Can someone help me to iterate the equation

1 Ansicht (letzte 30 Tage)
Karlo Turkovic
Karlo Turkovic am 3 Mär. 2019
Bearbeitet: John D'Errico am 4 Mär. 2019
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

Antworten (2)

John D'Errico
John D'Errico am 4 Mär. 2019
Bearbeitet: John D'Errico am 4 Mär. 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
Star Strider am 3 Mär. 2019
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 Kommentare
Karlo Turkovic
Karlo Turkovic am 4 Mär. 2019
Thank you!
Star Strider
Star Strider am 4 Mär. 2019
My pleasure!
If my Answer helped you solve your problem, please Accept it!

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by