Question: function project _ 9 ( ) PROJECT _ 9 project _ 9 ( ) is the driver function for the program. % Name: $ Date:

function project_9()
PROJECT_9 project_9() is the driver function for the program.
%
Name:
$ Date:
% Class: CMPSC 200
Description: Approximate the zero of a function using the
x Newton-Raphson Method.
% Print the splash screen - you need to add the print header yourself
$ Create an anonymous function by calling the get_function() function
Use the get data function three times to enter the three inputs:
%,xa, and b
%x0 is the starting value
% a is the minimum (it is only for the plot at the end)
% b is the maximum (it is also only for the plot at the end)
In the get_data function you must use check_data to error check
inputs. If a and b are not
In the correct range the check data function will return 1, and in
get_data the function will be called again recursively = this
is an important aspect of the program
The restrictions on the inputs should be
xo can be any value
starting_point, a, must be less than xin
stopping.point, b, must be greater than x
% Call get_zero to estimate the zero
x zero =get zero (f,x):
6 Print results from the previous function - create and then call
% a print-results function. This function will have three input variables
% the function handle
%- the starting point, xo
%- the zero point = in this program x zero
GET_ZERO x= get zero (f,x) determines the zero of the function f
Name: :
Date:
Class:
CMPSC 200
% Set value eps
% Should be small but reasonable. About 0,0001 works well
6 Check if eps). If it is then update x using
the Newton - Raphson and then call get zero again with the same
function but the new value.
and
function plot, function, zero(func,x point, minx, maxx )
8 PLOT FUNCTION,ZERD plot function,zero(func, min, maxx, xPoint) plots
4 the function passed in func between the minimum and maximum values
8 Indicated. It then plots a point at the zero of the function with a 4
cross at that point.
%. Name:
Class: CMPSC 200
Date: March 19,2019
%
Create a vector of points from min to max
x= Linspace , max, 250
& Finish with the title and axes labels
title (func2str (func)):
x labe l'(x'):
ylabel('y'');
hold off % return the hold to the default
end
using this template in matlab do the following project
Objective Using MatLab Recursive Functions.
Project In the Calculus we study the Newton-Raphson method for solving equations. This technique uses the value of a function and its derivative to estimate where the function crosses the x axis. If necessary it repeats the process until the amount of change in the estimate is smaller than some predetermined amount.
The formula is
xn+1=xn-f(xn)f'(xn)
You will write a program that uses a recursive function to perform this operation estimating where a function crosses the x-axis.
Methodology
Prompt the user for the mathematical function that you want to solve.
Prompt the user for the starting value. Call this x0.
In the get_zero function you will set a differential value. Call this dx. It should be a small value, say dx=0.01.
In the get_zero function you will set a stopping criteria. Call this eps. It should be a small value, say eps =0.001.
Call the get_zero function. You will pass the function and the starting value for the zero of the function. The function will return a new value for the zero.
In the get_zero function calculate a new value for x0 by evaluating the function and an estimate of the derivative at x.
Compare |f(x)| to eps.
If |f(x)|> eps then call get_zero from the selection structure. You pass the same function and the same variable, but now x contains the new predicted value for the intercept.
If If |f(x)| eps the function returns the calculated intercept value.
Call print_results to show the function, the starting value, and the estimated zero. An example of what the output might look like is
\ta
 function project_9() PROJECT_9 project_9() is the driver function for the program.

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!