1/20java.lang.FooEclipseJavadocjava.lang.MathJavadoc——20Java™5java.lang.Mathjava.lang.StrictMath10Java610log10cosh20.2JavadoubleJava2,000,000,001intfloat2.0E9—doubledoublefloatJava1/57/500.20.141/30.3333333……1052221/21/41/81/16math+*11.publicclassSineTaylor{publicstaticvoidmain(String[]args){for(doubleangle=0;angle=4*Math.PI;angle+=Math.PI/8){System.out.println(degrees(angle)+\t+taylorSeriesSine(angle)+\t+Math.sin(angle));}}publicstaticdoubledegrees(doubleradians){return180*radians/Math.PI;}2/20publicstaticdoubletaylorSeriesSine(doubleradians){doublesine=0;intsign=1;for(inti=1;i40;i+=2){sine+=Math.pow(radians,i)*sign/factorial(i);sign*=-1;}returnsine;}privatestaticdoublefactorial(inti){doubleresult=1;for(intj=2;j=i;j++){result*=j;}returnresult;}}0.00.00.022.50.38268343236508970.382683432365089845.00.70710678118654750.707106781186547567.50.9238795325112870.923879532511286790.01.00000000000000021.0630.0000000000003-1.0000001371557132-1.0652.5000000000005-0.9238801080153761-0.9238795325112841675.0000000000005-0.7071090807463408-0.7071067811865422697.5000000000006-0.3826922100671368-0.38268343236508243607204pijava.lang.Math10X863/20X86VMHotSpotc2=a2+b2R2Java5Math.hypotpublicstaticdoublehypot(doublex,doubley){returnx*x+y*y;}2Cxy2.Math.hypot/**====================================================*Copyright(C)1993bySunMicrosystems,Inc.Allrightsreserved.**DevelopedatSunSoft,aSunMicrosystems,Inc.business.*Permissiontouse,copy,modify,anddistributethis*softwareisfreelygranted,providedthatthisnotice*ispreserved.*====================================================*/#includefdlibm.h#ifdef__STDC__double__ieee754_hypot(doublex,doubley)#elsedouble__ieee754_hypot(x,y)doublex,y;#endif4/20{doublea=x,b=y,t1,t2,y1,y2,w;intj,k,ha,hb;ha=__HI(x)&0x7fffffff;/*highwordofx*/hb=__HI(y)&0x7fffffff;/*highwordofy*/if(hbha){a=y;b=x;j=ha;ha=hb;hb=j;}else{a=x;b=y;}__HI(a)=ha;/*a-|a|*/__HI(b)=hb;/*b-|b|*/if((ha-hb)0x3c00000){returna+b;}/*x/y2**60*/k=0;if(ha0x5f300000){/*a2**500*/if(ha=0x7ff00000){/*InforNaN*/w=a+b;/*forsNaN*/if(((ha&0xfffff)|__LO(a))==0)w=a;if(((hb^0x7ff00000)|__LO(b))==0)w=b;returnw;}/*scaleaandbby2**-600*/ha-=0x25800000;hb-=0x25800000;k+=600;__HI(a)=ha;__HI(b)=hb;}if(hb0x20b00000){/*b2**-500*/if(hb=0x000fffff){/*subnormalbor0*/if((hb|(__LO(b)))==0)returna;t1=0;__HI(t1)=0x7fd00000;/*t1=2^1022*/b*=t1;a*=t1;k-=1022;}else{/*scaleaandbby2^600*/ha+=0x25800000;/*a*=2^600*/hb+=0x25800000;/*b*=2^600*/k-=600;__HI(a)=ha;__HI(b)=hb;}}/*mediumsizeaandb*/w=a-b;if(wb){t1=0;__HI(t1)=ha;5/20t2=a-t1;w=sqrt(t1*t1-(b*(-b)-t2*(a+t1)));}else{a=a+a;y1=0;__HI(y1)=hb;y2=b-y1;t1=0;__HI(t1)=ha+0x00100000;t2=a-t1;w=sqrt(t1*y1-(w*(-w)-(t1*y2+t2*b)));}if(k!=0){t1=1.0;__HI(t1)+=(k20);returnt1*w;}elsereturnw;}JVMSunJDKJDKSunJavaSun15fdlibmIEE75410Math.pow()10e2Java1.0MathxexJavaCFortranBasiclog()log10lnelg2Java5log10()10e31100210e6/203.1100publicclassLogarithms{publicstaticvoidmain(String[]args){for(inti=1;i=100;i++){System.out.println(i+\t+Math.log10(i)+\t+Math.log(i)+\t+lg(i));}}publicstaticdoublelg(doublex){returnMath.log(x)/Math.log(2.0);}}1010.00.00.020.30102999566398120.69314718055994531.030.477121254719662441.09861228866810961.58496250072115640.60205999132796241.38629436111989062.050.69897000433601891.60943791243410032.32192809488736260.77815125038364361.7917594692280552.58496250072115670.84509804001425681.94591014905531322.80735492205760480.90308998699194352.07944154167983573.090.95424250943932492.19722457733621963.1699250014423126101.02.3025850929940463.3219280948873626Math.log10()0NaN—Java5Math.cbrt()4-557/204.-55publicclassCubeRoots{publicstaticvoidmain(String[]args){for(inti=-5;i=5;i++){System.out.println(Math.cbrt(i));}}}-1.709975946676697-1.5874010519681996-1.4422495703074083-1.2599210498948732-1.00.01.01.25992104989487321.44224957030740831.58740105196819961.709975946676697NaNNaNtx=rcos(t)y=rsin(t)rx=rcosh(t)8/20y=rsinh(t)rsin(x)(eix-e-ix)/2cos(x)(eix+e-ix)/2sinh(x)=(ex-e-x)/2cosh(x)=(ex+e-x)/2Java5Math.cosh()Math.sinh()Math.tanh()—cosh(z)5Math.cosh5.Math.cosh()importjava.awt.*;publicclassCatenaryextendsFrame{privatestaticfinalintWIDTH=200;privatestaticfinalintHEIGHT=200;privatestaticfinaldoubleMIN_X=-3.0;privatestaticfinaldoubleMAX_X=3.0;privatestaticfinaldoubleMAX_Y=8.0;privatePolygoncatenary=newPolygon();publicCatenary(Stringtitle){super(title);setSize(WIDTH,HEIGHT);for(doublex=MIN_X;x=MAX_X;x+=0.1){doubley=Math.cosh(x);intscaledX=(int)(x*WIDTH/(MAX_X-MIN_X)+WIDTH/2.0);intscaledY=(int)(y*HEIGHT/MAX_Y);//incomputergraphics,yextendsdownratherthanupasin//Caretesiancoordinates'sowehavetoflipscaledY=HEIGHT-scaledY;catenary.addPoint(scaledX,scaledY);}}publicstaticvoidmain(String[]args){9/20Framef=newCatenary(Catenary);f.setVisible(true);}publicvoidpaint(Graphicsg){g.drawPolygon(catenary);}}11.Math.signum1.0-1.000ComparablefloatdoubleNaN00NaN0000066.Math.signumpublicstaticdoublesignum(doublex){if(x==0.0)return0;10/20elseif(x0.0)return-1.0;elsereturn1.0;}000IEEE754NaN77.Math.signumpublicstaticdoublesignum(doubled){return(d==0