Ok, thanks. This seems works well. The only thing which had to be change is to replace "**" (power) with the usual "^"
The code below works well in jhepwork (shows the function and its differential on the same plot) ************************************************************* from java.awt import Color from jhplot import * c1 = HPlot("Canvas") c1.setAutoRange() c1.setGTitle("Example", Color.red) c1.setNameX("Xaxis") c1.setNameY("Yaxis") c1.setName("Canvas title") c1.visible() c1.setAutoRange() func="2*exp(-x*x/50)+sin(pi*x)/x" f1 = F1D(func, 1.0, 10.0) c1.draw(f1) # use sympy from sympy import * x = Symbol('x') a=diff(S(func), x) ff=str(a).replace("**","^") f2 = F1D(ff, 1.0, 10.0) f2.setTitle("Differential") f2.setColor(Color.green) c1.draw(f2) # export to some image (png,eps,pdf,jpeg...) # c1.export(Editor.DocMasterName()+".png") ********************************************************* On Sun, Jul 5, 2009 at 5:32 PM, Aaron S. Meurer <asmeu...@gmail.com> wrote: > > Hi, I'm not completely clear on what you are doing, as I don't use > jython, but couldn't you just use str(), as in > > >>> a = str(diff(2*exp(-x*x/50)+sin(pi*x)/x, x)) > >>> type(a) > <type 'str'> > >>> F1D(a) # probably works now > > Also, you can use sympify() or just S() to convert from a string to a > SymPy expression: > > >>> func = func="2*exp(-x*x/50)+sin(pi*x)/x" > >>> print S(diff(func,x)) > -sin(pi*x)/x**2 + pi*cos(pi*x)/x - 2*x*exp(-x**2/50)/25 > > > On Jul 5, 2009, at 7:35 AM, sergei175 wrote: > > > > > > > Hi, > > > > Sympy seems is rather advanced and useful project. > > > > I've tried to test it using jhepwork, and even included it into > > http://jwork.org/jhepwork/download/ > > (version 2.0) for test purpose (directory python/packages) > > > > Apparently, one can run sympy using Jython (v2.5) and Java ! > > A code snipped is below. Load it into the jHepWork IDE > > editor and press the button [run]. > > > > However, there is on feature I want to understand. To plot a function > > as in the example below using F1D class, I need to pass a string > > representing this function. However, simpy cannot accept strings for > > the > > statements such as diff() or integral(). In the below example, what I > > want > > to do is to type "diff(func,x)". > > > > Further, if I want to plot the result of "diff" or integration, I > > need again a string > > representing the output function and pass it to the F1D class as in > > the example. > > How can I do this? > > > > thanks, Sergei > > > > ******************************************************** > > # jHepWork Jython example > > > > from java.awt import Font,Color > > from jhplot import * > > > > c1 = HPlot("Canvas") > > c1.setAutoRange() > > > > c1.setGTitle("Example", Color.red) > > c1.setNameX("X") > > c1.setNameY("Y") > > c1.setName("Simpy example") > > c1.visible() > > c1.setAutoRange() > > > > # draw function > > func="2*exp(-x*x/50)+sin(pi*x)/x" > > f1 = F1D(func, -2.0, 5.0) > > c1.draw(f1) > > > > # use sympy > > from sympy import * > > x = Symbol('x') > > print diff(2*exp(-x*x/50)+sin(pi*x)/x, x) > > > > # how to get string with the result > > # to build F1D with results for drawing? > > > > # export to some image (png,eps,pdf,jpeg...) > > # c1.export(Editor.DocMasterName()+".png") > > > > > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sympy@googlegroups.com To unsubscribe from this group, send email to sympy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sympy?hl=en -~----------~----~----~----~------~----~------~--~---