Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 To draw a polynomial solution
#1
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"
Quote
#2
(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
Quote
#3
I finally found the solution. How can I delete the post?
Quote

Top Page

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

Forum Jump:


Users browsing this thread: 1 Guest(s)