/*
This program uses the Euler-Richardson method to solve the differential equation
dy/dx = x + y. The initial condition is y(0) = 1 and the step size is h = 0.025.
The program calculates the value of y at x = 0.1.
*/
#include <iostream>
#include <cmath>
using namespace std;
double f(double x, double y)
{
return (x + y);
}
int main()
{
double x0 = 0;
double y0 = 1;
double h = 0.025;
double xn = 0.1;
while (x0 < xn) {
double y1 = y0 + h * f(x0 + h / 2, y0 + h / 2 * f(x0, y0));
x0 += h;
y0 = y1;
}
cout << "The value of y at x is " << y0 << endl;
return 0;
}