Numerical Methods for Solving Differential Equations, Exercises of Mathematics

Various numerical methods for solving differential equations, including the euler method, heun's method, and the runge-kutta method. It provides the implementation of these methods in python and discusses their complexity and properties. The document also covers the encoding and decoding of text using the vigenère cipher, including the implementation of the encoding and decoding functions, as well as the analysis of the complexity and robustness of the cipher. Additionally, the document includes questions and solutions related to these topics, making it a valuable resource for students and researchers interested in numerical methods and cryptography.

Typology: Exercises

2023/2024

Uploaded on 03/05/2024

marouane-mellakh
marouane-mellakh 🇲🇦

1 document

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
PROBLEME I
Question 1:
On retrouve la méthode d'Euler pour (α,β) = (1,0)
Question 2:
def Heun(f,t0,y0,T,N) :
t,h,y = t0,T/N,y0
tt,yh = [t0],[y0]
while t <= t0+T :
y += (h/2)*(f(t,y)+f(t+h,y+(h*f(t,y))))
t += h
tt.append(t)
yh.append(y)
return tt,yh
Question 3:
def Euler(f,t0,y0,T,N) :
t,h,y = t0,T/N,y0
tt,yh = [t0],[y0]
while t <= t0+T :
y += h*(f(t,y)
t += h
tt.append(t)
yh.append(y)
return tt,yh
Question 4 :
La complexité de la fonction Euler : O(N)
Question 5 :
y0(t) = y1(t)
y1(t)= -4π²cos(2πt)-y1(t)-y0(t)
Question 6 :
F(t,X) = (X[1] , -4π²cos(2πt)-X[1]-X[0])
Question 7 :
*******
PROPOSITION DE CORRIGE DU CNC DINFORMATIQUE 2016
pf3
pf4

Partial preview of the text

Download Numerical Methods for Solving Differential Equations and more Exercises Mathematics in PDF only on Docsity!

PROBLEME I

Question 1:

On retrouve la méthode d'Euler pour (α,β) = (1,0)

Question 2:

def Heun (f,t0,y0,T,N) : t,h,y = t0,T/N,y tt,yh = [t0],[y0] while t <= t0+T : y += (h/2)(f(t,y)+f(t+h,y+(hf(t,y)))) t += h tt.append(t) yh.append(y) return tt,yh

Question 3:

def Euler (f,t0,y0,T,N) : t,h,y = t0,T/N,y tt,yh = [t0],[y0] while t <= t0+T : y += h*(f(t,y) t += h tt.append(t) yh.append(y) return tt,yh

Question 4 :

La complexité de la fonction Euler : O(N)

Question 5 :

y 0 (t) = y 1 (t) y 1 ’(t)= - 4π²cos(2πt)-y 1 (t)-y 0 (t)

Question 6 :

F(t,X) = (X[1] , - 4π²cos(2πt)-X[1]-X[0])

Question 7 :


PROPOSITION DE CORRIGE DU CNC D’INFORMATIQUE 2016

PROBLEME II

Question 8 :

def indice(c,ch) : for i in range(len(ch)) : if ch[i] == c : return i return - 1 # n’existe pas

def enMajuscule (CH) : alphabet_min = 'abcdefghijklmnopqrstuvwxyzâàéèêëïîôùûüÿç' alphabet_maj = 'ABCDEFGHIJKLMNOPQRSTUVWXYZAAEEEEIIOUUUYC' s = '' for c in CH : i = indice(c,alphabet_min) if i != -1 : s += alphabet_maj[i] else : s += c return s

Question 9 :

def majusculesSeules (CH) : alphabet_min = 'abcdefghijklmnopqrstuvwxyzâàéèêëïîôùûüÿç' alphabet_maj = 'ABCDEFGHIJKLMNOPQRSTUVWXYZAAEEEEIIOUUUYC' s = '' for c in CH : i = indice(c,alphabet_min) if i != -1 : s += alphabet_maj[i] return s

Question 10 :

def vigenereEncode (CH,CL) : alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' n = len(CH) m = len(CL) ch_criptée = '' for i in range(n) : lettre_clé = CL[i%m] k = indice(CH[i],alphabet) h = indice(lettre_clé,alphabet) p = (k+h)% ch_cryptée += alphabet[p] return ch_cryptée

Question 11 :

La complexité de la fonction vigenereEncode est O(len(CH))

Question 12 :

def vigenereEncodeRec (CH,CL,i) : alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' n = len(CH) m = len(CL) if i>n : return '' lettre_clé = CL[i%m]

Question 19 :

def code (CH,p) : alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' clé = '' LSC = listeSousChaines(CH,p) for s in LSC : L = frequencesCaracteres (s) i = indiceMax(L) clé += alphabet[(6-i)%26] return clé

------------- FIN DE L’EPREUVE -----------------