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 16:30
Amuffin recipe, which yields 12 muffins, calls for cup of milk for every 1 cups of flour. the same recipe calls for cup of coconut for every cup of chopped apple. to yield a batch of 30 muffins, how much flour will be needed in the mix?
Answers: 1
question
Mathematics, 21.06.2019 19:30
Evaluate 3(a + b + c)squared for a = 2, b = 3, and c = 4. a. 54 b. 243 c.729 add solution .
Answers: 1
question
Mathematics, 22.06.2019 03:00
What is the answer to question 11? richard simplified an expression in three steps,as shown taking 04.10 segment one exam part one (flvs)
Answers: 3
question
Mathematics, 22.06.2019 04:00
Asalad dressing recipe calls for 1 teaspoon of vinegar and three tablespoons of olive oil to only make 1/3 of the recipe for a single portion how much of each ingredient would you need
Answers: 1
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
Biology, 14.10.2019 23:00
question
Mathematics, 14.10.2019 23:00
Questions on the website: 13722359