.

Wednesday, August 14, 2013

Secant Method

Code: function [ ] = secMethod( ) % design Name: SecantMethod.m %System: Windows 7 32-bit, MATLAB R2010a %Date: 2011 08 15 %Bugs: none %Description: graphically shows the Secant Method in finding the root of y % = x- x^(1/3) - 2 %equation: y = x - x^(1/3) - 2 xtheo = -5:0.01:5; %creates an interval of x put in for creating the graph of the equation ytheo = xtheo - xtheo.^(1/3) - 2; %calculates the y note judge like to for each(prenominal) one x in xtheo plot(xtheo,ytheo) %plots the graph of the equation axis([1.5 4.5 -1.5 1]) hold on yzero = zeros(length(xtheo)); %creates a vector of 0s for creating the x-axis plot(xtheo,yzero) %plots the x-axis a = 2; %1st sign guess b = 4; %2nd initial guess fa = a - a^(1/3) - 2; %calculates f(a) fb = b - b^(1/3) - 2; %calculates f(b) c = b - fb*((b - a)/(fb - fa)); %calculates close guess display panel = [a b c fb]; %tabulates data xrange = linspace(a, b); %creates an interval of x values for creating the pull verboten connecting (a,f(a)) and (b,f(b)) yrange = ((fb - fa)/(b - a)).
Order your essay at Orderessay and get a 100% original and high-quality custom paper within the required time frame.
*(xrange-a) + fa; %calculates the y value corresponding to each x in xrange plot(xrange, yrange, g); %plots the cable system connecting (a,f(a)) and (b,f(b)) %this loop topology is in charge of display the Secant Method graphically cnt = 2; while abs(c-b) > 10^(-10) fc = c - c^(1/3) - 2; %calculates f(c) yvert = linspace(0,fc); %creates an interval of y values for creating the vertical store x = f(c) xvert = ones(1,length(yvert)); %creates a vector of 1s xvert = xvert.*c; %multiplies xvert with the value of c for creating the vertical make x = f(c) plot(xvert,yvert,r) %plots the vertical line x = f(c) a = b; %the red-hot value of a is the value of b b = c; %the stark naked value of b is the value of c fa = a - a^(1/3) - 2; %calculates saucily f(a) fb = b - b^(1/3) - 2; %calculates new f(b) c = b - fb*((b - a)/(fb - fa)); %calculates next guess...If you want to overprotect a full essay, guild it on our website: Orderessay

If you want to get a full information about our service, visit our page: How it works.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.