Can someone help me to iterate the equation

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)

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.
Let fzero (link) do the iiteration for you:
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

My pleasure!
If my Answer helped you solve your problem, please Accept it!

Sign in to comment.

Categories

Find more on Function Creation in Help Center and File Exchange

Tags

Asked:

on 3 Mar 2019

Edited:

on 4 Mar 2019

Community Treasure Hunt

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

Start Hunting!