- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Euler Method for solving differential equation in C++

In this problem, we are given a *differential equation ***f(x, y) = dy/dx **with initial value *y(x _{0}) = y_{0}*. Our task is to find the solution of the equation using the Euler method for solving differential equations.

## EULER METHOD

Euler method also known as *forward euler Method *is a first order numerical procedure to find the solution of the given differential equation using the given initial value.

For a differential equation f(x, y) = dy / dx. Euler method is defined as,

*y(n+1) = y(n) + h * f( x(n), y(n) )*

The value h is step size which is calculated as,

*h = (x(n) - x(0)) / n*

## Program to illustrate the working of our solution,

## Example

#include <iostream> using namespace std; float equation(float x, float y) { return (x + y); } void solveEquationEulers(float x0, float y, float h, float x) { float temp = 0.0; while (x0 < x) { temp = y; y = y + h * equation(x0, y); x0 = x0 + h; } cout<<"The solution of the differential equation at x = "<< x <<" is f(x, y) = "<<y; } int main() { float x0 = 0; float y0 = 1; float h = 0.5; float x = 0.1; solveEquationEulers(x0, y0, h, x); return 0; }

## Output −

The solution of the differential equation at x = 0.1 is f(x, y) = 1.5

- Related Questions & Answers
- Runge-Kutta 4th order rule for differential equation
- Signals and Systems – Solving Differential Equations with Laplace Transform
- Explain Differential pricing method
- C++ program for Solving Cryptarithmetic Puzzles
- Solving Cryptarithmetic Puzzles
- Sudoku Solving algorithms
- DC Motor Voltage Equation, Power Equation and Condition for Maximum Mechanical Power
- Secant method to solve non-linear equation
- Euler and Hamiltonian Paths
- What is Differential Cryptanalysis in Information Security?
- Euler Circuit in a Directed Graph
- Euler’s criterion in java
- Find Positive Integer Solution for a Given Equation in C++
- C++ Program to Implement Euler Theorem
- Euler's Four Square Identity in C++

Advertisements