The terminology can get a bit confusing since we're using both math and programming concepts. To that end, I'll refer to a C++ function as a subroutine (not 100% accurate, but sufficient) and to a mathematical curve as a function. E.g. Subroutine: int doSomething(int a, bool b){ if(a<0) return -7; if(b) return 3*a; return 99; } Function: f(t) = 3t² + 9t -5 Ok, with that out of the way, I'll give a quick overview of how Euler's method works, then use that as a framework to program the algorithm. The purpose of Euler's method is to derive a set of points that approximate a curve defined by an ordinary differential equation that we don't know the solution to, but have at least one value for (the "initial condition"). Euler's method generates a series of coordinates; you can use as many or as few as you'd like. Generally speaking, you'll want to define how many points you want (n), and how far apart they should be (s). The s parameter will wind up determining the x values for the coordinates. E.g. suppose you wanted 3 new points (n=3), starting from x=5, with the points spaced 0.2 units apart (s=0.2). You'd wind up with an array of coordinates like this: (5.0,y0) (5.2,y1) (5.4,y2) (5.6,y3) Where y1-y3 are calculated as part of Euler's Method, and y0 is given as part of the initial value problem. A differential equation, by it's nature, relates the derivative of a function to the function itself. So if I had a function f(x) = x² + 2x, I could write a differential equation using it, something like: df(x)/dx = 2*f(x). Now, suppose we have a differential equation with an unknown solution, let's say dg(x)/dx = 3.5*g(x)/x, and an initial value for that system: g(2)=5.65685. We don't want to solve the system analytically, but we do want to know some additional points on the curve for g(x) (well, approximations thereof.) Let's choose our parameters (s and n from above). Suppose we want to know about the function g(x) on the interval x=[2.0,6.0]. We want a fairly good approximation, so let's use small steps: s=0.05. If we use steps of that size, we'll wind up with 79 new points in addition to the initial one (g(2)=5.65685), for a total of 80, which we hope will be a good representation. To generate the first new point y1, we compute the slope of the tangent at the starting point (given to us as (2,5.65685)). This is easy, because we were literally given an equation for the slope of the line there: dg(x)/dx = 3.5*g(x)/x; x=2 and g(2)=5.65685, so m = 3.5 * 5.65685 /2 = 9.89949. So, if that's the tangent line's slope, and lines are of the form y = mx + b, then the equation for this tangent line must be t1(x) = 9.89949*x - 14.14213 (we know mwhen x=2 and y=5.65685, so just solve for b.) We use the tangent line we just found along with our step size (s=0.05) to compute our first output value: (2.05,y1): t1(2.05) = 9.89949*2.05 - 14.14213 = 6.15182, so now we have 1 of our 79 output points: (2.05, 6.15182). Now we use that new point (2.05, 6.15182) to repeat the process above, which will create our second output: (2.10,y2). Finally, the coding part. Thanks for bearing with me. You asked how you'd define the given differential equation in code. The answer, as u/shingtaklam1324 correctly points out, is to use a (what I'm calling) subroutine. If you were writing a generic ODE solver, you would need to write a system that would allow a user to type in text (e.g. "y' = 3.5*y/x") and then parse that into an actual subroutine. That's a complicated problem on its own, so for now let's presume that you'll define the ODE to be worked within your code. E.g., for the ODE above dg(x)/dx = 3.5*g(x)/x: double dgx_dx(double x, double gx){ return 3.5*gx/x; } You'll be using this subroutine whenever you need to get a new slope. The only other thing you'll really need is a way to get the new point given the old point: double getNextY(double x0, double y0, double slope, double x1){ double b = y0-slope*x0; double y1 = slope*x1 + b; return y1; } Once you have those, you can start generating new points via a loop.