Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,29 +1,29 @@
|
|||
// Function that takes differential-equation, initial condition,
|
||||
// ending x, and step size as parameters
|
||||
function eulersMethod(f, x1, y1, x2, h) {
|
||||
// Header
|
||||
console.log("\tX\t|\tY\t");
|
||||
console.log("------------------------------------");
|
||||
// Header
|
||||
console.log("\tX\t|\tY\t");
|
||||
console.log("------------------------------------");
|
||||
|
||||
// Initial Variables
|
||||
var x=x1, y=y1;
|
||||
// Initial Variables
|
||||
var x=x1, y=y1;
|
||||
|
||||
// While we're not done yet
|
||||
// Both sides of the OR let you do Euler's Method backwards
|
||||
while ((x<x2 && x1<x2) || (x>x2 && x1>x2)) {
|
||||
// Print what we have
|
||||
console.log("\t" + x + "\t|\t" + y);
|
||||
// While we're not done yet
|
||||
// Both sides of the OR let you do Euler's Method backwards
|
||||
while ((x<x2 && x1<x2) || (x>x2 && x1>x2)) {
|
||||
// Print what we have
|
||||
console.log("\t" + x + "\t|\t" + y);
|
||||
|
||||
// Calculate the next values
|
||||
y += h*f(x, y)
|
||||
x += h;
|
||||
}
|
||||
// Calculate the next values
|
||||
y += h*f(x, y)
|
||||
x += h;
|
||||
}
|
||||
|
||||
return y;
|
||||
return y;
|
||||
}
|
||||
|
||||
function cooling(x, y) {
|
||||
return -0.07 * (y-20);
|
||||
return -0.07 * (y-20);
|
||||
}
|
||||
|
||||
eulersMethod(cooling, 0, 100, 100, 10);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue