Attention : ne pas oubler d'exécuter la première cellule.
nom="g"
def f(x) : # ne pas changer f sur cette ligne
return 2*x**2-5*x+1
print(f"Exemple, pour x=0, on a {nom}(0) = {f(0)}.")
Exemple, pour x=0, on a g(0) = 1.
xmin = -4
xmax = 5
pas = 1
x=xmin
while x <=xmax :
print(f"{nom}({x:5.1f}) = {f(x):8.2f}")
x=x+pas
g( -4.0) = 53.00 g( -3.0) = 34.00 g( -2.0) = 19.00 g( -1.0) = 8.00 g( 0.0) = 1.00 g( 1.0) = -2.00 g( 2.0) = -1.00 g( 3.0) = 4.00 g( 4.0) = 13.00 g( 5.0) = 26.00
%matplotlib notebook
import courbe
from courbe import plt,np
plt.ion()
#---------------- pour un affichage automatique
courbe.xmin = -10
courbe.xmax = 10
#--------------- réglages utilisés pour un affichage personnalisé
courbe.ymin=-20
courbe.ymax=30
courbe.xstep=2
courbe.ystep=5
#---------------- choisir l'affichage
# auto = 1 : automatique
#auto = 0 : personnalisé
nom_f="$({\cal C}_"+nom+")$"
courbe.affichage(f,nom = nom_f, couleur = "green",auto=0)
#courbe.affichage(g,nom = "$({\cal C}_g$)",couleur = "red",auto=0)
#------------------------------ éventuelles asymtotes
#courbe.asymptote_horizontale(2)
#courbe.asymptote_verticale(1)
#-------------- pour afficher la grille
plt.grid()
plt.legend()
plt.show()