-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParserTests.java
More file actions
64 lines (60 loc) · 2.4 KB
/
ParserTests.java
File metadata and controls
64 lines (60 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
public class ParserTests {
public static void main(String[] args){
//System.out.println(Parser.parse("5 + 5 * 5 / 5 - 5") + " ---5");
//System.out.println(Parser.parse("5 + 5 - 5") + " ---5");
//System.out.println(Parser.parse("5 * 5 / 5") + " ---5");
//System.out.println(Parser.parse("5 ^ ( 2 * 3 ) + 8") + "---15633");
//System.out.println(Parser.parse("2^3 - 3 + 1 + 3 * ((4+4*4)/2) / 5 + -5") + "---7");
//
//String expression = "5 + x";
//System.out.println(replaceVariables(22, expression)+"--- 5 + 22") ;
//
//Function f = new Function("2^x - x + 1 + x * ((4+4*4)/2) / 5 + -5");
//System.out.println(f.getValue(6.1645));
//
//Function f = new Function("s(x)"); //sin of
//System.out.println(f.getValue(5));
// f = new Function("c(x) + 5"); //cos of
//System.out.println(f.getValue(5));
// f = new Function("t(x) + 5"); //tan of
//System.out.println(f.getValue(5));
// f = new Function("S(x) + 5"); //arcsin of
//System.out.println(f.getValue(.5));
// f = new Function("C(x) + 5"); //arccos of
//System.out.println(f.getValue(.5));
//f = new Function("T(x) + 5"); //arctan of
//System.out.println(f.getValue(.5));
//Function f = new Function("s(x)");
//System.out.println(f.getValue(Math.PI));
//System.out.println(f.getValue(Math.PI/2));
//System.out.println(f.getValue(Math.PI/4));
//
//Function f = new Function("l(x)");
//System.out.println(f.getValue(10));
//f = new Function("L(x)");
//System.out.println(f.getValue(10));
//f = new Function("n(x)");
//System.out.println(f.getValue(10000));
//for(int i = 1; i<1000000; i++){
// System.out.println(f.getValue(i));
//}
Function f = new Function("s(s(x))");
System.out.println(f.getValue(0));
Function g = new Function("t(t(x))");
System.out.println(g.getValue(0));
//System.out.println(f.calculateIntersection(g, 10, 20));
System.out.println(f.calculateIntersection(g, -1, 1));
//System.out.println(Parser.parse("6.1E-6",0));
}
private static String replaceVariables(double x, String s)
{
for(int i = 0; i < s.length(); i++)
{
if(s.charAt(i) == 'x')
{
s = s.substring(0,i) + x + s.substring(i+1);
}
}
return s;
}
}