Question

script for Secant Method. Using Octave. The data: y = x.^2 - 1.2 x_lower = 0.4...

script for Secant Method. Using Octave.

The data:

y = x.^2 - 1.2

x_lower = 0.4

x_upper = 0.6


Es = 0.5*10^(2-n)

n = 5

Homework Answers

Answer #1

Execute the following MATLAB code:

syms x
y=inline(x^2-1.2); %Define function y

x(1)=0.4; %x_lower
x(2)=0.6; %x_upper

n=5;
Es=0.5*10^(2-n); %Allowed error
iter=0; %Initiate the value of iteration with zero

for i=3:1000
x(i) = x(i-1) - (y(x(i-1)))*((x(i-1) - x(i-2))/(y(x(i-1)) - y(x(i-2))));
iter=iter+1;
if abs((x(i)-x(i-1))/x(i))*100<Es
root=x(i); %root in fraction
vpa(root,4) %root into decimal from fraction
iter=iter %number of iterations
break
end
end

Obtain the following output:

ans =

1.095

iter =

6

Conclusion:

The value of "x" is 1.095 using secant method.

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
Using the secant method, find the roots of the following. x=e-x. Carry out the method to...
Using the secant method, find the roots of the following. x=e-x. Carry out the method to find three approximations.
Using the Script: function EulerMethod1(n) X = 0 : 1/n : 1 ; Y = zeros(...
Using the Script: function EulerMethod1(n) X = 0 : 1/n : 1 ; Y = zeros( 1, n + 1 ) ; Y(1) = 1 ; for k = 1 : n m = Y(k) ; Y(k + 1) = Y(k) + m*( X(k + 1) - X(k) ) ; end clf plot( X, Y ) Create a new script, which defines the function EulerMethod2. The purpose of EulerMethod2 is to use Euler's Method to approximate the solution to the...
Using MATLAB or Octave, use documenting code to Write a script that prompts the user for...
Using MATLAB or Octave, use documenting code to Write a script that prompts the user for a non-negative integer value a. The script should then evaluates the sum Pn i=1 i a using a running sum for the case when n = 5. More specifically, use a counter for i that is used in the output fprintf as well as in the running sum. Feel free to write some code and just repeat it 5 times in your script. Sample...
Let f(x)=sin(x)+x^3-2. Use the secant method to find a root of f(x) using initial guesses x0=1...
Let f(x)=sin(x)+x^3-2. Use the secant method to find a root of f(x) using initial guesses x0=1 and x1=4. Continue until two consecutive x values agree in the first 2 decimal places.
Using MATLAB or Octave, use documenting code to Write a script that prompts the user for...
Using MATLAB or Octave, use documenting code to Write a script that prompts the user for an integer between 0 and 9999, inclusive. The script should then calculate the digit in each of the 1000’s, 100’s, 10’s, and 1’s place of the number. Create a variable for each of the 4 extracted digits. For example, if your variables are named nThousands, nHundreds, nTens, and nOnes, then, in the case of 9471, they would be end up being set to 9,...
X - Bernoulli (0.4) Y - Binomial (n = 10, p = 0.4) Z - Binomial...
X - Bernoulli (0.4) Y - Binomial (n = 10, p = 0.4) Z - Binomial (n = 3, p = 0.4); X, Y, Z all independent; find pmf of W = X + Y + Z
refer to the graph of y=f(x)=x^2+x shown a. Find the slope of the secant line joining(-3,f(-3))...
refer to the graph of y=f(x)=x^2+x shown a. Find the slope of the secant line joining(-3,f(-3)) and (0,f(0)) b. Find the slope of the secant line joining (-3,f(-3)) and(-3+h,f(-3+h)) c . Find the slope of the graph at (-3,f(-3)) d. Find the equation of the tangent line to the graph at (-3,f(-3))
Use Euler's method to approximate y(1.2), where y(x) is the solution of the initial-value problem x2y''...
Use Euler's method to approximate y(1.2), where y(x) is the solution of the initial-value problem x2y'' − 2xy' + 2y = 0,  y(1) = 9,  y'(1) = 9, where x > 0. Use h = 0.1. Find the analytic solution of the problem, and compare the actual value of y(1.2) with y2. (Round your answers to four decimal places.) y(1.2) ≈     (Euler approximation) y(1.2) =     (exact value)
Use Euler's method with step size 0.4 to estimate y ( 0.8 ) , where y...
Use Euler's method with step size 0.4 to estimate y ( 0.8 ) , where y ( x ) is the solution of the initial-value problem y' = 4x + y^2 , y ( 0 ) = 0 . y ( 0.8 ) =_____________________
You have collected data that are exponentially distributed:  pdf f(x)= θexp(-xθ), x>0. 0.1, 0.2, 0.3, 0.4, 0.5,...
You have collected data that are exponentially distributed:  pdf f(x)= θexp(-xθ), x>0. 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, and 1.0. 1) Determine the maximum likelihood estimation of θ. 2) Implement the central limit theorem to obtain a 95% CI for θ.