Write a program to test the functions by computing f 5


Assignment:  C++ - User Functions

Given:   tanh(x ) = 1 - 2 e-2x + 2 e-4x - 2 e-6x + 2 e-8x - 2 e-10x   + ....
cos(x) = 1 - x2 / (2!) + x4 /(4!) - x6  /(6!) + x8 /(8!) +  ....
where   0 ≤  x  < 2 π

Write two functions:

tanh(ax) where a and x are passed to the function and
cos(ax)  where a and x are passed to the function.

The functions must give answers that are accurate at least to six significant digits.

Write a program to test the functions by computing F = 5 tanh(ax) + 4 cos(ax) where 0 ≤ x < 2 π with the values of a and x entered by the user.

Check the answer with a calculator.

Check the functions with these data:

a

X

F

0

0

4

2.78

0

4

0

2.78

4

1

2.78

1.220321454

1.5

2.6

2.092175112

3.78

1

1.782610497

For your reference, read ex, sin(x) and cos(x) functions at www.csun.edu/~glaw and see how these functions are written.

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Write a program to test the functions by computing f 5
Reference No:- TGS01395200

Now Priced at $30 (50% Discount)

Recommended (98%)

Rated (4.3/5)