Skip to content

Add Java implementation of Forward Euler #518

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 27, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contents/forward_euler_method/code/java/ForwardEuler.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ private static boolean checkResult(double[] eulerResult, double threshold, doubl
boolean isApprox = true;

for(int i = 0; i < eulerResult.length; i++) {
double time = (i - 1) * timestep;
double time = (i) * timestep;
Copy link
Contributor

@Butt4cak3 Butt4cak3 Oct 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uhm... So, why exactly is i still in parentheses? =P

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha! Because I'm lazy and didn't even look that closely

double solution = Math.exp(-3 * time);
if(Math.abs(eulerResult[i] - solution) > threshold) {
System.out.println(eulerResult[i] + " " + solution);
Expand Down