importmath# REVISIONS ULTIMATE TOMIC
# Lignes < 32 car. Sans accent.
# PAS D APOSTROPHE.
defed1_methode():print("--- ED ORDRE 1 ---")print("Forme: y1 + a(x)y = b(x)")print("")print("SUR TA COPIE:")print("1. HOMOGENE (y1 + ay = 0)")print(" Prim A(x) de a(x)...")print(" yh(x) = K * exp(-A(x))")print("")print("2. PARTICULIERE (yp)")print(" Methode Var Constante:")print(" Poser yp = K(x) * exp(-A)")print(" Deriver et injecter ds E")print(" Trouver K1(x) puis K(x)")print("")print("3. SOL GENERALE")print(" y(x) = yh(x) + yp(x)")print(" y(x) = K*exp(...) + ...")print("")print("4. SOL UNIQUE (C.I.)")print(" Avec y(x0) = y0")print(" Remplacer x par x0")print(" Trouver K.")input("EXE pour Menu...")defed2_ultimate():print("--- ED ORDRE 2 COMPLET ---")print("ay2 + by1 + cy = f(x)")try:a=float(input("a? "))b=float(input("b? "))c=float(input("c? "))except:return# 1. HOMOGENE
delta=b*b-4*a*cprint("\n--- ETAPE 1: HOMOGENE ---")print("Eq carac: "+str(a)+"r^2+"+str(b)+"r+"+str(c)+"=0")print("Delta = "+str(delta))# Stockage des params pour C.I.
mode=0# 0:Reel, 1:Double, 2:Cplx
p1,p2=0,0ifdelta>0:r1=(-b-math.sqrt(delta))/(2*a)r2=(-b+math.sqrt(delta))/(2*a)mode=0;p1=r1;p2=r2print("2 Racines reelles:")print("r1="+str(round(r1,2))+" r2="+str(round(r2,2)))print("yh(x) = A*exp(r1*x) +")print(" B*exp(r2*x)")elifdelta==0:r0=-b/(2*a)mode=1;p1=r0print("1 Racine double:")print("r0="+str(round(r0,2)))print("yh(x) = (Ax + B)*exp(r0*x)")else:alpha=-b/(2*a)beta=math.sqrt(-delta)/(2*a)mode=2;p1=alpha;p2=betaprint("Racines complexes:")print("r = "+str(round(alpha,2))+" +/- i"+str(round(beta,2)))print("yh(x) = exp(alph*x) * ...")print("(A*cos(bet*x) + B*sin(bet*x))")input("EXE: Sol Particuliere...")# 2. PARTICULIERE
print("\n--- ETAPE 2: PARTICULIERE ---")print("Type de f(x)?")print("0:Rien 1:Cst 2:Poly 3:Sin")ch=input("Choix? ")ifch=="1":print("f(x) = Constante K")print("On cherche yp(x) = C (Cst)")print("Calcul: yp = K / c")elifch=="2":print("f(x) = Polynome degre n")print("On cherche yp meme degre n")print("Ex: ax2+bx+c -> Ax2+Bx+C")print("Identifier coeff...")elifch=="3":print("f(x) = K*cos(w*x)")print("On cherche yp forme:")print("C1*cos(wx) + C2*sin(wx)")else:print("Pas de 2nd membre (yp=0)")print("\n--- ETAPE 3: GENERALE ---")print("SOLUTION GENERALE S.G.:")print("y(x) = yh(x) + yp(x)")input("EXE: Cond. Initiales...")# 3. CONDITIONS INITIALES
print("\n--- ETAPE 4: SOL UNIQUE ---")print("Systeme avec C.I.:")try:y0=float(input("y(0) = ? "))v0=float(input("y1(0) (derivee) = ? "))except:returnprint("Resolution systeme A,B...")A_val,B_val=0,0# RESOLUTION SYSTEME
ifmode==0:# Reelles r1, r2
# A + B = y0
# A*r1 + B*r2 = v0
# B = (v0 - r1*y0)/(r2-r1)
if (p2-p1)!=0:B_val=(v0-p1*y0)/(p2-p1)A_val=y0-B_valprint("A = "+str(round(A_val,2)))print("B = "+str(round(B_val,2)))print("SOL FINALE:")print(str(round(A_val,2))+"e^("+str(round(p1,2))+"x)")print("+ "+str(round(B_val,2))+"e^("+str(round(p2,2))+"x)")elifmode==1:# Double r0
# y(0) = B = y0
# y1(0) = A + B*r0 = v0 -> A = v0 - y0*r0
B_val=y0A_val=v0-y0*p1print("A = "+str(round(A_val,2)))print("B = "+str(round(B_val,2)))print("SOL FINALE:")print("("+str(round(A_val,2))+"x + "+str(round(B_val,2))+")")print("* exp("+str(round(p1,2))+"x)")elifmode==2:# Complexe alpha, beta
# y(0) = A = y0
# y1(0) = A*alpha + B*beta = v0
# B = (v0 - A*alpha)/beta
A_val=y0ifp2!=0:B_val=(v0-A_val*p1)/p2print("A = "+str(round(A_val,2)))print("B = "+str(round(B_val,2)))print("SOL FINALE:")print("exp("+str(round(p1,2))+"x) * ...")print("("+str(round(A_val,2))+"cos("+str(round(p2,2))+"x)")print("+"+str(round(B_val,2))+"sin("+str(round(p2,2))+"x))")input("EXE pour Menu...")defosc_physique():print("--- OSCILLATEURS ---")print("x2 + w0^2 x = f(t)")print("C est une ED Ordre 2 !")print("Avec a=1, b=0, c=w0^2")print("")print("1. SOL HOMOGENE (Regime Libre)")print("Delta toujours negatif (-4w0^2)")print("xh(t) = A*cos(w0t) + B*sin(w0t)")print("")print("2. SOL PARTICULIERE (Force)")print("- Si f(t)=F (Cst): xp = F/w0^2")print("- Si f(t)=cos(wt) (Sinus):")print(" Si w != w0: xp = C*cos(wt)")print(" Si w = w0 (RESONANCE):")print(" xp(t) = C * t * sin(wt)")print("")print("3. SOL GENERALE")print("x(t) = xh(t) + xp(t)")print("Utiliser cond init x(0), v(0)")print("pour trouver A et B.")print("ASTUCE: Utilise le Menu 2")print("avec a=1, b=0, c=w0^2")input("EXE pour Menu...")defintegr():print("--- INTEGRALES ---")print("1. METHODE GENERALE")print("- Faire un Dessin du domaine")print("- Ecrire bornes (ex: 0 a R)")print("- Integrale dedans vers dehors")print("")print("2. COORD POLAIRES (2D)")print("x=r*cos(th) y=r*sin(th)")print("dx dy deviens r dr dth")print("!! NE PAS OUBLIER LE r !!")print("")print("3. COORD CYLINDRIQUES (3D)")print("Ajout de z. dV = r dr dth dz")input("EXE pour Menu...")defmenu():whileTrue:print("")print("=== MENU ULTIMATE ===")print("1. Methodo ED Ordre 1")print("2. SOLVEUR ED Ordre 2")print("3. Oscillateurs (Phys)")print("4. Integrales")print("5. Quitter")c=input("Choix? ")ifc=="1":ed1_methode()elifc=="2":ed2_ultimate()elifc=="3":osc_physique()elifc=="4":integr()elifc=="5":breakmenu()
During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:
Ensure the proper functioning of the site (essential cookies); and
Track your browsing to send you personalized communications if you have created a professional account on the site and can be contacted (audience measurement cookies).
With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.