Ipython sympy plot error -


i trying plot equation result of solve block using sympy here code , error message follows:

%pylab inline sympy import init_printing;init_printing() sympy import * d,vf,a,vi,t,x,h,g,theta=symbols('d vf vi t x h g theta') equations=[eq(sin(theta),(0.5*g*t**2+h)/(vi*t)),eq(cos(theta),x/(vi*t))] ans=solve(equations,[h,t],dict=true) h=ans[0][h] vi=5 g=9.8 theta=0.707 plot(h,(x,0,5)) 

then following error:

--------------------------------------------------------------------------- valueerror                                traceback (most recent call last) <ipython-input-11-f388e50e21e7> in <module>() ----> 1 plot(h,(x,0,5))  c:\anaconda\lib\site-packages\sympy\plotting\plot.pyc in plot(*args, **kwargs)    1158     show = kwargs.pop('show', true)    1159     series = [] -> 1160     plot_expr = check_arguments(args, 1, 1)    1161     series = [lineover1drangeseries(*arg, **kwargs) arg in plot_expr]    1162   c:\anaconda\lib\site-packages\sympy\plotting\plot.pyc in check_arguments(args, expr_len, nb_of_free_symbols)    1620         if len(free_symbols) > nb_of_free_symbols:    1621             raise valueerror("the number of free_symbols in expression" -> 1622                                 "is greater %d" % nb_of_free_symbols)    1623         if len(args) == + nb_of_free_symbols , isinstance(args[i], tuple):    1624             ranges = tuple(*[range_expr range_expr in args[i:i + nb_of_free_symbols]])  valueerror: number of free_symbols in expressionis greater 1 

if retype corect equation h correct plot.

thanks trying develop physics students use next year

the way trying set values of vi, g , theta doesn't work. symbolic expression h still made of sympy symbolic objects defined, while variable names point numbers defined. fix replace lines

vi=5 g=9.8 theta=0.707 

with

h = h.subs({vi:5, g:9.8, theta:.707}) 

or

h = h.subs(vi,5).subs(g,9.8).subs(theta,.707) 

i'd go whichever find clearer.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -