Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

MANE 3351- Manufacturing Engineering Analysis Programming Assignment 2 1. Write

ID: 3167671 • Letter: M

Question

MANE 3351- Manufacturing Engineering Analysis Programming Assignment 2 1. Write a program that calculates sin( 3x) numerically using Taylor series. You need to use two functions 1) Calculate and return the result with n (allow user enter the value of n) significant figures 2) Calculate and return the result with truncation error less then a value entered by user. 2.Problems:Chapter4,.4-1,4-4 Deliverables for each program .Printout of program .Printout of output Program file Compare results from two functions in program 1

Explanation / Answer

%%% Matlab code

clc;

clear all;

close all;

n=input(' Enter the number of significant digit u want in answer :');
x=input(' Enter the angle in radian : ');
err=10^(-n);
f_act=sin(3*x);
sum=0;
for k=1:100
sum=sum+(-1)^(k+1)*(3*x)^(2*k-1)/factorial(2*k-1);
if ( abs ( sum-f_act) < err )
break;
end
end
fprintf(' Value of sin(3* %f ) = %f ',x,sum);

OUTPUT:

Enter the number of significant digit u want in answer :6
Enter the angle in radian : pi/9
Value of sin(3* 0.349066 ) = 0.866025