Answered step by step
Verified Expert Solution
Question
1 Approved Answer
TASK 1 : ( 8 - 1 2 min ) Main Script - Obtain and validate a user input for a coefficient vector Prompt the
TASK :min
Main Script Obtain and validate a user input for a coefficient vector
Prompt the user to enter a vector that contains the coefficients for apolynomial.
Perform data validation to check that the userentered vector contains an even number of elements
& HINT: Explore the rem or mod functions to help you. What is the remainder of an even number after dividing by What is the remainder of an odd number after dividing by
Continue reprompting the user to reenter the vector until a valid entry is obtained. Limit the total number of tries to attempts.
If after the attempt, an invalid vector is still entered, display a warning, and remove the last entry so that you have an even number of elements in the vector:
Example: Invalid Valid
Save the final vector as MAPolynomial.csy
TASK : min
Main Script Obtain and validate a user input for the root value initial guess; obtain a percent error value
Review the help documentation for the polyval and polyder functions. Practice in the command window to make sure you understand how each of these functions works and what the outputs mean! This is essential for the rest of the MA
Prompt the user to input an initial guess for is the value at which the userentered polynomial function entered in Task crosses the axis.
Perform data validation to check that the derivative of the polynomial does not equal zero at the userentered value. You are checking that Continue prompting the user to reenter an initial guess until a valid entry is obtained. Limit the total number of tries to attempts.
diamond HINT: You will need to use polyval and polyder
After three failed attempts to enter an value where the derivative does not equal zero, issue an error and terminate the program.
If a valid value is obtained, prompt the user to enter a percent error that will be used for the NewtonRaphson calculation. No additional validation on the percent error is required.
TASK : min
Function Calculate the true value where the function crosses the axis using the NewtonRaphson method Create a new function named FindZero,m
diamond Inputs: Final vector of coefficients from Task initial guess for from Task percent error from Task as a whole number.
diamond Outputs Final value for and number of iterations for the NewtonRaphson method
Within your function, repeatedly apply the NewtonRaphson method until the percent error between two subsequent iterations is less than the userentered percent error.
Hint! polyval and polyder are very useful here!
Percent Diff
If at any time the denominator in the NewtonRaphson calculation is equal to ie issue an error and terminate the program.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started