Euler-Method
This is a package for approximating (numerically) the solution to differential equations of the form $y'=f(x,y)$ where $y$ is a function of $x$ and $f(x,y)$ is a function of both $y$ and $x$. Learn more.
const eulerMethod = require('euler-method')
console.log(eulerMethod('y', 100, { x: 0, y: 1 }, 0.3))
eulerMethod(func, iterations, initial, final)
Required
- The mathematical function to evaluate - Ommit the $y'$ part (Input 'y'
for the differential equation $y'=y$, for example) - Uses mathjs
formatting - See here for more information
func - Default: 100
- Number of times to iterate Euler's Method - More times yields more accurate results (but takes more time)
iterations - Default: { x: 0, y: 0 }
- A value that is guarenteed to be on the function - Due to the Fundamental Theorem of Calculus, differential equations have an infinite amount of solutions (determined up to a constant), so an "initial" value needs to be provided to calculate a unique value for the function
initial - Default: 10
- This is the value for which the function will be approximated to - The $y$ value will be outputed for this particular $x$ value - Using $y'=y$, for example, a final
value of $10$ will give the value for $y$ when $x=10$
final - Result
{ x: 0.3000000000000002, y: 1.3492527193665074 }