 |
Symbolic differentiation and integration using JSCL
Source code name: "symbolic1.py"
Programming language: Python
Topic: Symbolic/JSCL
DMelt Version 1. Last modified: 12/10/2015. License: Pro
https://datamelt.org/code/cache/symbolic1_2764.py
To run this script using the DMelt IDE,
copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.
from jhplot.math import *
from jhplot import *
from java.awt import Color
j=Symbolic("jscl") # using jscl engine
print "Integral ##############"
s1="integral(cos(x)+x^2,x)"
ans1=j.eval(s1) # this is the same as simplify(expand(s1))
print s1, " is ", ans1
print "Differentiate ##############"
s2="d(1/(1+x^2),x)"
ans2=j.eval(s2)
print s2, " is ", ans2
######## now plotting ####################
from java.awt import Color
from jhplot import *
c1 = HPlot("Canvas")
c1.setNameX("X")
c1.setNameY("Y")
c1.visible()
c1.setAutoRange()
f1 = F1D( ans1, 0, 1.0)
f1.setTitle("Diff")
c1.draw(f1)
f1 = F1D( ans2, 0, 1.0)
f1.setTitle("Integral")
f1.setColor(Color.blue)
c1.draw(f1)
You see the box below because you did not login.