# -*- coding: utf-8 -*- """ Created on Fri Mar 25 14:23:19 2022 @author: turinici """ import numpy as np import matplotlib.pyplot as plt np.sqrt(2)**2 - 1 #np.sqrt(2)*np.sqrt(2) - 1 T=1.0 N=100 h = T/N U0exact=0.0 U0=np.sqrt(2)**2 - 2 Uexact = np.zeros(N+1) Uexact[0]=U0exact U = np.zeros(N+1) U[0]=U0 #implementation Euler Explicite for k in range(N): U[k+1]=U[k]+h*2*np.sqrt(np.abs(U[k])) Uexact[k+1]=Uexact[k]+h*2*np.sqrt(np.abs(Uexact[k])) plt.figure(1) plt.plot(np.linspace(0,T,N+1),U, np.linspace(0,T,N+1),Uexact) plt.legend(['precision finie','precision infinie'])