SymPy in Jython

Viewed 18

I'm making a calculator app. I am using Java and Jython. I wanted to use the SymPy module but after calling the code below I get an error that there is no such module. Any advice?

try (PythonInterpreter interpreter = new PythonInterpreter()) {

            interpreter.exec("""
                    
                    from sympy import cos, sin, pi
                    def f(x):
                    \treturn\040""" + wartoscCalki.getText() +
                    """
                    \ndef simpson(a, b, n):
                    \tx1=0.0
                    \tx2=0.0
                    \tx0=f(a)+f(b)
                    \th=(b-a)/n
                    \twynik=0.0
                                            
                    \tfor i in range(1,n):
                    \t\tx=(a+(i*h))
                    \t\tif i%2==0:
                    \t\t\tx2+=f(x)
                    \t\telse:
                    \t\t\tx1+=f(x)
                    \twynik=h*(x0+2*x2+4*x1)/3
                    \treturn wynik
                    c=float(simpson(""" + granicaDolna.getText() + """
                    ,""" + granicaGorna.getText() + """
                    ,""" + liczbaPodprzedzialow.getText() + """
                    ))"""
            );
}

Caused by: Traceback (most recent call last): File "", line 2, in module ImportError: No module named sympy

0 Answers
Related