quiz حل الأسئلة الجامعية manage_search الأرشيف

تم الحل ✓
categoryعلوم الحاسوب وتقنية المعلومات schoolبكالوريوس event_available2026-07-15

السؤال

Transcribed Image Text:

The Maclaurin series expansion for cos x is cos x=1 x² x4 + 21 4! 6! 8! Starting with the simplest version, cos x = 1, terms are added one at a time to estimate, e.g. cos (). After each new term is added, the true, &, and approximate percent relative || errors can be evaluated. The MATLAB function, cos(pi/4), may be used to determine the true value. (cos x)True= Write a MATLAB function, mycos, that estimates cos x as outlined above. The first line in the function is: function out1 mycos(ang,n) where, ang is the angle, e.g. pi/4, and n is the number of significant figures. Number of significant figures, n, is an optional input. If it is not provided by the user, set n = 5. Design the output of the function similar to the following format: Iteration 2 3 Outl let Test your function using the calls: mycos(pi/4) and mycos(pi/4,4) Consider the following Gauss-Legendre algorithm for computing: a) Set a = 1, b=t=and x = 1. b) Repeat the following commands until the difference between a and b is within some desired accuracy, E, (i.e. la-b|≤E,): упа a= a+b b=√by t=t-x(y-a)² x = 2x c) From the resulting values of a, b and t, an estimate of is: Start a-1 b- x=1 yes la-SE по yal a(a+b)/2 b sqrt (by); t-x*(y-a) "21 (a+b) plest 4t Write a script that implements the algorithm, which is also illustrated in the flowchart. Use the while structure, and E. = 1e-8. Piesta+by 2)(4) End

check_circle الجواب — حل مفصل خطوة بخطوة

hourglass_top