- #1

- 33

- 0

## Homework Statement

I am supposed to find the roots of the equation: 10e

^{sinx}= x

^{2}- 5x +4 in MATLAB using Newton's method with a tolerance of 10

^{-8}. There should be three roots.

## Homework Equations

p=p

_{o}- f(p

_{o})/f'(p

_{o})

|p - p

_{o}| < TOL

## The Attempt at a Solution

Here is what I have for the code so far:

Matlab:

```
N=100;
x=zeros(N+1,1);
f=x.^2-(5*x)+4-(10*exp(sin(x)));
fprime= diff(sym(f));
TOL=1E-7;
p0=1;
I=1;
x(1)=p0;
while (I<=N+1)
fp=f(x(I-1));
fprimep=fprime(x(I-1));
x(I)=x(I-1)-fp/fprimep;
if (abs(x(I)-x(I-1))<=TOL)
Ifinal=I;
break;
end
I=I+1;
x(I-1)=x(I);
end
```

I just keep getting so many errors. MATLAB won't even accept the function itself(but it doesn't specify what the problem is). Any help would be appreciated, as this is the first time I've ever used this program and have no idea what I'm doing.

Last edited by a moderator: