👤

Sagot :

CAYLUS

Réponse :

Bonsoir,

Explications étape par étape

Ce programme en python devrait vous aider.

#-----------------------------------------------

def fnc_f(p):

   return 2*p*p-20.5*p+100

def fnc_g(p):

   return 9*p+38

#-----------------------------------------------

import numpy as np

import matplotlib.pyplot as plt

#Max=int(input("Maximum="))

Max=15

s=0

Sol_x=[]

Sol_y=[]

array_x=np.array([i for i in range(0,Max+1)])

array_f=np.array([fnc_f(i) for i in range(0,Max+1)])

array_g=np.array([fnc_g(i) for i in range(0,Max+1)])

for i in range(0,len(array_f)):

   if array_f[i]<=array_g[i]:

       s=s+1

       Sol_x.append(i)

       Sol_y.append(-array_f[i]+array_g[i] )

print ("nb sol=",s)

for i in range(len(Sol_x)):

   print ("(",i,",",Sol_x[i],",",Sol_y[i],")")

#print (Sol_x,Sol_y)

#print (array_x)

#print (array_f)

#print (array_g)

plt.grid(True)

plt.plot(array_x, array_f)

plt.plot(array_x, array_g)

plt.plot(Sol_x, Sol_y,"o")

# : *, +, o.

plt.show()

plt.close()

© 2024 IDNLearn. All rights reserved.