Sympy to Numerical

23 views
Skip to first unread message

Keoagile Kerileng

unread,
May 24, 2022, 12:38:52 AM5/24/22
to sympy
Good day, I am new in to sympy and it looks to be the suitable one for my PhD. I have been working on my analytical work.

I now want try to plot and it seem not working for me. Can someone guide me or help how to turn expression which include i-th term and integral to change to numerical.

attached is sympy file.

Thank you. 
Prediction (Impact Force History).py

gu...@uwosh.edu

unread,
May 24, 2022, 8:38:06 AM5/24/22
to sympy
There are a lot of different options. I suggest you start by looking at these:
* Using the built in sympy plotting (https://docs.sympy.org/latest/modules/plotting.html)
* Using the quite nice sympy plotting backend extension ( https://sympy-plot-backends.readthedocs.io/en/latest/overview.html)
* Combine your solutions with pandas (https://pandas.pydata.org/) and tools for plotting and manipulation of pandas data. An example is jupyter_Pandas_GUI (https://jupyterphysscilab.github.io/jupyter_Pandas_GUI/Pandas_GUI_Doc_Home.html). Note: I am the initial author of this last tool.

Jonathan

Alan Bromborsky

unread,
May 24, 2022, 10:34:23 PM5/24/22
to sy...@googlegroups.com

If you need publication quality plots look at Asymptote -

https://asymptote.sourceforge.io/

The only drawback to Asymptote is that it has it's own scripting language.  Look at the galleries of examples which also show the scripts used.  My favorite examples is -

https://asymptote.sourceforge.io/gallery/3Dwebgl/Klein.html

(it can be zoomed, rotated, and translated interactively with mouse) with script -

import graph3;

size(469pt);

currentprojection=
  perspective(camera=(25.0851928432063,-30.3337528952473,19.3728775115443),
              up=Z,
              target=(-0.590622314050054,0.692357205025578,-0.627122488455679),
              zoom=1,autoadjust=false);

triple f(pair t) {
  real u=t.x;
  real v=t.y;
  real r=2-cos(u);
  real x=3*cos(u)*(1+sin(u))+r*cos(v)*(u < pi ? cos(u) : -1);
  real y=8*sin(u)+(u < pi ? r*sin(u)*cos(v) : 0);
  real z=r*sin(v);
  return (x,y,z);
}

surface s=surface(f,(0,0),(2pi,2pi),8,8,Spline);
draw(s,lightolive+white,"bottle",render(merge=true));

string lo="$\displaystyle u\in[0,\pi]: \cases{x=3\cos u(1+\sin u)+(2-\cos u)\cos u\cos v,\cr
y=8\sin u+(2-\cos u)\sin u\cos v,\cr
z=(2-\cos u)\sin v.\cr}$";

string hi="$\displaystyle u\in[\pi,2\pi]:\\\cases{x=3\cos u(1+\sin u)-(2-\cos u)\cos v,\cr
y=8\sin u,\cr
z=(2-\cos u)\sin v.\cr}$";

real h=0.0125;

begingroup3("parametrization");
draw(surface(xscale(-0.38)*yscale(-0.18)*lo,s,0,1.7,h,bottom=false),
     "[0,pi]");
draw(surface(xscale(0.26)*yscale(0.1)*rotate(90)*hi,s,4.9,1.4,h,bottom=false),
     "[pi,2pi]");
endgroup3();

begingroup3("boundary");
draw(s.uequals(0),blue+dashed);
draw(s.uequals(pi),blue+dashed);
endgroup3();

add(new void(frame f, transform3 t, picture pic, projection P) {
    draw(f,invert(box(min(f,P),max(f,P)),P),"frame");
  });
--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/ccc3aebb-41a2-43ab-b328-d96b7d16eb61n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages