Skip to content

Commit 25a6301

Browse files
committed
Another WiFi password
1 parent bbfd9fd commit 25a6301

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

src/symjava/examples/WiFiPassword.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package symjava.examples;
22

3-
import static symjava.math.SymMath.pow;
4-
import static symjava.math.SymMath.sin;
3+
import static symjava.math.SymMath.*;
54
import static symjava.symbolic.Symbol.x;
65
import symjava.bytecode.BytecodeFunc;
76
import symjava.domains.Domain;
@@ -14,15 +13,32 @@ public class WiFiPassword {
1413
public static void password() {
1514
//Define the interval
1615
Domain I = Interval.apply(-5, 5).setStepSize(0.01);
16+
1717
//Define the integral
1818
Expr f = Integrate.apply(
1919
(pow(x,3)*pow(sin(x),2))/(pow(x,4)+2*pow(x,2)+1), I);
2020
System.out.println(f);
21+
2122
//Compile f to perform numerical integration
2223
BytecodeFunc cf = JIT.compile(f);
2324
System.out.println(String.format("%.3f", cf.apply()));
2425
}
26+
27+
public static void password2() {
28+
// Define the interal
29+
Domain I = Interval.apply(-2, 2).setStepSize(0.00001);
30+
31+
// Define the integral
32+
Expr i = Integrate.apply((pow(x, 3) * cos(x / 2.0) + 0.5)
33+
* sqrt(4 - x * x), I);
34+
System.out.println(i);
35+
36+
// Compile the integral to perform numerical integration
37+
BytecodeFunc f = JIT.compile(i);
38+
System.out.println(f.apply());
39+
}
2540
public static void main(String[] args) {
26-
password();
41+
//password();
42+
password2();
2743
}
2844
}

0 commit comments

Comments
 (0)