Lab1 Task2
Lab1 Task2
function
For and , we need to find the derivatives of with respect to x and evaluate them at
The derivatives are as follows:
Now, evaluate these derivatives at to find the coefficients for the Taylor series expansion:
Now, we can substitute these derivatives into the Taylor series formula. The first three terms are:
y=(pi/2)+(pi/10)
y = 1.8850
1
approximation = 1 - ((pi^2)/2)*(x-a)^2 + ((pi^4)/24)*(x-a)^4
approximation = 0.9511
approx_values = 1×10000
0.0200 0.0205 0.0211 0.0216 0.0222 0.0227 0.0233 0.0238
figure;
plot(interval, exact_values, 'b', interval, approx_values, 'r--');
legend('Exact', 'Approximation');
xlabel('x');
ylabel('y');
title('Comparison of Exact and Approximate Values');
xlim([0.00 1.90])
ylim([-1 7])
2
% Computing errors and relative errors
error = abs(exact_value - approximation);
relative_error = abs((exact_value - approximation) / exact_value) * 100;
Error: 1.3329e-06