Difference of the two functions
2 views (last 30 days)
Show older comments
yogeshwari patel
on 29 May 2021
Commented: yogeshwari patel
on 29 May 2021
I wrote the text for the two function as :
U=zeros(1,2,'sym');
A=zeros(1,2,'sym');
B=zeros(1,2,'sym');
C=zeros(1,2,'sym');
series(x,t)=sym(zeros(1,1));
U(1)=x^2/10
for k=1:5
A(1)=0;
C(1)=0;
for i=1:k
A(1)=simplify(A(1)+U(i)*U(k-i+1)) ;
end
for i=1:k
C(1)=simplify(C(1)+U(i)*diff(U(k-i+1),x,1));
end
U(k+1)=(simplify(2*C(1)+4*A(1)-3*U(k))))/k;
end
disp (U);
for k=1:6
series(x,t)=simplify(series(x,t)+U(k)*(power(t,k-1)));
end
series
C=zeros(10,10);
for x=1:10
for t=1:10
f=t/10;
C(x,t)=series(x,f);
end
end
u=zeros(10)
for x=1:10
for t=1:10
e=t/10;
u(x,t)=sin(x)+sin(e);
end
end
disp(u)
r=abs(u-C)
The code is showing the dimension error in the last line when is use the commmand surf(x,t,r)
0 Comments
Accepted Answer
Walter Roberson
on 29 May 2021
format long g
syms x t real
U=zeros(1,2,'sym');
A=zeros(1,2,'sym');
B=zeros(1,2,'sym');
C=zeros(1,2,'sym');
series(x,t)=sym(zeros(1,1));
U(1)=x^2/10
for k=1:5
A(1)=0;
C(1)=0;
for i=1:k
A(1)=simplify(A(1)+U(i)*U(k-i+1)) ;
end
for i=1:k
C(1)=simplify(C(1)+U(i)*diff(U(k-i+1),x,1));
end
U(k+1)=(simplify(2*C(1)+4*A(1)-3*U(k)))/k;
end
disp (U);
for k=1:6
series(x,t)=simplify(series(x,t)+U(k)*(power(t,k-1)));
end
series
C=zeros(10,10);
for x=1:10
for t=1:10
f=t/10;
C(x,t)=series(x,f);
end
end
u=zeros(10);
[X, T] = meshgrid(1:10, 1:10);
e = T/10;
u = sin(x) + sin(e);
r = abs(u-C)
surf(X, T, r)
xlabel('x');
ylabel('t');
zlabel('r')
More Answers (0)
See Also
Categories
Find more on Calculus in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!