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

Write a group of functions for the computation of themathematical oprns: (Use th

ID: 3617991 • Letter: W

Question

Write a group of functions for the computation of themathematical oprns:

(Use the series listed below.)

              sine                cosine                exp                 tan

Store the functions under thename "mylibrary.cpp" (eg, in the same folder as thecalling main function).

Then write a program that uses the above created library tocompute each of the named functions for data values to beinput:

#include<iostream.h>

#include"mylibrary.cpp"

.Compare with the corresponding results obtained from thebuilt-in library functions:

#include<math.h>

Series:

sin x = x - x³/3! + x5 /5! – x7/7! +….. x (in radians).Use angles 0 to 90 degrees.

cos x = 1- x²/2! + x4/4! –x6/6! +….   x (in radians).Useangles 0 to 90 degrees

x (in radians)=x(in degrees)*3.1416/180

ex = 1 + x + x²/2! + x³/3!+….             Use |x|1

tan-1x = x - x³/3 + x5/5 –x7/7 +…….. Use |x|1, obtain answer indegrees

Form an event controlled loop around a statement suchas    sum = sum + term

in each case and include all terms>0.0001 in absolute value.

Explanation / Answer


#include <iostream> #include <iomanip> using namespace std; double factorial(double); int mypow(int,int);
int main() { int x,c; double t,etotal=1.0,stotal=1.0,ctotal=1.0; cout<<"Enter exponent : "; cin>>x; cout<<" Enter number of Terms : "; cin>>t; int flag=0; for(int v=1;v<=t;v++) { if(flag%2==0) stotal+=(mypow(x,v)/factorial(v); else ctotal+=(mypow(x,v)/factorial(v); total=(total+(mypow(x,v))/factorial(v)); flag++; } cout<<"e^"<<x<<" of "<<t<<" terms : "<<setprecision(5)<<total<<endl; #include <iostream> #include <iomanip> using namespace std; double factorial(double); int mypow(int,int);
int main() { int x,c; double t,etotal=1.0,stotal=1.0,ctotal=1.0; cout<<"Enter exponent : "; cin>>x; cout<<" Enter number of Terms : "; cin>>t; int flag=0; for(int v=1;v<=t;v++) { if(flag%2==0) stotal+=(mypow(x,v)/factorial(v); else ctotal+=(mypow(x,v)/factorial(v); total=(total+(mypow(x,v))/factorial(v)); flag++; } cout<<"e^"<<x<<" of "<<t<<" terms : "<<setprecision(5)<<total<<endl;
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