1. Write an algorithm that computes f(r) sinTs(z) 2 in the range r e l 10 10, wh
ID: 667914 • Letter: 1
Question
1. Write an algorithm that computes f(r) sinTs(z) 2 in the range r e l 10 10, where (z) is a sine function that you must program from scratch using Taylor series expansions. To receive points on this assignment, your algorithm must statisfy all of the following criteria: It must be efficient; you are only allowed to keep at most 16 terms in the sum (n E jo, 15 zero terms included It cannot make use of any transcendental functions built-in to your programming language; your algorithm may only multiply, divide, add, and subtract double precision numbers and 32-bit integers. If you need to use an ational number, e.g., V2, you may not use the sqrt() function built-in to your programming language; instead use the decimal approximation 1.41421356237309504880 It may not use any built-in factorial function: this must be coded by you as well. It must be generic, it must be able to automatically compute the coefficient fin)(zo)/n! n for any and at most 8 values of zo The pattern i n for zo) must be found by hand WORK) without use of any calculator you must choose values of za so that this is possible using trigonometric identities. To this end, you may find the following trigonometric identities useful sin t 2x) sin(r) sin (r m/2) cos(z) cos(z) cos /2) sin (r) (r) sin (r) sin (0) (T/2) (m) sin(3x/2) 1/v2 sin(x/4) cos(x/4) cos(0) cos(T/2) (m) cos(3m/2) z) to at least 14 significant built-in transcendent The sinTs0 function must agree with the digits at all points in the range r E 10 10 n your algorithm follows when computing coeffcients (a) (20 pts): By hand, write out the pattern (0,*/4, T,3 m/2). en convert the (n) the Taylor series expansion of sin(z) about pattern for into computer code. After this code, rint all the nonzero coefficients the coefficients for each of values of aro, for up and including printed and label which coefficients correspond to which zo. coefficients must be in 15 ignificant digits. You may use either computing scientific notation (e.g 1.00000000000015eo) or standard scientific notation (e.g., 1.00000000000015 x 100 (b) (so pts): Plot f(r) versus z for r e I-10: 10). Then plot the logarithm of the relative error f(z) (sin(a) 2) sin (a) 2 for r E 10 10), where sin(z) is the built-in double-precision s function for your programming language. Entitle the seoond plot "Relative Error in f(z) Computation Your plots must contain 10 to r 10, and each neighboring point must be connected 2,001 points, evenly spaced from z by a line. Le you are to print the function f(rk) at all points ze 10 0,01k, where k 0, 1, 2,..., 1999, 2000. Your algorithm successfully completes this task if all points in the relative error at all points ze) plot fall below -14 (ie, the relative error falls below 10Explanation / Answer
Simple idea to write an algorithm for this
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.