Question

How to write in matlab program ? (1) Reduce the following system of equations to one equation in ...

How to write in matlab program ?

(1) Reduce the following system of equations to one equation in terms of x and solve the resulting equation numerically using Newton-Raphson method.

ex/10y = 0 and 2logey – cosx = 2

(2) Solve the above equations numerically using system of equations, first by plotting the graph to obtain an initial approximation of the roots (such as x = 1 with y = 1 or other combinations), then produce the results numerically with tolerance of 1e−4.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Part 1

function file

myFunction.m

function fval= myFunction(x)

fval=10+5*cos(x)-x;

end

using newton raphson method

script file

newtonRaphson.m

clc;clear all;

x0=3.3;

maxIter=500;

tol=1e-16;

x=x0;

xOld=x0;

for i=1:maxIter

df=-5*sin(x)-1;

x=x-(myFunction(x)/df);

err=abs(x-xOld);

xSol=x;

xOld=x;

disp(['Iteration No is ', num2str(i),' Error is =',num2str(err),' ,XSol is =',num2str(x)]);

if err<tol

break;

end

end

Part 2

Plotting is done for initial guess

IntialGuess.m

x=-10:0.1:20;

y1=exp(x/10);

y2=exp(1+0.5*cos(x));

plot(x,y1,'-b'); hold on

plot(x,y2,'--k');


8 7 4 x 8.2 Y 2.2943 3 2 10 15 20 -10 -5solving of nonlinear equation by fsolve

funNonlinear.m

function fVal= funNonlinear(Y)

x=Y(1);

y=Y(2);

fVal(1,1)=exp(x/10)-y;

fVal(2,1)=2*log(y)-cos(x)-2;

end

Y0=[8.2;2.29];

ySol=fsolve(@(Y) funNonlinear(Y),Y0)

Note: Your given function were not clear either e^x/10 or e^(x/10); so solution may vary

Add a comment
Know the answer?
Add Answer to:
How to write in matlab program ? (1) Reduce the following system of equations to one equation in ...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT