Backward Euler Method for First Order ODEs in C++ Code | Plot Soln using GNU
Professor ConeHead
0:00 / 0:00
Backward Euler Method for First Order ODEs in C++ Code | Plot Soln using GNU
165 просмотров · 9 дней назад
Professor ConeHead
18 подписчиков
165 просмотров · 9 дней назад
Solving y' = -2y using the Implicit (Backward) Euler Method in C++
In this video, I walk through a C++ program that numerically solves the ODE dy/dx = -2y with the initial condition y(0) = 1, using the Implicit Euler method.
🔹 What the code does:
Starts at x = 0, y = 1
Uses a step size h = 0.1 up to x = 1
Updates y at each step using the implicit Euler formula: y_(n+1) = y_n / (1 + 2h)
Prints the results to the console and saves them to a data file (rd14.dat) for plotting/analysis
🔹 Why Implicit Euler?
Unlike the explicit Euler method, the implicit (backward) Euler method is more numerically stable, especially for stiff differential equations — making it a great starting point for anyone learning numerical methods for ODEs.
🔹 Topics covered:
Numerical methods in C++
Implicit/Backward Euler method
File I/O in C++ (fstream)
Solving first-order ODEs numerically
💻 Full code included in the video — feel free to try it yourself and compare with the exact solution y(x) = e^(-2x)!
📌 Like, subscribe, and comment if you liked the video
#Cpp #NumericalMethods #ODE #ImplicitEuler #Programming #Coding #EngineeringMath #ScientificComputing