Question

Please, please use MATLAB and explain everything, thank you!!! If possible please plot the values.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution: The MATLAB code for secant method is shown below: Enter function la-input (Enter function:,s Store function f-inl

break %End end %End end Sample Output: sh-4.3$ octave -qf-no-window-system demo.m Enter function: x-cos (x) Enter 1st point 0

code:

%Enter function

la=input('Enter function:','s');

%Store function

f=inline(la)

%Get first point

x(1)=input('Enter 1st point : ');

%Get second point

x(2)=input('Enter 2nd point : ');

%Enter error value

n=input('Enter error allowed: ');

%Define lIter

lIter=0;

%Loop

for li=3:1000

%Compute x

x(li) = x(li-1) - (f(x(li-1)))*((x(li-1) - x(li-2))/(f(x(li-1)) - f(x(li-2))));

  

   %Update iteration

    lIter=lIter+1;

   

    %If error condition matches

    if abs((x(li)-x(li-1))/x(li))*100<n

   

        %Assign root

        root=x(li)

       

        %Store iteration count

        iteration=lIter

       

        %Break

        break

       

    %End   

    end

   

%End   

end

Add a comment
Know the answer?
Add Answer to:
Please, please use MATLAB and explain everything, thank you!!! If possible please plot the values. Consider...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a matlab program to implement the secant root finding method in matlab. The function name...

    Write a matlab program to implement the secant root finding method in matlab. The function name should be Secant and it should take the equation as input whoes root has to be found and the two initial values of a and b and maximum tolerable error. Consider the following example: Your code should generate the following: >> secantAssg5(@(x)(x^4+x^2+x+10),2,3,0.0001)    Xn-1      f(Xn-1)      Xn      f(Xn)      Xn+1      f(Xn+1) 2.0000   32.0000    3.0000 103.0000    1.5493   19.7111 ….. ….. ….. Root is x = 0.13952 ans...

  • Please code in MatLab or Octave Output should match Sample Output in Second Picture Thank you...

    Please code in MatLab or Octave Output should match Sample Output in Second Picture Thank you 5. In this problem we will investigate using the Secant Method to approximate a root of a function f(r). The Secant Method is an iterative approach that begins with initial guesses , and r2. Then, for n > 3, the Secant Method generates approximations of a root of f(z) as In-1-In-2 n=En-1-f (x,-1) f(Fn-1)-f(-2) any iteration, the absolute error in the approximation can be...

  • In MATLAB please Consider the nonlinear function: y = f(x) = x3 cos x a. Plot...

    In MATLAB please Consider the nonlinear function: y = f(x) = x3 cos x a. Plot y as a function of x as x is varied between -67 and 67. In this plot mark all the locations of x where y = 0. Make sure to get all the roots in this range. You may need to zoom in to some areas of the plot. These locations are some of the roots of the above equation. b. Use the fzero...

  • i need the answer to be on a MatLab window 1. Consider the following equation, which...

    i need the answer to be on a MatLab window 1. Consider the following equation, which represents the concentration (c, in mg/ml) of a drug in the bloodstream over time (t, in seconds). Assume we are interested in a concentration of c2 mg/ml C3te-0.4t A. Estimate the times at which the concentration is 2 mg/ml using a graphical method Be sure to show your plot(s). Hint: There are 2 real solutions B. Use MATLAB to apply the secant method (e.g....

  • Matlab only What is the function value at the estimated root after one iteration of the...

    Matlab only What is the function value at the estimated root after one iteration of the bisection method for the root finding equation: f(x) = x^3 -x -11 with xl = -4 and xu = 2.5? Select one: a.-0.7500 x O b.-3.2500 o co d. -10.6719 Which of the following statements is false? All open methods for root finding: Select one: a. Is sensitive to the shape of the function X b. Require two initial guesses to begin the algorithm...

  • This is Matlab Problem and I'll attach problem1 and its answer for reference. We were unable...

    This is Matlab Problem and I'll attach problem1 and its answer for reference. We were unable to transcribe this imageNewton's Method We have already seen the bisection method, which is an iterative root-finding method. The Newton Rhapson method (Newton's method) is another iterative root-finding method. The method is geometrically motivated and uses the derivative to find roots. It has the advantage that it is very fast (generally faster than bisection) and works on problems with double (repeated) roots, where the...

  • PLEASE explain and show work? 5. (30 points) Use the secant method to find a root...

    PLEASE explain and show work? 5. (30 points) Use the secant method to find a root of the following equation with two initial guesses xo 2.x1 1.8. Please show the first two iterations only. f(x) = 1-x + sin(x)

  • Not in C++, only C code please In class, we have studied the bisection method for...

    Not in C++, only C code please In class, we have studied the bisection method for finding a root of an equation. Another method for finding a root, Newton's method, usually converges to a solution even faster than the bisection method, if it converges at all. Newton's method starts with an initial guess for a root, xo, and then generates successive approximate roots X1, X2, .... Xj, Xj+1, .... using the iterative formula: f(x;) X;+1 = x; - f'(x;) Where...

  • MATLAB QUESTION please include function codes inputed Problem 3 Determine the root (highest positive) of: F(x)=...

    MATLAB QUESTION please include function codes inputed Problem 3 Determine the root (highest positive) of: F(x)= 0.95x.^3-5.9x.^2+10.9x-6; Note: Remember to compute the error Epsilon-a after each iteration. Use epsilon_$=0.01%. Part A Perform (hand calculation) 3 iterations of Newton's Raphson method to solve the equation. Use an initial guess of x0=3.5. Part B Write your own Matlab function to validate your results. Part C Compare the results of question 1 to the results of question 2, what is your conclusion ?

  • PLEASE USE MATLAB! Thank you in advance! Problem 4: Consider the following system differential equations for...

    PLEASE USE MATLAB! Thank you in advance! Problem 4: Consider the following system differential equations for a plug flow reactor ar,=-2k,C,'; F,(0) = 2 dV dV dV where k 0.25, k2 0.05 and Cr-1. If you were to solve this system of differential equation using the Euler Method determine the values of F, FB, F for the first two iterations of the procedure. Use a sample period of 0

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT