0% found this document useful (0 votes)
19 views3 pages

Lab1 Task2

This document discusses using a Taylor series approximation to estimate the value of sin(π/2 + π/10). It first finds the derivatives of sin(x) and evaluates them at x=0.5 to determine the coefficients of the Taylor series. It then uses the first three terms of this series to calculate an approximate value for sin(π/2 + π/10). This is compared to the exact value and errors are computed. The relative error between the approximate and exact values is found to be 0.00014015%.

Uploaded by

document.dhruv
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views3 pages

Lab1 Task2

This document discusses using a Taylor series approximation to estimate the value of sin(π/2 + π/10). It first finds the derivatives of sin(x) and evaluates them at x=0.5 to determine the coefficients of the Taylor series. It then uses the first three terms of this series to calculate an approximate value for sin(π/2 + π/10). This is compared to the exact value and errors are computed. The relative error between the approximate and exact values is found to be 0.00014015%.

Uploaded by

document.dhruv
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Task:2) [Taylor series approximation ]

function

Here is taylor series expanstion :

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:

Now, let's find an approximate value for

y=(pi/2)+(pi/10)

y = 1.8850

% Taylor series approximation for sin(pi*x) centered at a=0.5


a = 0.5;
x = 3/5;

%approx value of (pi/2) + (pi/10) is 1.8850

1
approximation = 1 - ((pi^2)/2)*(x-a)^2 + ((pi^4)/24)*(x-a)^4

approximation = 0.9511

% Exact value for sin(pi/2 + pi/10)


exact_value = sin((pi/2) + (pi/10));

% Plotting the functions over the interval [0, 1.9]


interval = linspace(0, 1.9, 10000);
exact_values = sin(pi*interval);
approx_values = sin(pi/2) - ((pi^2)/2)*sin(pi/2)*(interval-a).^2 + ((pi^4)/
24)*sin(pi/2)*(interval-a).^4

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;

disp(['Exact Value: ', num2str(exact_value)]);

Exact Value: 0.95106

disp(['Approximate Value: ', num2str(approximation)]);

Approximate Value: 0.95106

disp(['Error: ', num2str(error)]);

Error: 1.3329e-06

disp(['Relative Error (%): ', num2str(relative_error)]);

Relative Error (%): 0.00014015

So, here we get Relative error = 0.00014015 %

You might also like