To draw a polynomial solution - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Data Science (https://python-forum.io/forum-44.html) +--- Thread: To draw a polynomial solution (/thread-14062.html) |
To draw a polynomial solution - pianistseb - Nov-13-2018 I just want to draw a polynomial solution and I have always the same error. I need this program to complete my thesis. I'm new in python. Please help!!! from sympy.solvers import solve from sympy import Symbol from sympy import solve, Poly, Eq, Function, exp from sympy.abc import x, y, z, a, b import matplotlib.pyplot as plt import numpy as np def coef0(k0,c,N): return k0**2*c**2*N**2 def coef1(k0,q,a): return -(k0**2+q**2+0.25*a**2) def coef2(k0): return 1 def sols(a0,a1,a2): omg2=Symbol('omg2') c=solve(Poly(a2*omg2**2+a1*omg2+a0),omg2) return c N=10 a=20.42 k0=np.arange(1,500,1) n=np.arange(1,11,1) x=k0 c=1 plt.figure(1) plt.rc('text', usetex=True) plt.rc('font', family='serif') for i in n: q=i*np.pi c0=coef0(k0,c,N) c1=coef1(k0,qq,a) c2=coef2(k0) y1,y2=sols(c0,c1,c2) plt.plot(x,y1,'b',x,y2,'r') plt.xlabel(r'$\bar{k}^{2}_{0}$',fontsize=16) plt.ylabel(r'$\bar{\omega}^{2}$',fontsize=16) plt.title(r"Arithmetic Dispersion Diagram", fontsize=16, color='purple') plt.legend([r'$\bar{\omega}_{p}$',r'$\bar{\omega}_{g}$']) plt.ylim(1,500) plt.xlim(1,30) plt.show()Hint: I tried also to create a scatter with a for loop j in k0, but always the same problem. The error is: "can't initialize from 'list' without generators" RE: To draw a polynomial solution - buran - Nov-13-2018 (Nov-13-2018, 12:54 PM)pianistseb Wrote: I have always the same error.Please, read What to include in a post Post the full traceback in error tags RE: To draw a polynomial solution - pianistseb - Nov-13-2018 I finally found the solution. How can I delete the post? |