Slope Field Generator

This application is for creating slope field graphs.
More customization will come in the future.
Inspiration: Mr. Magallon

Graph Values
Customize coordinates & points here

Initial Point (x₀, y₀)

How It Works

Mathematical explanation

4th Order Runge-Kutta (RK4)

The RK4 is a technique used for first-order ordinary differential equations, giving an approximate solution using 4 intermediate steps to calculate the next value of y over a given range x. The math behind it is as follows:

Given ordinary differential equation y' = f(x, y) & h as the stepsize:

  • k₁ = h * f(x, y)
  • k₂ = h * f(x + h/2, y + k₁/2)
  • k₃ = h * f(x + h/2, y + k₂/2)
  • k₄ = h * f(x + h, y + k₃)

The solution is updated as:
yₙ₊₁ = yₙ + (1/6)(k₁ + 2k₂ + 2k₃ + k₄)xₙ₊₁ = xₙ + h

Each intermediate value of k is calculated with respect to the prior value, where the first uses the initial point of (x₀, y₀) to initialize the curve from that point.
Normally, the curve is only drawn from the direction of the given stepsize, but if you want to draw it going left and right, you can run the rungeKutta function with both a positive and negative stepsize. Then, you combine the points together to create an array of all of the points and graph that.