Question

In: Computer Science

Implement the steffenson method in matlab. The code must be in MATLAB DOnt answer if you...

Implement the steffenson method in matlab. The code must be in MATLAB

DOnt answer if you cannot give correct

MATLAB

Solutions

Expert Solution

Here is the source for an implementation of Steffensen's Method in MATLAB.
function Steffensen(f,p0,tol)
% This function takes as inputs: a fixed point iteration function, f, 
% and initial guess to the fixed point, p0, and a tolerance, tol.
% The fixed point iteration function is assumed to be input as an
% inline function. 
% This function will calculate and return the fixed point, p, 
% that makes the expression f(x) = p true to within the desired 
% tolerance, tol.

format compact % This shortens the output.
format long    % This prints more decimal places.

for i=1:1000   % get ready to do a large, but finite, number of iterations.
               % This is so that if the method fails to converge, we won't
               % be stuck in an infinite loop.
    p1=f(p0);  % calculate the next two guesses for the fixed point.
    p2=f(p1);
    p=p0-(p1-p0)^2/(p2-2*p1+p0) % use Aitken's delta squared method to
                                % find a better approximation to p0.
    if abs(p-p0)<tol  % test to see if we are within tolerance.
        break         % if we are, stop the iterations, we have our answer.
    end
    p0=p;              % update p0 for the next iteration.
end
if abs(p-p0)>tol       % If we fail to meet the tolerance, we output a
                       % message of failure.
    'failed to converge in 1000 iterations.'
end

Related Solutions

You must implement the delete method. Below are the requirements: • The delete method takes a...
You must implement the delete method. Below are the requirements: • The delete method takes a Price as an argument and removes the Price from the queue if it is present. (If the Price was not present, the method does nothing). • The method returns true if the Price was deleted and false otherwise. • The method must run in logarithmic time. This is a key requirement. Solutions that are linear or worse will not receive credit. (You may assume...
Use matlab code for bisection method and regula falsi. Thank you!
Use matlab code for bisection method and regula falsi. Thank you!
matlab code that performs overlap add method.
matlab code that performs overlap add method.
USING MATLAB Part 2: Insert coins For this part, you are going implement the code that...
USING MATLAB Part 2: Insert coins For this part, you are going implement the code that asks the user to enter coins until they have entered enough for the NAU power juice. Open the insert_coins.m file. Initialize total to 0. We do this because initially, no coins have been entered. Using a loop, ask the user to enter a coin until the total matches or exceeds 115 cents. The input should be a char or string, so make sure that...
The following code must be written in Matlab I want to print the following in Matlab...
The following code must be written in Matlab I want to print the following in Matlab (x1,x2, x3) = (0.33333, 0.33333, 0.33333)  . The whole thing should be on the same line. I need to use fprintf and write out the coordinates with 5 decimal places of variable x = (0.33333, 0.33333, 0.33333) Thanks!
The following code must be written using matlab How to loop through a vector in matlab...
The following code must be written using matlab How to loop through a vector in matlab and assigning a value to every 4th entry. The vector could be of any length. Thanks
Re-do Problem 1, but now implement the following method: i must use this code :- public...
Re-do Problem 1, but now implement the following method: i must use this code :- public static BagInterface intersection (BagInterface bagA, BagInterface bagB) and here how my java program must work This method must return a new bag which is the intersection of the two bags: bagA and bagB. An element appears in the intersection of two bags the minimum of the number of times it appears in either. For example, {1,1,2} ∩{1,1,2,2,3}= {1,1,2}. Do not forget to state the...
The following code must be written using matlab and must be using a for-loop. NOTE! Write...
The following code must be written using matlab and must be using a for-loop. NOTE! Write a computer program that assigns random integers for each entry and generates a row vector. Different random integers should be drawn from different intervals for position 1, position 2, position3 and position 4 of the array. After these first 4 positions are drawn. The whole thing should start over where position5 drawn from same interval as positions 1, position6 drawn from same interval as...
The following code must be written using matlab and must be using a for-loop. NOTE! Write...
The following code must be written using matlab and must be using a for-loop. NOTE! Write a computer program that assigns random integers for each entry and generates a row vector. Different random integers should be drawn from different intervals in chunks of 4 , that is chunk1-chunk2-chunk3-chunk4 The parameters for specifying the lintervals by which the random numbers should be drawn should be able to change and be hardcoded in the script, however, be hardcoded in the script.
Give me a working code in MATLAB for Crout Decomposition. The code must work totally fine...
Give me a working code in MATLAB for Crout Decomposition. The code must work totally fine and must break into 2 matrix L and U It must be in MATLAB The code used must use continue statement. If no continue statement is there in code it will be downvoted. Answer only if you know or else i will dislike badly
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT