Question

write your own cos function that guarantees precision to 8 decimal places. Do not use built...

write your own cos function that guarantees precision to 8 decimal places. Do not use built in Matlab functions cos, factorial, or power (^).

0 0
Add a comment Improve this question Transcribed image text
Answer #1

// Function for calculation

void cal_cos(float n)

{

float accuracy=0.0000001, x1, denominator, cos x, cos val;

// Converting degree to radian

n=n*(3.142/180.0);

x1=1;

//maps the sum along the series

cos x=x1;

//holds the actual value

cos val=cos(n);

int i=1;

do

{

denominator= 2 * i * i (2 * i - 1);

x1= -x1 * n* n/ denominator;

cos x= cos x + x1;

i= i + 1;

}while(accuracy<=fabs(cos val - cos x));

cout<<cos x;

}

Add a comment
Know the answer?
Add Answer to:
write your own cos function that guarantees precision to 8 decimal places. Do not use built...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT