benchmarks.wiki / Public workspace
SciCode / 78.2 / Write a fourth-order fixed-time-step Runge-Kutta (RK4) integrator from scratch…
Problem
Answer published by the source. Consult the official source to check your work against its answer.
step background
Background
Given an initial value problem of the form:
the RK4 method updates the solution from time to using the following steps:
**2.1 Calculate intermediate slopes:**
-
-
-
-
**2.2 Update the solution:**
In our case, ** represents the state vector of the system, which includes the angle ** and the angular velocity **.
Plain-text mathematical notation (without MathML)
Background Given an initial value problem of the form: (dy)/(dt)=f(t,y), y(t₀)=y₀ the RK4 method updates the solution y from time t to t+Δt using the following steps: **2.1 Calculate intermediate slopes:** - k₁=f(t,y) - k₂=f(t+(Δt)/(2),y+(k₁Δt)/(2)) - k₃=f(t+(Δt)/(2),y+(k₂Δt)/(2)) - k₄=f(t+Δt,y+k₃Δt) **2.2 Update the solution:** y(t+Δt)=y(t)+(Δt)/(6)(k₁+2k₂+2k₃+k₄) In our case, *y* represents the state vector of the system, which includes the angle *θ* and the angular velocity *ω*.
Original LaTeX notation
Background
Given an initial value problem of the form:
$$
\frac{dy}{dt} = f(t, y), \quad y(t_0) = y_0
$$
the RK4 method updates the solution $y$ from time $t$ to $t + \Delta t$ using the following steps:
**2.1 Calculate intermediate slopes:**
- $k_1 = f(t, y)$
- $k_2 = f(t + \frac{\Delta t}{2}, y + \frac{k_1 \Delta t}{2})$
- $k_3 = f(t + \frac{\Delta t}{2}, y + \frac{k_2 \Delta t}{2})$
- $k_4 = f(t + \Delta t, y + k_3 \Delta t)$
**2.2 Update the solution:**
$$
y(t + \Delta t) = y(t) + \frac{\Delta t}{6} (k_1 + 2k_2 + 2k_3 + k_4)
$$
In our case, *$y$* represents the state vector of the system, which includes the angle *$\theta$* and the angular velocity *$\omega$*.step description prompt
Write a fourth-order fixed-time-step Runge-Kutta (RK4) integrator from scratch in Python, to calculate and at any certain timepoint. The output of this procedure — a series of state vectors representing the n-point state-space trajectory emanating from ~x(t0). Do not use any canned numerical integration routines, commands, functions.
Plain-text mathematical notation (without MathML)
Write a fourth-order fixed-time-step Runge-Kutta (RK4) integrator from scratch in Python, to calculate θ and ω at any certain timepoint. The output of this procedure — a series of state vectors representing the n-point state-space trajectory emanating from ~x(t0). Do not use any canned numerical integration routines, commands, functions.
Original LaTeX notation
Write a fourth-order fixed-time-step Runge-Kutta (RK4) integrator from scratch in Python, to calculate $\theta$ and $\omega$ at any certain timepoint. The output of this procedure — a series of state vectors representing the n-point state-space trajectory emanating from ~x(t0). Do not use any canned numerical integration routines, commands, functions.
Discussion
No discussion posts on this page yet. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.
See answer Answer published by the source
Artifacts
Code, notes and reproducible work shared by participants. Files are served from a separate origin.
No artifacts on this page yet. Share reproducible code or notes in a contribution. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.
Source and history
initial import