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

3.5 The sine function can be evaluated by the following infinite series: Create

ID: 3758691 • Letter: 3

Question

3.5 The sine function can be evaluated by the following infinite series: Create an M-file to implement this formula so that it computes and displays the values of sin x as each term in the series is added. In other words, compute and display in sequence the values for up to the order term of your choosing. For each of the pre ceding. compute and display the percent relative error as As a test case, employ the program to compute sin(0.9) for up to and including eight terms - that is. up to the term x^15/15!

Explanation / Answer

dc:clear ad;
x=0.9;
n=8;
sinx=xin(1);
sx=0.0;
dop("n sin(x) apporx error(%)")
fori=1:n
sx=sx+(-1)^(-1)^x^(2^-1)factorial(2^)-1);
err*abs(sinx-sx)*100sinx;
fprint(%d %8 4f %8*n)(sinx,sx,err);
end

or .


#include <iostream>
#include <math.h>

using namespace std;

#define PI 3.14

int main()
{
float angle,radian,sine,n,x,factorial;


cout<<"Enter angle in degrees (0 to quit): ";
cin>>angle;

while (angle!=0){
radian=angle*(PI/180);
sine=0;
n=1;
while (n<=15){
sine=(x-(pow(x,n))/(factorial(n)));
n++;
}
cout<<"Sine equals: "<<sine<<endl;
return 0;
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote