Question: Do this using anonymous functions so that you can easily evaluate f and fprime for any desired value of x . 2 . Set the

Do this using anonymous functions so that you can easily evaluate f and fprime for any desired value of x.
2. Set the initial guess for the root (x) equal to the user input to the function. This is the first value of xold.
3. Use the formula above to compute x and xnew.
4. Repeat step 3 until |x|10-8. This is a reasonable condition for terminating the loop because it means there isn't much change between successive guesses of the root. Note that on successive loops, xnew from the previous loop should become xold for the current loop. You can do this by defining a single variable x and setting up your algorithm properly.
function should have two inputs:
The first input is the initial guess of the root.
The second input is the variable a, for defining f(x)=ax-cos(x) and f'(x) within the function.
funfition should have two outputs:
The first output is the value of the root.
The second output is the number of iterations required to find the root. For example, if your loop only runs once, the numer of iterations is 1.
Do this using anonymous functions so that you can

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!