Skip to content

Commit 769ef0e

Browse files
authored
Adjusted looping to include the endpoint
1 parent dace7bf commit 769ef0e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Maths/EulerMethod.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function eulerFull (xStart, xEnd, stepSize, yStart, differentialEquation) {
2828
let yCurrent = yStart
2929
let xCurrent = xStart
3030

31-
while (xCurrent <= xEnd - stepSize) {
31+
while (xCurrent < xEnd) {
3232
// Euler method for next step
3333
yCurrent = eulerStep(xCurrent, stepSize, yCurrent, differentialEquation)
3434
xCurrent += stepSize
@@ -86,7 +86,7 @@ function exampleEquation3 (x, y) {
8686
}
8787

8888
const points1 = eulerFull(0, 4, 0.1, 0, exampleEquation1)
89-
const points2 = eulerFull(0, 4.1, 0.1, 1, exampleEquation2)
89+
const points2 = eulerFull(0, 4, 0.1, 1, exampleEquation2)
9090
const points3 = eulerFull(0, 0.1, 0.025, 1, exampleEquation3)
9191

9292
console.log(points1)

0 commit comments

Comments
 (0)