1.A method called sine,which takes asits only parameter avalue oftype double,and returns a valueof type doubleThe parameter represents anangle expressed inradians,andthe value returned bythe method representsthe trigonometric sine ofthis angleFor example,suppose thefollowingmethod
call isexecuted:double sin=MathAssignment.sine(1.047197551)
After the execution ofthe above method call,thevalue stored invariable sin willbe(approximately)0.866025404,as the sine of 1.047197551radians is approximately 0.866025404Thesine ofan angle x,denoted sinx,canbe calculated usingthe following algorithm:If x<-π,repeatedly add2π toxuntil-π≤x≤π.Conversely,ifx>π,repeatedlysubtract2π
fromxuntil-π≤x≤πYou MUST use 3.141592653589793 as a value for π
Calculate sinx using the following formula:where t0=xTo calculate the other terms in the sum,we usethe following formula:where ti isan arbitrary term,and ti+1 isthe next termFor example:and so onThelast term in this sum,tn,will bethe firstterm whose absolute valueis lessthan10-10
public class MathAssignment {
public static double sine(double rad) {
return Math.sin(rad);
}
}
Comments
Leave a comment