parent
651915608c
commit
236eabd427
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,91 +0,0 @@
|
|||||||
package sin;
|
|
||||||
|
|
||||||
public class Sin {
|
|
||||||
|
|
||||||
public static double number;
|
|
||||||
public static double PI = 3.14159265358979323846;
|
|
||||||
|
|
||||||
|
|
||||||
public Sin() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static double sin(double num) {
|
|
||||||
|
|
||||||
double tmp = Math.toRadians(num);
|
|
||||||
number=Math.sin(tmp);
|
|
||||||
|
|
||||||
return number;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static double cos(double num) {
|
|
||||||
|
|
||||||
double tmp = Math.toRadians(num);
|
|
||||||
|
|
||||||
return Math.cos(tmp);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static double mysin(double x)
|
|
||||||
{
|
|
||||||
while(x>2*PI) x -= 2*PI;
|
|
||||||
while(x<0) x += 2*PI;
|
|
||||||
|
|
||||||
double index, result=0;
|
|
||||||
int i=1;
|
|
||||||
do{
|
|
||||||
index = mypow(x,i) / factorial(i);
|
|
||||||
result += mypow(-1,i/2) * index;
|
|
||||||
i += 2;
|
|
||||||
}
|
|
||||||
while(index>1e-6);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static double factorial(double i) {
|
|
||||||
|
|
||||||
if(i==0)
|
|
||||||
return 1;
|
|
||||||
else
|
|
||||||
return i*factorial(i-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static double mypow(double x,int i) {
|
|
||||||
|
|
||||||
if(i>0)
|
|
||||||
return x*mypow(x, i-1);
|
|
||||||
else if(i<0)
|
|
||||||
return 1/x*mypow(x, i+1);
|
|
||||||
else
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static double mycos(double x) {
|
|
||||||
while(x>2*PI) x -= 2*PI;
|
|
||||||
while(x<0) x += 2*PI;
|
|
||||||
|
|
||||||
double index, result=0;
|
|
||||||
int i=0;
|
|
||||||
|
|
||||||
do{
|
|
||||||
index = mypow(x,i) / factorial(i);
|
|
||||||
result += mypow(-1,i/2) * index;
|
|
||||||
i += 2;
|
|
||||||
}
|
|
||||||
while(index>1e-6);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
public static double toRadians(double angdeg) {
|
|
||||||
return angdeg / 180.0 * PI;
|
|
||||||
}
|
|
||||||
public static void main(String[] args) {
|
|
||||||
|
|
||||||
System.out.println(mysin(toRadians(30)));
|
|
||||||
System.out.println(mycos(30));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
test
|
|
@ -1,4 +0,0 @@
|
|||||||
print("this is gitee test")
|
|
||||||
import numpy as np
|
|
||||||
np.eye(5)
|
|
||||||
|
|
Loading…
Reference in new issue