0% found this document useful (0 votes)
7 views3 pages

Polynomes TD

The document contains a series of functions related to polynomial operations, including evaluation, degree calculation, normalization, scalar multiplication, addition, subtraction, multiplication, division, differentiation, and integration. Each function is defined with specific parameters and returns a normalized polynomial result. The document appears to be a programming code snippet for manipulating polynomials.

Uploaded by

Sir Glitch Fun
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views3 pages

Polynomes TD

The document contains a series of functions related to polynomial operations, including evaluation, degree calculation, normalization, scalar multiplication, addition, subtraction, multiplication, division, differentiation, and integration. Each function is defined with specific parameters and returns a normalized polynomial result. The document appears to be a programming code snippet for manipulating polynomials.

Uploaded by

Sir Glitch Fun
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

POLYNOMES TD

[1,1,0,1]
[1,0,0,0,-5]
P(X)=5+2X^4
Q(X)=0
Def image(P ,v) :
Result=0
For i in range(len(P)):
Result=P[i]*(v**i)
Def degre(P):
For i in range(len(P)-1;-1;-1):
If P[i] !=0:
Return i
Return 0
Def monome(a;i):
Return [0] * i + [a]
Def normaliser (P) :
While len(P) >1 and P[-1] ==0 :
P.pop()
Return P
Def mul_scalaire(P;v):
Return normaliser([v*coeff for coeff in P])
Def somme(P;Q):
Max_len = max(len(P);len(Q))
P+= [0] * (max_len – len(P))
Q+= [0] * (max_len – len(Q))
Return normaliser([P[i] + Q[i] for i in range
(max_len)])
Def difference(P;Q) :
Max_len = max(len(P) ; len(Q))
P += [0] * (max_len – len(P))
Q += [0] * (max_len – len(Q))
Return normaliser([P[i] – Q[i] for i in
range(max_len)])
Def produit(P;Q) :
Result=[0] * (len(P) + len(Q)-1)
For i in range(len(P)):
For j in range(len(Q)):
Result[i + j] += P[i] * Q[j]
Return normaliser(result)
Def div(P;Q) :
If len(Q) == 0:
Raise ValueError(“Division par zero’’)
Quotient = [0] * (len(P) – len(Q) +1)
Reste = P.copy()
While len(reste) >= len(Q) :
Coeff = reste[-1] / Q[-1]
Deg = len(reste) – len(Q)
Quotient[deg] = coeff
For i in range(len(Q)):
Reste[deg + i] -= coeff*Q[i]
Reste = normaliser(reste)
Return normaliser(quotient) ;normaliser(reste)
Def derivée(P) :
Return normaliser([i * P[i] for I in range(1;len(P))])
Def primitive(P):
Return normaliser([0] + [P[i] /(i+1) for i in
range(len(P))])

Zayd LEKHRIBAT

You might also like