Bottom Page

• 0 Vote(s) - 0 Average
• 1
• 2
• 3
• 4
• 5
 To draw a polynomial solution pianistseb Silly Frenchman Posts: 21 Threads: 7 Joined: Nov 2018 Reputation: 0 Likes received: 0 #1 Nov-13-2018, 12:54 PM (This post was last modified: Nov-13-2018, 12:54 PM by pianistseb. Edited 2 times in total.) 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" buran Posts: 6,051 Threads: 102 Joined: Sep 2016 Reputation: 465 Likes received: 1268 #2 Nov-13-2018, 01:15 PM (This post was last modified: Nov-13-2018, 01:15 PM by buran. Edited 1 time in total.) (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 pianistseb Silly Frenchman Posts: 21 Threads: 7 Joined: Nov 2018 Reputation: 0 Likes received: 0 #3 Nov-13-2018, 01:45 PM I finally found the solution. How can I delete the post? « Next Oldest | Next Newest »

Top Page

 Possibly Related Threads... Thread Author Replies Views Last Post Can I evaluate a Chebyshev polynomial using a function player1681 1 301 Nov-22-2019, 06:33 AM Last Post: scidam Machine Learning Polynomial Regression braveYug 0 233 Nov-13-2019, 11:41 AM Last Post: braveYug Confidence intervals over time with polynomial regression jjameson 0 636 May-16-2019, 02:22 PM Last Post: jjameson

Forum Jump:

Users browsing this thread: 1 Guest(s)