Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Modify the user-defined function sine_taylorN (page 12 of (his pack of notes) by

ID: 3781677 • Letter: M

Question

Modify the user-defined function sine_taylorN (page 12 of (his pack of notes) by using the absolute relative approximate error instead of the absolute relative error. a) Write the pseudo-codes used to develop this user-defined function. (Simply copy from the notes with a minor modification.) b) Evaluate for x = '1 and maxtol = le-3. Plot the relative error and the relative approximate error versus the number of terms used in the series (this can be viewed as the number of iterations in the while loop), i.e., make two plots. Initializations and Definitions y = 0; % initial value of the sine series summation er - 1; % initial relative approximate error set at 1 or 100% k = 0; % initial value for the counter err = zeros(1, 100); % pre-allocate the vector err % set default value for Maxtor if it is not specified if margin = maxtol err(k) = abs ((y - yold/y); % relative approximate error at each iteration er - err (k); end A set of sample codes for plotting is provided as follows. >> [y, N, err; = sine_taylorN_re12(1, le-3); >> figure >> plot ([1:N], err, 'ko', 'markersize', 6, ' markerfacecolor', 'r') >> xlabel ('iteration number') >> ylabel ('relative approximate error (%) ', grid

Explanation / Answer

1.

initialise y to zero

initialise er to 1

initialise k to 1

initialse err vector to zeros(1,100)

if margin is less then 2

then set maxtol to lo minus 3;

endif;

while er is greater then equal to maxtol

push abs((y-yold)/y) value to err vector

set er to previously pushed value in vector err

increment k value by one

endwhile

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote