Question: Hi I need to write a python code for the following: (part a and b can be done by hand) Consider the nonlinear equation: f

Hi I need to write a python code for the following: (part a and b can be done by hand) Consider the nonlinear equation: f (x) = sin(x) x2= 0

(a) Can you solve the equation by hand, i.e. express the solution x* explicitly in terms of elementary functions and the constant ?

(b) Show that the equation f (x) = 0 has the same solution(s) as g(x) = x if g(x) =1/2(sinx)-1/2(x2)+x In fact, we can show that for any initial point in (0, 2] the sequence xk= g(xk1 ) converges to a unique solution x* . (c) Write a function that computes this sequence. Your function should: Take for input the an initial point, a maximal number of iterations and a tolerance for |xk xk-1| (the estimated error) and for |f (xk)| (the residual).

Print to the command window the list of iterates, stopping when either the maximal number of iterations is reached or the estimated error and the residual are below their respective tolerance. Output the approximate solution, its estimated error and its residual.

(d) If you used a for or while loop in (c), program a function with the same functionality using recursion (i.e. no explicit loops). If you used recursion in (c) then program a function with the same functionality using loops (i.e. no recursion). Name your functions iteration.m for the version with a loop and recursion.m for the version without.

e) What happens if you take x0=0? What happens if you take x0<0?

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 Databases Questions!