-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblem1.m
More file actions
22 lines (19 loc) · 799 Bytes
/
problem1.m
File metadata and controls
22 lines (19 loc) · 799 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
% Interpolating given data using the second form of the Barycentric
% polynomial.
tau = [1.725, 1.035, 0.975, 0.405, 0.015, -0.015, -0.405, -0.975, -1.035, -1.725];
x = linspace(-1.75,1.75,1001);
rho = [73.439, -86.510, -90.472, -138.670, -154.987, -154.987, -138.670, -90.472, -86.510, 73.439];
p = baryeval2(tau, rho, x);
plot(x,p,tau,rho,'o');
title('Barycentric second form Interpolation');
xlabel('x boundary');
ylabel('y boundary');
f = @(x) baryeval2(tau, rho, x);
% Fzero built in matlab root finding method.
rootfz = fzero(f, 1)
% Finding a root with bisection method
root2 = bisectionMethod(f, -2, 2, 1e-7, 20);
rootBi = root2(end)
% Using tau nodes as bounds initial bounds for bisection root finding
% method.
rootTk = bisectionMethod(f, -0.975, 0.975, 1e-1, 20)