Member

# Using the SymJa engine

SymJa is a Java computer algebra system which is discussed in more detail in SymJa web page. You should use the interface  jhplot.math.Symbolic to initialize this engine. Then you can use in in Python, Groovy, JRuby scripts or within the Java programs. Here is a simple examples how to use it:

from jhplot.math   import *

s=Symbolic("symja")
util=s.getEngine()

result = util.evaluate("Expand[(AX^2+BX)^2]")
print result

result = util.evaluate("A=2;B=4")
print result

result = util.evaluate("Expand[(A*X^2+B*X)^2]")
print result

result = util.evaluate("Factor[-1+x^16]")
print result

The syntax of the program is described on the SymJa web site. Here are more examples showing how to expand a polynomial, calculate derivatives and work with matrices:

from jhplot.math   import *

s=Symbolic("symja")
util=s.getEngine()

s="FactorInteger[2^15-5]" #  Factor an integer number
print util.evaluate(s)

s="D[Sin[x^3],x]"
print util.evaluate(s)    # Derivative of a function

s="Factor[-1+x^16]"
print util.evaluate(s)    # Factor a polynomial

s="Factor[5+x^12,Modulus->7]"
print util.evaluate(s)    # Factor a polynomial modulo an integer

s="Expand[(-1+x)*(1+x)*(1+x^2)*(1+x^4)*(1+x^8)]"
print util.evaluate(s)    # Expand a polynomial

s="Inverse[{{1,2},{3,4}}]"
print util.evaluate(s)    # Inverse of a matrix

s="Det[{{1,2},{3,4}}]"
print util.evaluate(s)    # Determinant of a matrix