Can someone help me to iterate the equation
Show older comments
I have to iterate the equation to find M,
I have tried to use codes from previous topic but they do not work on Matlab 2018b.
0=(1/M)*(2/2.4*0.4/2.4*M^2)^(2.4/0.8)-0.3/0.2
Thank you! Br
Answers (2)
John D'Errico
on 4 Mar 2019
Edited: John D'Errico
on 4 Mar 2019
Algebra?
(1/M)*(2/2.4*0.4/2.4*M^2)^(2.4/0.8)-0.3/0.2 == 0 -->
(1/M)*(1/7.2*M^2)^3 - 3/2 == 0
M^5 * (1/7.2)^3 == 3/2
Which yields:
M = nthroot(7.2^3 * 3/2,5)
Or, more simply:
M = (7.2^3 * 3/2)^0.2
M =
3.54501
So why do you think you need an iterative scheme to solve it? It is so simple to solve, ergo this must be homework. As such, fzero is arguably unacceptable. As well, you explicitly asked for an iterative method. So I might guess that your assignment is to find a fixed point iteration scheme that is convergent.
What do we know about fixed point iteration? There are requirements on when such a scheme will be convergent, based on the derivative of that function near the solution.
A quick plot of the function would show the slope of it is roughly 2 in that vicinity. So, if I divide by 3, then subtract the result from M.
F(M) = @(M) (1/M)*(2/2.4*0.4/2.4*M^2)^(2.4/0.8)-0.3/0.2;
Miter = @(M) M - F(M)/3;
Now, just iterate. 30 tmes through a loop should suffice.
M = 5;
for i= 1:30
M = Miter(M);
end
M
M =
3.54501232687533
Which, coincidentally, is the result that simple algebra would yield.
Star Strider
on 3 Mar 2019
Mfcn = @(M) (1/M).*(2/2.4*0.4/2.4*M.^2).^(2.4/0.8)-0.3/0.2;
[Mval,fval] = fzero(Mfcn, 10)
producing:
Mval =
3.54501232687533
fval =
0
2 Comments
Karlo Turkovic
on 4 Mar 2019
Star Strider
on 4 Mar 2019
My pleasure!
If my Answer helped you solve your problem, please Accept it!
Categories
Find more on Function Creation 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!