How to find the approximation of the solution to an equation with an infinite series?

2 views (last 30 days)
Hi, I am very new to matlab and I am trying to solve an equation with an infinite serie. The equation looks like this:
The variable is \alpha and the rest are all parameters.So this thing looks ugly, and almost clearely it has no closed form solution, but I can somehow gurantee that the thing on the left converges by choosing the right parameters. What I want to do is to choose numbers for all parameters and solve for \alpha. I think it would be ok if I replace infinity with a large number. But I have been trying this for a long time and still haven't find out how to do this. I would really appreciate it if someone can give me a hint about how to do this. (Even better if you can provide a code sample). Thanks!

Accepted Answer

Bruno Luong
Bruno Luong on 26 Oct 2018
N = 50; % number of sum
t = (1:N);
delta = 0.6;
R = 2;
c = 5;
M0 = 2;
Rc = R/c;
rhs = c/(M0*R);
sfun = @(beta) sum(((beta*delta).^(t-1).*(1-beta*delta))./(Rc-(Rc-M0)*beta.^t).^2);
beta = fzero(@(beta) sfun(beta)-rhs, 0);
alpha = 1-beta
  2 Comments
Jiahao Chen
Jiahao Chen on 26 Oct 2018
Hi Bruno, thanks for your answer! The code worked but as I change the parameters, sometimes the following error comes out:
Exiting fzero: aborting search for an interval containing a sign change because NaN or Inf function value encountered during search. (Function value at -5.12 is NaN.) Check function or try again with a different starting value.
I guess this is because under the chosen parameter there is no solution. But I am just wondering if there is a way to specify a starting point of searching for the solution? I am only concerned about the solutions that are between 0 and 1, so if the function goes to infinity somewhere else should not matter.
Bruno Luong
Bruno Luong on 26 Oct 2018
Edited: Bruno Luong on 26 Oct 2018
I don't know enough the equation to answer.
But you can first plot the function
>> ezplot(@(beta) sfun(beta)-rhs,[0 1]);
to see if it cross 0, and approximately where.

Sign in to comment.

More Answers (1)

Torsten
Torsten on 26 Oct 2018
function main
c = ...;
M0 = ...;
R = ...;
delta = ...;
N = ...;
x0 = ...;
sol = fzero(@(x)fun(x,c,M0,R,delta,N),x0)
end
function res = fun(x,c,M0,R,delta,N)
res = 0.0;
for i = 1:N
res = res + ((1-x)*delta))^(i-1)/(R/c-(R/c-M0)*(1-x)^i)^2
end
res = res - c/(M0*R)/(1-(1-x)*delta))
end
  1 Comment
Jiahao Chen
Jiahao Chen on 26 Oct 2018
Hi Torsten, thanks for your answer! But it seems that there is an error when I run the code:
function main
Error: Function definitions are not permitted in this context.
And I am a little bit confused about what is x0. Is that the starting point where the program start to look for a solution (change of sign)?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!