- Building on your work in the second homework assignment,
modify the program from the second problem and define a function called
*mycos*which gives the cosine of an angle by summing the Maclaurin series and giving six decimal places accuracy. Use this function to print a table which has angles in degrees from 1 to 360 in the first column, the value of your function*mycos*for these angles in the second column, and the machine values of*cos*for these angles in the third column. Check for the accuracy of your computation by comparing the values in the second and third column. -
This is an exercise on periodic functions and recursive subprogram calls. A function
*f(x)*defined for all real*x*is periodic of period*p>0*if*f(x+p)=f(x)*for all*x*. You will write a function*perfun*that is periodic of period*p*and tabulate the function over several periods. You can define*perfun*to be just about anything you want over a single period, and then it will recursively copy itself with the same waveform to other periods.A **periodic function.**The salmon part of the graph*0 ≤ x< p*is repeated over and over.Electrocardiograms from Prof. Keener's lecture, MAw. (The abnormal ones are not periodic.) Write a function subprogram

*perfun*that accepts two double precision arguments*x*and*p*and returns the value of the function at the point*x*. If the input value lies between*0≤ x < p*then you can return any interesting wave shape, such as a sawtooth or a cardiogram. (Make sure that your wave shape is not left-right symmetric and don't use trigonometric functions.) For values of*x*outside this range, have the function call itself, but at an argument translated by*±p*.The main program should ask the user to enter two numbers

*a*and*b*and then print out a table of values of*x*and*perfun(x,p)*for about 30 equally spaced points from*a*to*b*. (e,g., try*a=-2p*and*b=4p*.)