symbolic substitution error and convert
syms x
series1(x)=sym(zeros(1));
series2(x)=sym(zeros(1));
U=zeros(1,2,’sym’);
syms x m z
alpha=15;
gamma=0.01;
U(1)=m;
U(2)=0;
A(1)=zeros(1,’sym’);
for k=1
U(k+2)=z;
A(1)=0;
for m=1:k
A(1)=A(1)+U(m)*(k-m+1)*(k-m+2)*U(k-m+3);
end
B=k*(k+1)*U(k+2)+alpha*A(1)-gamma*U(k)
D=simplify(solve(B,z))
U(k+2)=D
end
disp(U(3))
for k=1:3
series1(x)=simplify(series1(x)+U(k)*(power(x,k-1)));
end
series1
e1=subs(series1,x,1);
e=e1-1;
format long
accuracy=input(‘enter the accuracy’)
f=e(x)
g=inline(f)
g=inline(f)
a=input(‘enter the ist approximation=’)
b=input(‘enter the 2nd approximation=’)
fa=feval(g,a)
fb=feval(g,b)
while fa*fb>0
a=input(‘enter the ist approximation=’)
b=input(‘enter the 2nd approximation=’)
fa=feval(g,a)
fb=feval(g,b)
end
for i=1:50
c=(a+b)/2;
fc=feval(g,c);
disp([i a fa b fb c fc abs(b-a)])
if fc==accuracy
fprintf(‘the root of the equation is %f’,c)
break;
elseif abs(b-a)<=accuracy
fprintf(‘the root of the equation is %f’,c)
break;
elseif fa*fc<=0
b=c;
fb=fc;
else
a=c;
fa=fc;
end
end
fprintf(‘the value of c=%f’, c)
series2(x)=subs(series1,m,c)
toc
the synatx is correct but still the value of m is not substituted insyms x
series1(x)=sym(zeros(1));
series2(x)=sym(zeros(1));
U=zeros(1,2,’sym’);
syms x m z
alpha=15;
gamma=0.01;
U(1)=m;
U(2)=0;
A(1)=zeros(1,’sym’);
for k=1
U(k+2)=z;
A(1)=0;
for m=1:k
A(1)=A(1)+U(m)*(k-m+1)*(k-m+2)*U(k-m+3);
end
B=k*(k+1)*U(k+2)+alpha*A(1)-gamma*U(k)
D=simplify(solve(B,z))
U(k+2)=D
end
disp(U(3))
for k=1:3
series1(x)=simplify(series1(x)+U(k)*(power(x,k-1)));
end
series1
e1=subs(series1,x,1);
e=e1-1;
format long
accuracy=input(‘enter the accuracy’)
f=e(x)
g=inline(f)
g=inline(f)
a=input(‘enter the ist approximation=’)
b=input(‘enter the 2nd approximation=’)
fa=feval(g,a)
fb=feval(g,b)
while fa*fb>0
a=input(‘enter the ist approximation=’)
b=input(‘enter the 2nd approximation=’)
fa=feval(g,a)
fb=feval(g,b)
end
for i=1:50
c=(a+b)/2;
fc=feval(g,c);
disp([i a fa b fb c fc abs(b-a)])
if fc==accuracy
fprintf(‘the root of the equation is %f’,c)
break;
elseif abs(b-a)<=accuracy
fprintf(‘the root of the equation is %f’,c)
break;
elseif fa*fc<=0
b=c;
fb=fc;
else
a=c;
fa=fc;
end
end
fprintf(‘the value of c=%f’, c)
series2(x)=subs(series1,m,c)
toc
the synatx is correct but still the value of m is not substituted in syms x
series1(x)=sym(zeros(1));
series2(x)=sym(zeros(1));
U=zeros(1,2,’sym’);
syms x m z
alpha=15;
gamma=0.01;
U(1)=m;
U(2)=0;
A(1)=zeros(1,’sym’);
for k=1
U(k+2)=z;
A(1)=0;
for m=1:k
A(1)=A(1)+U(m)*(k-m+1)*(k-m+2)*U(k-m+3);
end
B=k*(k+1)*U(k+2)+alpha*A(1)-gamma*U(k)
D=simplify(solve(B,z))
U(k+2)=D
end
disp(U(3))
for k=1:3
series1(x)=simplify(series1(x)+U(k)*(power(x,k-1)));
end
series1
e1=subs(series1,x,1);
e=e1-1;
format long
accuracy=input(‘enter the accuracy’)
f=e(x)
g=inline(f)
g=inline(f)
a=input(‘enter the ist approximation=’)
b=input(‘enter the 2nd approximation=’)
fa=feval(g,a)
fb=feval(g,b)
while fa*fb>0
a=input(‘enter the ist approximation=’)
b=input(‘enter the 2nd approximation=’)
fa=feval(g,a)
fb=feval(g,b)
end
for i=1:50
c=(a+b)/2;
fc=feval(g,c);
disp([i a fa b fb c fc abs(b-a)])
if fc==accuracy
fprintf(‘the root of the equation is %f’,c)
break;
elseif abs(b-a)<=accuracy
fprintf(‘the root of the equation is %f’,c)
break;
elseif fa*fc<=0
b=c;
fb=fc;
else
a=c;
fa=fc;
end
end
fprintf(‘the value of c=%f’, c)
series2(x)=subs(series1,m,c)
toc
the synatx is correct but still the value of m is not substituted in mbolic computation MATLAB Answers — New Questions









