Question

Using Matlab, find an approximation by the method of false position for the root of function...

Using Matlab, find an approximation by the method of false position for the root of function f(x) = ex −x2 + 3x−2 accurate to within 10−5 (absolute error) on the interval [0,1]. Please answer and show code.

Pseudo Code for Method of False Position:

Given [a,b] containing a zero of f(x);

tolerance = 1.e-7; nmax = 1000; itcount = 0; error = 1;

while (itcount <=nmax && error >=tolerance)

itcount = itcount + 1;

x= a - ((b-a)/(f(b)-f(a)))f(a)

error =abs(f(x));

If f(a)*f(x) < 0

then b=x;

else a=x;

end while.

Homework Answers

Answer #1

clc;
clear all;

format short
f=@(x)exp(x)-x^2 + 3*x-2 ; %function


a=0;b=1; % interval
% checking sign
if(f(b)<f(a))
m=a;
a=b;
b=m;
end

n=1;
err=0.1;
tol=1e-5;

while((err>tol))
  
c=(a*f(b)-b*f(a))/(f(b)-f(a));% false method formula
if ( f(c) == 0 )
break;
elseif ( f(a)*f(c) < 0 )
b = c;
else
a = c;
end
  
err=abs(f(c)); % error
n=n+1; % update next iteration
end
disp('root of function')
c
disp('number of iteration')

%%%%%%%%%%%%%%%%% Answer

root of function

c =

0.2575

number of iteration

n =

5

>>

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
One old-time method to estimate the square root of any positive number a is called divide...
One old-time method to estimate the square root of any positive number a is called divide and average: xi+1 = xi + a xi 2 Show that this formula is equivalent to Newton method. Hint: Start by solving f (x) = x 2 − a = 0. Use Matlab code
Use Newton's method with the specified initial approximation x1 to find x3, the third approximation to...
Use Newton's method with the specified initial approximation x1 to find x3, the third approximation to the root of the given equation. x3 + 5x − 2 = 0,    x1 = 2 Step 1 If f(x) = x3 + 5x − 2, then f'(x) = _____ x^2 + _____ 2- Use Newton's method to find all roots of the equation correct to six decimal places. (Enter your answers as a comma-separated list.) x4 = 5 + x .
Newton's method: For a function ?(?)=ln?+?2−3f(x)=ln⁡x+x2−3 a. Find the root of function ?(?)f(x) starting with ?0=1.0x0=1.0....
Newton's method: For a function ?(?)=ln?+?2−3f(x)=ln⁡x+x2−3 a. Find the root of function ?(?)f(x) starting with ?0=1.0x0=1.0. b. Compute the ratio |??−?|/|??−1−?|2|xn−r|/|xn−1−r|2, for iterations 2, 3, 4 given ?=1.592142937058094r=1.592142937058094. Show that this ratio's value approaches |?″(?)/2?′(?)||f″(x)/2f′(x)| (i.e., the iteration converges quadratically). In error computation, keep as many digits as you can.
Solve the following problem using the MATLAB environment Write a function [approx_root, num_its] = bisection(f,a,b,tol) that...
Solve the following problem using the MATLAB environment Write a function [approx_root, num_its] = bisection(f,a,b,tol) that implements the bisection method. You function should take as input 4 arguments with the last argument being optional, i.e, if the user does not provide the accuracy tol use a default of 1.0e-6 (use varargin to attain this). Your function should output the approximate root, approx_root and the number of iterations it took to attain the root, num_its. However, if the user calls the...
Find the root of the function: f(x)=2x+sin⁡(x)-e^x, using Newton Method and initial value of 0. Calculate...
Find the root of the function: f(x)=2x+sin⁡(x)-e^x, using Newton Method and initial value of 0. Calculate the approximate error in each step. Use maximum 4 steps (in case you do not observe a convergence).
Find root of the equation cos (x) = xex using Bisection method. Make calculation for 4...
Find root of the equation cos (x) = xex using Bisection method. Make calculation for 4 iterations. Choose xl= 0 and xu= 1. Determine the approximate error in each iteration. Give the final answer in a tabular form.
Here is a modification of the BST program that includes a recursive find method: BinarySearchTree2C.java (posted...
Here is a modification of the BST program that includes a recursive find method: BinarySearchTree2C.java (posted below) Implement the following methods using recursion: int depth() // returns the length of the deepest path from root to any leaf int node_count() // returns the number of nodes in the tree void insert(int n) // inserts value n into the tree BinarySearchTree2C clone() // returns a clone (deep copy) of the tree Add code to the main method to test these methods....
Curve-Fit Function USING MATLAB Using the top-down design approach, develop a MATLAB function A8P2RAlastname.m that reads...
Curve-Fit Function USING MATLAB Using the top-down design approach, develop a MATLAB function A8P2RAlastname.m that reads data from a file and performs regression analysis using polyfit and polyval. The function shall have the following features: The input arguments shall include the file name (string), a vector of integers for the degrees of polynomial fits to be determined, and an optional plot type specifier (‘m’ for multiple plots, ‘s’ for a single plot - default). The data files will be text...
Helllp plz Allow the InsertAt method to add to the front position 0 (zero) also if...
Helllp plz Allow the InsertAt method to add to the front position 0 (zero) also if you try to add to a position greater than the number of nodes you get an error warning. /INSERT.C /*THIS PROGRAM READS A BINARY FILE (MUST ALREADY EXIST AND BE FILLED) */ /*AND PUTS IT INTO A LINKED LIST AND PRINTS THE LIST TO THE SCREEN) */ #include #include #include #include typedef struct ENTRY { char name[81]; }ENTRY; typedef struct LISTREC /* LISTREC is...
using System; public static class Lab5 { public static void Main() { // declare variables int...
using System; public static class Lab5 { public static void Main() { // declare variables int inpMark; string lastName; char grade = ' '; // enter the student's last name Console.Write("Enter the last name of the student => "); lastName = Console.ReadLine(); // enter (and validate) the mark do { Console.Write("Enter a mark between 0 and 100 => "); inpMark = Convert.ToInt32(Console.ReadLine()); } while (inpMark < 0 || inpMark > 100); // Use the method to convert the mark into...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT