Ask your own question, for FREE!
Computer Science 23 Online
OpenStudy (anonymous):

I can't quite understand the wording of this question or how to go about it; the power series the sum of x^k/k! converges to e^x for all values of x. Write a function subprogram that uses this series to calculate values for e^x to five-decimal-place accuracy (ex using terms up to the first one that is less than 10^-5 in absolute value) and that uses a function subprogram to calculate and print a table of values for the function cosh(x)=e^x+e^-x/2 and also the corresponding values of the library function cosh for x =-1 to 1 in increments of 0.1

OpenStudy (anonymous):

I dont know how to write the subprogram to calculate e^x.. or how to do it for less than 10^-5 I don't understand what it means to print a table of values for the function... like what is given?

OpenStudy (anonymous):

see [ http://en.wikipedia.org/wiki/Taylor_series \] \[e^x = \lim_{n \rightarrow \infty} \sum_{k = 0}^{n} \frac{ x^k }{ k!}, \forall x \in \mathbb{R}\] so that works for negative values of x too You can build a function using recursion just to calculate the \[ \frac{e^k }{ k! }\] terms. Say the function Term(k) Then the function to calculate \[e^x\] sums the Terms k until the abs(sum=approx e^x) < epsilon epsilon is the required precision: in your case 0.00001 Call this function approxExp(x) (for example) ================ Ones you've got the e^x function you can calculate values for \[\cosh(x) = \frac{ e^{x} + e^{-x} }{ 2 }\] You could thus create a function for the approximation of cosh(x) Call it for example approxCosh(x) You need to calculate cosh(x) for the values -1, -0.9, 0.8, ..., 0, 0.1, 0.2, ..., 1 there also exists a library function cosh(x) You table, an output format you'd have to figure out, could look like this x | cosh(x) | approxCosh(x) _____________________________ -1 | ? | ? -0.9 | ? | ? etc. up to 1 | ? | ? round your floating point values to the appropriate amount of decimal places (5 or 6?) You can leave out all the stripes and use tabs or so, those stripes are just there to give you an idea

OpenStudy (anonymous):

I made a mistake not sums the Terms k until the abs(sum=approx e^x) < epsilon but sums the Terms k until the abs(sum=approx e^x - previous sum)< epsilon

OpenStudy (anonymous):

You have to break up the problems in the parts you solve and do the solving in subprograms (or functions) so I think you can do function approxExp(x) You can even make a subprogram for approxCosh(x) function approx_cosh(x) -> use approx_exp(x) in this one and function print_table(x, delta_x, y1, y2)

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!