Editing
Equations, Formulas and Algorithms
(section)
From FusionGirl Wiki
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Runge-Kutta Methods == Runge-Kutta methods are numerical techniques for solving ordinary differential equations. They involve iterative procedures to approximate the solution trajectory of the differential equation over a specified time interval. Runge-Kutta methods are widely used in numerical simulations and scientific computing. '''Example: Runge-Kutta Method''' Consider the following ordinary differential equation: <math mode="display"> \frac{dy}{dt} = f(t, y) </math> where <math> y(t) </math> is the solution and <math> f(t, y) </math> is the derivative function. '''Source Code Example (Python):''' <syntaxhighlight lang="python"> import numpy as np # Define derivative function def f(t, y): return -y # Define initial conditions y0 = 1 t0 = 0 t_end = 10 dt = 0.1 # Initialize arrays to store solution t_values = [t0] y_values = [y0] # Runge-Kutta integration loop while t_values[-1] < t_end: t = t_values[-1] y = y_values[-1] k1 = f(t, y) k2 = f(t + dt/2, y + dt/2 * k1) k3 = f(t + dt/2, y + dt/2 * k2) k4 = f(t + dt, y + dt * k3) y_new = y + dt / 6 * (k1 + 2*k2 + 2*k3 + k4) t_values.append(t + dt) y_values.append(y_new) # Plot solution import matplotlib.pyplot as plt plt.plot(t_values, y_values) plt.xlabel('Time') plt.ylabel('Solution') plt.title('Runge-Kutta Method') plt.show() </syntaxhighlight>
Summary:
Please note that all contributions to FusionGirl Wiki are considered to be released under the Creative Commons Attribution (see
FusionGirl Wiki:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Page actions
Page
Discussion
Read
Edit
Edit source
History
Page actions
Page
Discussion
More
Tools
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Search
Tools
What links here
Related changes
Special pages
Page information