Advertisement
AntonioVillanueva

𝑃(𝑥)=2𝑥2−3𝑥−2 en Python3 avec matplotlib

Apr 3rd, 2019
346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.80 KB | None | 0 0
  1. #Antonio Villanueva Segura
  2. #Calculo grafico de 2x^2-3x-2 con matplotlib en python3
  3. #!/usr/bin/python
  4. # -*- coding: utf-8 -*-
  5. #python install pip
  6. #python -mpip install matplotlib
  7.  
  8. import numpy as np
  9. import matplotlib.pyplot as plt #Para plotear los resultados
  10.  
  11. def P(x):#La funcion   2x^2-3x-2
  12.     return (2*(x**2))-3*x-2
  13.  
  14. def liste_P(liste_x):# Crea una lista en funcion de los valores de X
  15.     liste=[]
  16.     for n in liste_x:
  17.         liste.append(P(n))
  18.     return liste
  19.  
  20. # Damos valores a las X de -10 a 10
  21. X = np.linspace(-10, 10)
  22.  
  23. # y calculamos Y con la funcion liste_(P) que utiliza P(x)=2x^2-3x-2
  24. Y = liste_P(X)
  25.  
  26. #Muestro los valores de ambas listas X e Y
  27. print ("Valores X = " ,X,'\n Valores Y = ',Y)
  28.  
  29. # Solo nos queda dibujar la lista de valores X, y
  30. plt.plot(X, Y)
  31. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement