subject
Mathematics, 14.11.2019 05:31 ugtguytu8528

We want to write a matlab function to solve the non-linear equation f(x) = 0 using any of the methods we learned in section-4. let's define our function as: (xsol, nit, error] = nonlin_lastname(solver, f, a, b, tol, nmax). the first input, solver, is an integer between 1 and 4 which will determine which method should be used, i. e. bisection method if solver=1; regula falsi method if solver=2; newton's method if solver=3; secant method if solver-4. the next input f is an anonymous function. the initial guess values are input by a and b: for the bracketing methods, a and b are the bounding points; for newton's method, a is the initial guess and b should be ignored (but still needs to be used when calling the function); and for the secant method, a and b are initial solution guesses. for bracketing methods, if the initial interval does not bracket a solution, your functions should return with an error message. the convergence tolerance and the maximum number of iterations are input by tol and nmax, respectively. for the newton's method, use the procedure in problem 2.b for estimating the derivative. the function has three outputs: the approximate numerical solution xsol, the integer nit which is the number of iterations it took for the solution to converge, and the error in your solution, i. e. f(x nit)=f(xsol). the iterations should stop if any of the following convergence criteria is met:
i) ii) if(xn)] iii) n > nmax (or in other words we should do nmax iterations at most) optional: if you want to examine the trend of the iterations, you may have your function print all the information of the iteration results to the screen using: fprintf('n=%i: \tx%i = %e it f(x%i)=%e \n',n, n,x, n,f(x)); where n is the current iteration counter, x is the current approximation and f(x) is the function value at x. now write a script to test your function for different nonlinear equations given below with their specified initial guess values. use a tolerance of 10-11 and nmax = 1000.
a. *4 = 3x2 + 2; a = -1.5; b = 10
b. 1 = (2x2 – 1.2)2(2(x – 2.5))*; a = 1.5; b = 2.5
c. tan (x)tan (x) = 1000; a = 1.2; b = 1.45 d. xe* = 10; a = -3; b = 3 e. [x]= 0.3; a = -1; b = 0 f. cos(x) = x; a = -1.579; b = 2 for each of the nonlinear equations, report your results in a separate table with the general format below and using four decimal digits. you may use 'format short; ' in your matlab script to automatically round the numbers to four decimal places. then for each nonlinear equation, plot the function f in the range [2a - b, 2b - a) and use the plots to explain the behavior of each method. method nit xsol error bisection regula falsi newton's secant

ansver
Answers: 2

Another question on Mathematics

question
Mathematics, 21.06.2019 14:30
The la dodgers hit the most homeruns in 2014. the number of homeruns accounted for 6% of the entire major leauge baseball homerun count. if 583 total homeruns were hit, approximately how many did the la dodgers hit
Answers: 1
question
Mathematics, 21.06.2019 20:00
Which of the following is not a subset of {1,2,3}?
Answers: 2
question
Mathematics, 21.06.2019 20:30
At the "no mutants allowed" country farm, every sheep has 4 legs, every chicken has two legs, and all animals have only 1 head. asked to count how many sheep and chicken are in the fields, a farm boy reports back that there are 140 feet and 50 heads. how many sheep and chicken are there? there are sheep and chicken at the farm.
Answers: 1
question
Mathematics, 21.06.2019 21:40
Will mark name all segments skew to bc
Answers: 2
You know the right answer?
We want to write a matlab function to solve the non-linear equation f(x) = 0 using any of the method...
Questions
question
History, 26.08.2020 19:01
Questions on the website: 13722363