error in logical calculation

1 view (last 30 days)
yogeshwari patel
yogeshwari patel on 5 Apr 2022
Edited: Steven Lord on 5 Apr 2022
syms x a
Y=sym(zeros(1));
Y(1)=0;
a=1/2
for i=1:4
if i==5
A=1
else
A=0
end
if i==4
B=1
else
B=0
end
Y(i+1)=simplify((gamma(a*(i-1)+1)/gamma((a*(i-1)+3/2))*(A-Y(i)+((2*B)/gamma(5/2)))));
end
disp(Y)
%%%%%%%%%%%%%%%%%%%%%
for i=4 ,the value of Y(5) should be 1 but it is showwing s2535301200456458897054207582575/2535301200456458802993406410752. If i work with pen and paper and simplify it again i get 1 .So what is the mistake in the code
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Question -2
syms x a
series(x)=sym(zeros(1));
Y=sym(zeros(1));
m=sym(1);
Y(1)=0;
Y(2)=a;
%N=input ('enter the number of coefficient required')
for k=1:6
Y(k+2)=((18*kroneckerDelta(k,m)-9*Y(k)))/(k*(k+1));
end
disp(Y)
for k=1:6
series(x)=series(x)+Y(k)*(power(x,k-1));
end
series % Find the series in terms of a and x
M=series(pi/2)-1
a=solve(M) % find the value of a
series
I want to put the value of a in series and want to evaluete the series in terms of x only. I used the command series but it is not working
[SL: edited to pull the prose in the middle of the two questions out of the code block.]
  1 Comment
Jan
Jan on 5 Apr 2022
Please explain "is not working" with any details. It is easier to solve a problem than to guess, what the problem is.

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by