Skip to content

Instantly share code, notes, and snippets.

@camisetags
Created March 10, 2015 21:27
Show Gist options
  • Save camisetags/ff17458cbc43064a8ea7 to your computer and use it in GitHub Desktop.
Save camisetags/ff17458cbc43064a8ea7 to your computer and use it in GitHub Desktop.
euler.js
<!DOCTYPE html>
<html>
<head>
<title>25.6</title>
<script>
var xi = 0,
xf = 4,
x = xi,
y = 1;
var dx = 0.5;
var nc = (xf - xi)/dx;
console.log(x, y);
function f(x, y, dx, i){
if ( i <= nc ) {
var dydx = (-2 * Math.pow(x, 3)) + (12 * Math.pow(x, 2)) - (20 * x) + 8.5;
y = y + dydx * dx;
x = x + dx;
console.log(x, y);
i++;
return f(x, y, dx, i);
}
}
f(x, y, dx, i = 0);
</script>
</head>
<body>
<h1>Abra o terminal</h1>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment