Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
30
Task/Eulers-identity/Java/eulers-identity.java
Normal file
30
Task/Eulers-identity/Java/eulers-identity.java
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
public class EulerIdentity {
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("e ^ (i*Pi) + 1 = " + (new Complex(0, Math.PI).exp()).add(new Complex(1, 0)));
|
||||
}
|
||||
|
||||
public static class Complex {
|
||||
|
||||
private double x, y;
|
||||
|
||||
public Complex(double re, double im) {
|
||||
x = re;
|
||||
y = im;
|
||||
}
|
||||
|
||||
public Complex exp() {
|
||||
double exp = Math.exp(x);
|
||||
return new Complex(exp * Math.cos(y), exp * Math.sin(y));
|
||||
}
|
||||
|
||||
public Complex add(Complex a) {
|
||||
return new Complex(x + a.x, y + a.y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return x + " + " + y + "i";
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue