diff --git a/src/net/apocalypselabs/symat/Functions.java b/src/net/apocalypselabs/symat/Functions.java
index f6b3171..dd4cb60 100644
--- a/src/net/apocalypselabs/symat/Functions.java
+++ b/src/net/apocalypselabs/symat/Functions.java
@@ -28,8 +28,6 @@
package net.apocalypselabs.symat;
import static java.lang.Math.*;
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineManager;
import javax.swing.JOptionPane;
import org.matheclipse.core.eval.EvalUtilities;
import org.matheclipse.parser.client.math.MathException;
@@ -42,9 +40,8 @@ import org.matheclipse.parser.client.math.MathException;
* @author Skylar
*/
public class Functions {
-
- private ScriptEngine symja = new ScriptEngineManager().getEngineByExtension("m");
- private EvalUtilities util = new EvalUtilities(true, true);
+
+ private final EvalUtilities util = new EvalUtilities(true, true);
Graph graphwin = new Graph(true);
/*
@@ -63,9 +60,27 @@ public class Functions {
*/
// Derivative of function with respect to idv
- public String D(String function, String idv) {
+ public String diff(String function, String idv) {
return util.evaluate("diff(" + function + "," + idv + ")").toString();
}
+
+ public String diff(String function) {
+ // Assume "x" as var
+ return diff(function, "x");
+ }
+
+ @Deprecated
+ public String D(String function, String idv) {
+ return diff(function, idv);
+ }
+
+ public String integrate(String function, String idv) {
+ return util.evaluate("integrate(" + function + "," + idv + ")").toString();
+ }
+
+ public String integrate(String function) {
+ return integrate(function, "x");
+ }
public String factor(String function) {
return sym("Factor(" + function + ")");
diff --git a/src/net/apocalypselabs/symat/help/commands.html b/src/net/apocalypselabs/symat/help/commands.html
index 5e5bc37..82a30cf 100644
--- a/src/net/apocalypselabs/symat/help/commands.html
+++ b/src/net/apocalypselabs/symat/help/commands.html
@@ -8,7 +8,8 @@
notify(var) Creates a popup box with the given content.
ask(prompt) Returns the entered text.
print(text) Outputs the given text to the screen. Does not require special prefix in Python.
-
D("3*x", "x") Returns the derivative of the function with respect to the second argument.
+
diff("x^3", "x") Returns the derivative of the function with respect to the second argument.
+
integrate("3*x^2", "x") Returns the integral of the function with respect to the second argument.
$("command") Parses the given text with the Symja library.
Aliases: sym
replace("text", "find", "replace") Returns "text" with all occurrences of "find" changed to "replace".
diff --git a/src/net/apocalypselabs/symat/resources/jsfunctions.txt b/src/net/apocalypselabs/symat/resources/jsfunctions.txt
index 2af5356..76145bc 100644
--- a/src/net/apocalypselabs/symat/resources/jsfunctions.txt
+++ b/src/net/apocalypselabs/symat/resources/jsfunctions.txt
@@ -1,6 +1,7 @@
notify|return nothing|Display a message in a box.
ask|return String|Ask a question in a box. Supply question text.
-D|return String|Find the derivative of the function passed with respect to the second argument.
+diff|return String|Find the derivative of the function passed with respect to the second argument.
+integrate|return String|Find the integral of the function passed with respect to the second argument.
rad|return double|Convert a given number in degrees to radians.
deg|return double|Convert a given number in radians to degrees.
subs|return double|Solve an equation for the second argument.
diff --git a/src/net/apocalypselabs/symat/resources/pyfunctions.txt b/src/net/apocalypselabs/symat/resources/pyfunctions.txt
index cb6328c..2984dcc 100644
--- a/src/net/apocalypselabs/symat/resources/pyfunctions.txt
+++ b/src/net/apocalypselabs/symat/resources/pyfunctions.txt
@@ -1,6 +1,7 @@
_.notify|return nothing|Display a message in a box.
_.ask|return String|Ask a question in a box. Supply question text.
-_.D|return String|Find the derivative of the function passed with respect to the second argument.
+_.diff|return String|Find the derivative of the function passed with respect to the second argument.
+_.integrate|return String|Find the integral of the function passed with respect to the second argument.
radians|return double|Convert a given number in degrees to radians.
degrees|return double|Convert a given number in radians to degrees.
_.subs|return double|Solve an equation for the second argument.