/math

differentiate or integrate simple functions console app

Primary LanguageJava

Before building project run:

mvn install:install-file -Dfile=lib/jcalc-1.0.jar -DgroupId=org.jcalculus -DartifactId=jcalc -Dversion=1.0 -Dpackaging=jar

Build project

mvn clean install

Run app

java -jar target/math-1.0-SNAPSHOT.jar

Usage examples:

Integrate:

jingerbread:math mfedorova$ java -jar target/math-1.0-SNAPSHOT.jar
0    [main] INFO  com.jingerbread.Main  - Choose differentiate or integrate, enter diff or int
int
4460 [main] INFO  com.jingerbread.math.Int  - Enter expression, note use uppercase function names:
SIN(x)
12266 [main] INFO  com.jingerbread.math.Int  - Integrate with respect to:
x
13432 [main] INFO  com.jingerbread.math.Int  - Result:
13432 [main] INFO  com.jingerbread.math.Int  - ADD(C,MULTIPLY(-1,COS(x)))
13432 [main] INFO  com.jingerbread.math.Int  - Enter interval [0, 1]
[-1.2, 5]
26570 [main] INFO  com.jingerbread.math.Int  - Entered interval: -1.2=5.0
26572 [main] INFO  com.jingerbread.math.Int  - Calculate integral on interval -1.2=5.0: 0.07869560000000003
26572 [main] INFO  com.jingerbread.math.Int  - Enter step of numeric integration
0.01
30479 [main] INFO  com.jingerbread.math.Int  - Numeric calculate integral on interval [-1.2=5.0]: 0.06912096635999952
30479 [main] INFO  com.jingerbread.Main  - If you want to exit: enter yes

Differentiate:

70874 [main] INFO  com.jingerbread.Main  - Choose differentiate or integrate, enter diff or int
diff
76081 [main] INFO  com.jingerbread.math.Diff  - Enter expression, note use uppercase function names:
SIN(x)
83076 [main] INFO  com.jingerbread.math.Diff  - Differentiate with respect to:
x
85380 [main] INFO  com.jingerbread.math.Diff  - Result:
85380 [main] INFO  com.jingerbread.math.Diff  - COS(x)
85380 [main] INFO  com.jingerbread.math.Diff  - Enter interval [0, 1]
[-3.14, 4]
95083 [main] INFO  com.jingerbread.math.Diff  - Entered interval: -3.14=4.0
95096 [main] INFO  com.jingerbread.math.Diff  - Differentiate values [-3.14=-0.9999899999999999, -3.04=-0.9953359999999994, -2.94=-0.9807399999999994, -2.84=-0.95634, -2.7399999999999998=-0.9223800000000004, -2.6399999999999997=-0.8792099999999969, -2.5399999999999996=-0.8272500000000016, -2.4399999999999995=-0.7670300000000019, -2.3399999999999994=-0.6991399999999981, -2.2399999999999993=-0.6242699999999934, -2.1399999999999992=-0.5431599999999981, -2.039999999999999=-0.4566300000000023, -1.939999999999999=-0.3655299999999917, -1.839999999999999=-0.2707800000000038, -1.7399999999999989=-0.17333000000000487, -1.6399999999999988=-0.07414000000000032, -1.5399999999999987=0.025799999999998047, -1.4399999999999986=0.1254699999999942, -1.3399999999999985=0.22389000000000436, -1.2399999999999984=0.3200599999999998, -1.1399999999999983=0.41303999999999785, -1.0399999999999983=0.5018999999999996, -0.9399999999999983=0.5857400000000013, -0.8399999999999983=0.6637299999999957, -0.7399999999999983=0.7350899999999938, -0.6399999999999983=0.799099999999997, -0.5399999999999984=0.8551199999999981, -0.4399999999999984=0.9025999999999978, -0.3399999999999984=0.9410699999999994, -0.2399999999999984=0.9701400000000027, -0.1399999999999984=0.9894999999999987, -0.0399999999999984=0.9989840000000006, 0.06000000000000161=0.9984839999999995, 0.1600000000000016=0.9880100000000003, 0.2600000000000016=0.967659999999998, 0.36000000000000165=0.9376400000000007, 0.46000000000000163=0.8982600000000007, 0.5600000000000016=0.8499000000000034, 0.6600000000000016=0.7930499999999951, 0.7600000000000016=0.7282600000000028, 0.8600000000000015=0.6562200000000074, 0.9600000000000015=0.5776100000000062, 1.0600000000000016=0.49323000000000006, 1.1600000000000017=0.40392000000000206, 1.2600000000000018=0.3105699999999989, 1.3600000000000019=0.21411999999999543, 1.460000000000002=0.11554000000000286, 1.560000000000002=0.01579000000000441, 1.6600000000000021=-0.08409999999999807, 1.7600000000000022=-0.18315999999999333, 1.8600000000000023=-0.28038999999999703, 1.9600000000000024=-0.37482000000000903, 2.0600000000000023=-0.46549999999999647, 2.1600000000000024=-0.5515300000000001, 2.2600000000000025=-0.6320500000000062, 2.3600000000000025=-0.706260000000003, 2.4600000000000026=-0.7734099999999966, 2.5600000000000027=-0.8328299999999955, 2.660000000000003=-0.8839200000000047, 2.760000000000003=-0.9261999999999992, 2.860000000000003=-0.9592099999999992, 2.960000000000003=-0.982630000000001, 3.060000000000003=-0.9962490000000004, 3.1600000000000033=-0.9999062999999999, 3.2600000000000033=-0.9935799999999995, 3.3600000000000034=-0.9773100000000007, 3.4600000000000035=-0.9512899999999991, 3.5600000000000036=-0.9157499999999985, 3.6600000000000037=-0.8710799999999963, 3.760000000000004=-0.8176899999999931, 3.860000000000004=-0.7561400000000051, 3.960000000000004=-0.6870299999999996]
95418 [main] INFO  com.jingerbread.Main  - If you want to exit: enter yes

See the graphics