Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a code in MATLAB using the NEWTON - RAPHSON METHOD to solve the problem be

ID: 2084528 • Letter: W

Question

Write a code in MATLAB using the NEWTON - RAPHSON METHOD to solve the problem below to three significant figures.

Please help with the MATLAB code. Thank you.

8.35 Mechanical engineers, as well as most other engineers, use thermodynamics extensively in their work. The following polynomial can be used to relate the zero-pressure specific heat of dry air, cp kJ/(kg K), to temperature (K): 8T 2 Cp = 0.99403 + 1.671 x 10-4 T +9.7215 x 10-8T2 9.5838 x 10-11T3 +1.9520 x 10-1474 Determine the temperature that corresponds to a specific heat of 1.2 kJ/(kg K).

Explanation / Answer

The Answer to this problem is provided using a MATLAB function (script or .m file) written under the name "newtonraph.m" that takes three input parameters.

a.) Initial guess for temperature T in Kelvin, here referred as T0 (convergence to correct solution also depends on wise choice of initial guess in newton-raphson method for finding a real root of a polynomial, so it should be done with proper care).

b.) Maximum Iterations constraint put by the user, here referred as max_iter (an integer).

c.) Tolerance for error in the root-evaluation using newton-raphson method, here referred as tolerance.

NOTE :- On running this function with the above mentioned parameters, the output remains paused, which can be used to indicate the development from itertaion to iteration in the a.) estimated root, b.) error , c.) itertation number. so, the user si requested to move from iteration to iteration by pressing the enter key on keyboard. Iterations will stop automatically if the root is reached within the desired tolerance level desired or if the no. of iterations exceed max_iter.

MATLAB CODE :

function root=newtonraph(t0,max_iter,tolerance)

it_count=0;
error=1;

while(error>tolerance && it_count<max_iter)
  
% here the function is typed in whose root is reqd. i.e
% F(T)-Cp_required = 0
ft=((1.952e-14)*(t0^4))-((9.5838e-11)*(t0^3))+((9.7215e-8)*(t0^2))+((1.671e-4)*t0)+(0.99403-1.2);
  
% here, first, F(T)-Cp_required = 0 is differentiated w.r.t T and that
% new function is typed in
dft=((7.808e-14)*(t0^3))-((28.7514e-11)*(t0^2))+((19.443e-8)*t0)+((1.671e-4));
  
% Newton-raphson method doesnt work if in any iteration, the 'dft'
% becomes zero
if dft==0
disp('derivative is zero')
end
  
t1=t0-(ft/dft);
it_count=it_count+1;
error=abs(t1-t0);
  
%on pressing enter, you'll see progress from iteration to iteration
iteration=[t1 error it_count]
pause
  
t0=t1;
  
end

if (it_count>=max_iter)
disp('An accurate result could not be calculated because of a diverging initial value or less no. iteration constraint. ')
else
root=t1;
end

end

ANSWER IS 1126 K

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote