You are on page 1of 5

Edgar Figueroa

MAE 305 Sec 02

28 February 2017

%Q1 Finding root using fixed point method


clc; close all; clear;
% (a) using g1(x)
syms x
g1=inline('(x^(1/3)+1.4)/(0.3*x)');
ezplot(x)
hold on
ezplot(g1)
set(gca,'FontName','Courier New','FontSize',8)
xlabel('x')
ylabel('f(x)')
title('Location of Fixed Point of g1(x)')
grid on
legend('y=x','g1(x)')
[r n]=FixedPoint(g1,3)
[r n]=FixedPoint(g1,4)

r=

failure

n=

20

r=

failure

n=

20
% (b) using g2(x)
clc; close all; clear;
syms x
g2=inline('(0.3*x^2-1.4)^3');
ezplot(x)
hold on
ezplot (g2)
set(gca,'FontName','Courier New','FontSize',8)
xlabel('x')
ylabel('y')
title('Location of Fixed Point of g2(x)')
grid on
legend('y=x','g2(x)')
[r n]=FixedPoint(g2,-4)
[r n]=FixedPoint(g2,4)

r=

failure

n=
20

r=

failure

n=

20

%Q2 Equation with several roots


clc; clear all;close all;
x=linspace(-4,4);
f=inline('sin((pi*x)/2)-1/3');
g=f(x);
NRoots=NZerosMod(f,4,0)

NRoots =

-3.7837
-2.2163

0.2163

1.7837

%Q3 Find root using thomas method


clc; close all; clear;
A=[-6 3.5 0 0 0;3.5 -8 4.5 0 0;0 4.5 -10 5.5 0;0 0
5.5 -12 6.5;0 0 0 4 -4];
b=[-4;-2;-2.5;-3;-1];
x=ThomasMethod(A,b)

x=

5.2500

7.8571

9.4405

10.2814

10.5314
hand written and matlab solutions are the same

You might also like