how to solve for non linear system of equations containing series terms.
Show older comments
Hey all, I want to solve for following non linear system of equations:
I have only 3 unknown: k=x(1); F=x(2); epsilon= x(3); And the corresponding nonlinear system of equations is :
Equation 1: 0.94=[(k^2+1)*epsilon-2*F]/[(k^2-1)*epsilon]
Equation 2: F=(pi/2)*summation n varies from 0 to inf {[(2n!)/(2^(2n)*(n!)^2)]^2}*[k^(2n)]
Equation 3: epsilon=(pi/2)*summation n varies from 0 to inf {[(2n!)/(2^(2n)*(n!)^2)]^2}*[k^(2n)]/(1-2n)
To solve for this I have written following code:
function F = myfun(x)
curvediff=0.94;
n=0:1:10e3;
N1=factorial(2.*n);
D1=2.^(2.*n);
D2=factorial(n).^2;
ND=N1./(D1.*D2);
PI=ND.*ND;
PII=PI./(1-2.*n);
EI=PI.*x(1).^(2.*n);
EII=PII.*x(1).^(2.*n);
F=[curvediff-((x(1)*x(1)+1)*x(3)-2*x(2))/((x(1)*x(1)-1)*x(3));x(2)-pi/2.*sum(EI);
x(3)-pi/2.*sum(EII)];
And when I try to solve for this I am getting following error :
>> x0=[9.347;5;1.02];
>> x=fsolve(@myfun,x0);
??? Error using ==> trustnleqn at 28
Objective function is returning undefined values at
initial point. FSOLVE cannot continue.
Error in ==> fsolve at 366
[x,FVAL,JACOB,EXITFLAG,OUTPUT,msgData]=...
Kindly help me to debug this error. Thanks in advance.
Nikhil
Accepted Answer
More Answers (1)
Roger Stafford
on 29 Sep 2013
Based on the same principle as in my other answer you can compute the sum of those series using 'sum' and 'cumprod' in a manner which also avoids computing factorials. For example
n=0:1:(some large integer);
n1 = n(2:end);
F = pi/2*sum(cumprod([1,((2*n1-1)./(2*n1)*k).^2]));
(The 'F' here refers to the quantity in Equation 2, not the F in 'myfun'.)
(Note that the quantity 'k' must be kept less than 1. Otherwise the series diverges to infinity.)
Categories
Find more on Linear Algebra 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!