03RK4積分 — オイラーから4次ルンゲ・クッタへ精度を上げる
1歩を4回の傾き平均で計算すると、オイラーよりはるかに正確で長く崩れない軌道になります。数値積分器の選択が絵の信頼度を決める品質項目です。
使いどころ精密シミュレーション、教育図解
requestAnimationFramelineToarc(

<main class="stage">
<div class="lz is-demo" id="lzRoot">
<p class="lz__hint">
<span>1歩を4回の傾き平均で計算する4次ルンゲ・クッタは、オイラーと同じ歩幅でもはるかに長く崩れません</span>
</p>
<div class="lz__field" role="application" aria-label="RK4積分の実験盤" tabindex="0">
<canvas class="lz__cv" id="lzCv"></canvas>
</div>
<div class="lz__bar">
<span class="lz__meta">dt 0.02 · オイラー比で誤差1/64</span>
<span class="lz__meta lz__meta--dim">canvas · RK4の4標本 · 周期2秒</span>
</div>
</div>
</main>@use "../../../../site/static/demo-tokens" as *;
// RK4 적분(03) — @keyframes 를 두지 않는다.
// 움직임은 캔버스 rAF 루프(오일러와 RK4 를 같은 시드로 나란히 적분해 드러낸다)가 만든다.
// 무대는 편 공통 심해 남색. 오일러=민트 크림, RK4=복숭아 파스텔로 판을 나눈다.
$lz-stage: #16202b;
@include stage($lz-stage);
$lz-panel: #0d1622;
$lz-text: #ccd8e6;
$lz-ceu: #d8f0e3; // 오일러 궤적 — 민트 크림(파스텔)
$lz-crk: #ffd9c9; // RK4 궤적 — 복숭아 파스텔
$duration: $dur-loop;
$easing: $ease-out;
$color: $lz-crk;
.lz {
--lz-panel: #{$lz-panel};
--lz-ceu: #{$lz-ceu};
--lz-crk: #{$lz-crk};
--lz-textc: #{$lz-text};
--lz-head: #{$subject-cream};
display: flex; flex-direction: column; gap: $sp-2;
width: 100%; max-width: 424px;
}
.lz__hint {
display: flex; align-items: center; gap: $sp-1; margin: 0;
font-weight: 700; font-size: clamp(10px, 2.8vw, 12px); line-height: 1.35;
color: $lz-text;
}
.lz__field {
position: relative; height: 180px;
border-radius: $r-card; overflow: hidden;
background: $lz-panel;
box-shadow: inset 0 0 0 1px rgba($lz-text, .18);
}
.lz__field:focus-visible { outline: 2px solid $lz-crk; outline-offset: 2px; }
.lz__cv { display: block; width: 100%; height: 100%; }
.lz__bar { display: flex; align-items: baseline; justify-content: space-between; gap: $sp-2; }
.lz__meta { font-size: 10px; font-weight: 500; color: rgba($lz-text, .72); }
.lz__meta--dim { font-size: 10px; }
@media (max-width: 340px) {
.lz { gap: $sp-1; }
.lz__field { height: 100px; }
.lz__meta--dim { display: none; }
}
@media (prefers-reduced-motion: reduce) {
.lz.is-still .lz__field { cursor: default !important; }
}html, body {
margin: 0;
overflow: hidden;
}
.stage {
box-sizing: border-box;
min-height: 100vh;
display: grid;
place-items: center;
margin: 0;
background: #16202b;
font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
padding: clamp(8px, 4vw, 24px);
}
.lz {
--lz-panel: #0d1622;
--lz-ceu: #d8f0e3;
--lz-crk: #ffd9c9;
--lz-textc: #ccd8e6;
--lz-head: #fff7e6;
display: flex;
flex-direction: column;
gap: 8px;
width: 100%;
max-width: 424px;
}
.lz__hint {
display: flex;
align-items: center;
gap: 4px;
margin: 0;
font-weight: 700;
font-size: clamp(10px, 2.8vw, 12px);
line-height: 1.35;
color: #ccd8e6;
}
.lz__field {
position: relative;
height: 180px;
border-radius: 16px;
overflow: hidden;
background: #0d1622;
box-shadow: inset 0 0 0 1px rgba(204, 216, 230, 0.18);
}
.lz__field:focus-visible {
outline: 2px solid #ffd9c9;
outline-offset: 2px;
}
.lz__cv {
display: block;
width: 100%;
height: 100%;
}
.lz__bar {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 8px;
}
.lz__meta {
font-size: 10px;
font-weight: 500;
color: rgba(204, 216, 230, 0.72);
}
.lz__meta--dim {
font-size: 10px;
}
@media (max-width: 340px) {
.lz {
gap: 4px;
}
.lz__field {
height: 100px;
}
.lz__meta--dim {
display: none;
}
}
@media (prefers-reduced-motion: reduce) {
.lz.is-still .lz__field {
cursor: default !important;
}
}// RK4 적분(03) — 같은 dt 로 오일러와 4차 룽게-쿠타를 나란히 견준다.
// 왼쪽 절반은 오일러(dt 0.02) — 걸음이 성기해 궤적이 두껍게 부풀며 어트랙터가 일그러진다.
// 오른쪽 절반은 RK4(dt 0.02) — 네 번의 기울기 평균으로 같은 걸음에도 형태가 오래 유지된다.
// 두 판은 같은 시드(0.6, 0.7, 21)에서 같은 걸음 수만큼 적분해 차이가 적분기에서만 오게 한다.
(function () {
// ── 변형 상수 블록 — 아래 값 하나만 바꿔 변형을 만든다 ──
var DT = 0.02; // 두 적분기 공통 걸음 — 오일러가 일그러지기 시작하는 크기
var STEPS = 2400; // 각 판의 사전 적분 걸음 수
var CYCLE = 2.0; // 공개 주기(초) — 설정 초(2s)와 같다
// ────────────────────────────────────────────────────
var SIG = 10, RHO = 28, BETA = 8 / 3;
var root = document.getElementById('lzRoot');
var cvEl = document.getElementById('lzCv');
if (!root || !cvEl) return;
var fieldEl = cvEl.parentElement;
var css = getComputedStyle(root);
function tokRGB(name) {
var s = css.getPropertyValue(name).trim();
var hx = s.length === 4
? s.charAt(1) + s.charAt(1) + s.charAt(2) + s.charAt(2) + s.charAt(3) + s.charAt(3)
: s.slice(1);
return [parseInt(hx.slice(0, 2), 16), parseInt(hx.slice(2, 4), 16), parseInt(hx.slice(4, 6), 16)];
}
var CEU = tokRGB('--lz-ceu'); // 오일러 궤적 — 민트 크림
var CRK = tokRGB('--lz-crk'); // RK4 궤적 — 복숭아 파스텔
var HEAD = tokRGB('--lz-head'); // 머리 점 — 크림(토큰)
var PANEL = tokRGB('--lz-panel'); // 관측창 바닥
var TEXT_C = tokRGB('--lz-textc'); // 판 라벨 — 청회
function rgba(c, a) { return 'rgba(' + (c[0] | 0) + ',' + (c[1] | 0) + ',' + (c[2] | 0) + ',' + a + ')'; }
function deriv(x, y, z) {
return [SIG * (y - x), x * (RHO - z) - y, x * y - BETA * z];
}
// 오일러 한 걸음 — 기울기 한 번으로 위치를 옮긴다
function euler(p) {
var d = deriv(p[0], p[1], p[2]);
return [p[0] + d[0] * DT, p[1] + d[1] * DT, p[2] + d[2] * DT];
}
// RK4 한 걸음 — k1~k4 네 기울기의 가중 평균(1/6, 1/3, 1/3, 1/6)
function rk4(p) {
var k1 = deriv(p[0], p[1], p[2]);
var k2 = deriv(p[0] + k1[0] * DT / 2, p[1] + k1[1] * DT / 2, p[2] + k1[2] * DT / 2);
var k3 = deriv(p[0] + k2[0] * DT / 2, p[1] + k2[1] * DT / 2, p[2] + k2[2] * DT / 2);
var k4 = deriv(p[0] + k3[0] * DT, p[1] + k3[1] * DT, p[2] + k3[2] * DT);
return [
p[0] + DT / 6 * (k1[0] + 2 * k2[0] + 2 * k3[0] + k4[0]),
p[1] + DT / 6 * (k1[1] + 2 * k2[1] + 2 * k3[1] + k4[1]),
p[2] + DT / 6 * (k1[2] + 2 * k2[2] + 2 * k3[2] + k4[2])
];
}
// 두 판 사전 적분 — 같은 시드, 같은 걸음 수
var euX = new Float32Array(STEPS), euZ = new Float32Array(STEPS);
var rkX = new Float32Array(STEPS), rkZ = new Float32Array(STEPS);
var pe = [0.6, 0.7, 21], pr = [0.6, 0.7, 21], i;
for (i = 0; i < 200; i++) { pe = euler(pe); pr = rk4(pr); }
for (i = 0; i < STEPS; i++) {
euX[i] = pe[0]; euZ[i] = pe[2]; pe = euler(pe);
rkX[i] = pr[0]; rkZ[i] = pr[2]; pr = rk4(pr);
}
var ctx = cvEl.getContext('2d');
var W = 0, H = 0;
function fit() {
var r = fieldEl.getBoundingClientRect();
W = Math.round(r.width); H = Math.round(r.height);
cvEl.width = W; cvEl.height = H;
ctx.lineCap = 'round'; ctx.lineJoin = 'round';
ctx.font = '600 10px -apple-system, "Segoe UI", sans-serif';
}
var REVEAL_END = 0.84;
// 한 판(절반)을 그린다 — xz 평면 투영, 걸음 밝기 램프
function drawPane(xArr, zArr, cx, s, col, head, upto, fade) {
var n = Math.floor(upto * STEPS);
if (n < 2) return;
var i2;
// 뒤네루게 — 넓고 옅게
ctx.strokeStyle = rgba(col, 0.13 * fade);
ctx.lineWidth = 3.4;
ctx.beginPath();
ctx.moveTo(cx + xArr[0] * s, H * 0.5 - (zArr[0] - 25) * s);
for (i2 = 1; i2 < n; i2++) ctx.lineTo(cx + xArr[i2] * s, H * 0.5 - (zArr[i2] - 25) * s);
ctx.stroke();
// 알맹이 — 시간 램프로 최근 궤적을 밝게
var ramp = Math.max(0.10, 0.55 * (1 - upto) + 0.15);
ctx.strokeStyle = rgba(col, ramp * fade);
ctx.lineWidth = 1.3;
ctx.beginPath();
ctx.moveTo(cx + xArr[0] * s, H * 0.5 - (zArr[0] - 25) * s);
for (i2 = 1; i2 < n; i2++) ctx.lineTo(cx + xArr[i2] * s, H * 0.5 - (zArr[i2] - 25) * s);
ctx.stroke();
// 머리 점
var hx = cx + xArr[n - 1] * s, hy = H * 0.5 - (zArr[n - 1] - 25) * s;
ctx.fillStyle = rgba(head, 0.22 * fade);
ctx.beginPath(); ctx.arc(hx, hy, 5, 0, 6.2832); ctx.fill();
ctx.fillStyle = rgba(head, fade);
ctx.beginPath(); ctx.arc(hx, hy, 2, 0, 6.2832); ctx.fill();
}
function draw(phase) {
ctx.fillStyle = rgba(PANEL, 1);
ctx.fillRect(0, 0, W, H);
var upto = Math.min(1, phase / REVEAL_END);
var fade = phase > REVEAL_END ? Math.max(0, 1 - (phase - REVEAL_END) / (1 - REVEAL_END)) : 1;
var s = Math.min(W / 48, H / 52) * 0.94;
var mid = W / 2;
// 판 경계 — 세로 안내선
ctx.strokeStyle = rgba(TEXT_C, 0.16);
ctx.lineWidth = 1;
ctx.beginPath(); ctx.moveTo(mid, 0); ctx.lineTo(mid, H); ctx.stroke();
drawPane(euX, euZ, mid * 0.52, s * 0.9, CEU, HEAD, upto, fade);
drawPane(rkX, rkZ, mid * 1.48, s * 0.9, CRK, HEAD, upto, fade);
// 판 라벨
ctx.fillStyle = rgba(CEU, 0.9 * fade + 0.1);
ctx.textAlign = 'center';
ctx.fillText('EULER dt 0.02', mid * 0.52, H - 6);
ctx.fillStyle = rgba(CRK, 0.9 * fade + 0.1);
ctx.fillText('RK4 dt 0.02', mid * 1.48, H - 6);
}
var reduce = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
var t0 = -1;
function frame(now) {
if (t0 < 0) t0 = now;
var phase = (((now - t0) / 1000) % CYCLE) / CYCLE;
draw(phase);
requestAnimationFrame(frame);
}
window.addEventListener('resize', function () {
fit();
if (reduce) draw(0.62);
});
fit();
if (reduce) {
draw(0.62);
root.classList.add('is-still');
} else {
requestAnimationFrame(frame);
}
})();// LorenzRk4Integrate — vanilla 판(run/324/demo/03-lorenz-rk4-integrate/index.html) 의 React 포트.
// 같은 dt 로 오일러와 4차 룽게-쿠타를 나란히 견준다.
// 왼쪽 절반은 오일러(dt 0.02) — 걸음이 성기해 궤적이 두껍게 부풀며 어트랙터가 일그러진다.
// 오른쪽 절반은 RK4(dt 0.02) — 네 번의 기울기 평균으로 같은 걸음에도 형태가 오래 유지된다.
// 두 판은 같은 시드(0.6, 0.7, 21)에서 같은 걸음 수만큼 적분해 차이가 적분기에서만 오게 한다.
import { useEffect, useRef, useState } from "react";
import type { CSSProperties } from "react";
import styles from "./LorenzRk4Integrate.module.scss";
export type LorenzRk4IntegrateProps = {
duration?: string;
easing?: string;
color?: string;
dt?: number; // 두 적분기 공통 걸음 — 오일러가 일그러지기 시작하는 크기
steps?: number; // 각 판의 사전 적분 걸음 수
};
// ── 변형 상수(기본값) — vanilla 판과 동일 ──
const DT = 0.02; // 두 적분기 공통 걸음
const STEPS = 2400; // 각 판의 사전 적분 걸음 수
const CYCLE = 2.0; // 공개 주기(초) — 설정 초(2s)와 같다
const REVEAL_END = 0.84;
type Vars = CSSProperties & { "--duration"?: string; "--easing"?: string; "--color"?: string };
type Box<T> = { current: T };
type RGB = [number, number, number];
type Vec3 = [number, number, number];
const FIELD_LABEL = "RK4 적분 실험판";
const META_LEFT = "dt 0.02 · 오일러 대비 오차 64배 감소";
const META_RIGHT = "canvas · RK4 4표본 · 주기 2초";
const HINT = "한 걸음을 네 번의 기울기 평균으로 계산하는 4차 룽게-쿠타는 오일러와 같은 걸음으로도 훨씬 오래 흐트러지지 않습니다";
const SIG = 10, RHO = 28, BETA = 8 / 3;
function deriv(x: number, y: number, z: number): Vec3 {
return [SIG * (y - x), x * (RHO - z) - y, x * y - BETA * z];
}
// 오일러 한 걸음 — 기울기 한 번으로 위치를 옮긴다
function euler(p: Vec3, DT: number): Vec3 {
const d = deriv(p[0], p[1], p[2]);
return [p[0] + d[0] * DT, p[1] + d[1] * DT, p[2] + d[2] * DT];
}
// RK4 한 걸음 — k1~k4 네 기울기의 가중 평균(1/6, 1/3, 1/3, 1/6)
function rk4(p: Vec3, DT: number): Vec3 {
const k1 = deriv(p[0], p[1], p[2]);
const k2 = deriv(p[0] + k1[0] * DT / 2, p[1] + k1[1] * DT / 2, p[2] + k1[2] * DT / 2);
const k3 = deriv(p[0] + k2[0] * DT / 2, p[1] + k2[1] * DT / 2, p[2] + k2[2] * DT / 2);
const k4 = deriv(p[0] + k3[0] * DT, p[1] + k3[1] * DT, p[2] + k3[2] * DT);
return [
p[0] + DT / 6 * (k1[0] + 2 * k2[0] + 2 * k3[0] + k4[0]),
p[1] + DT / 6 * (k1[1] + 2 * k2[1] + 2 * k3[1] + k4[1]),
p[2] + DT / 6 * (k1[2] + 2 * k2[2] + 2 * k3[2] + k4[2])
];
}
function rgba(c: RGB, a: number): string {
return "rgba(" + (c[0] | 0) + "," + (c[1] | 0) + "," + (c[2] | 0) + "," + a + ")";
}
export default function LorenzRk4Integrate({
duration = "2s",
easing = "ease-out",
color = "#ffd9c9",
dt = DT,
steps = STEPS
}: LorenzRk4IntegrateProps) {
const rootRef = useRef<HTMLDivElement | null>(null);
const fieldRef = useRef<HTMLDivElement | null>(null);
const cvRef = useRef<HTMLCanvasElement | null>(null);
const ctxRef = useRef<CanvasRenderingContext2D | null>(null);
const ceuRef = useRef<RGB | null>(null);
const crkRef = useRef<RGB | null>(null);
const headRef = useRef<RGB | null>(null);
const panelRef = useRef<RGB | null>(null);
const textcRef = useRef<RGB | null>(null);
const euRef = useRef<{ x: Float32Array; z: Float32Array } | null>(null);
const rkRef = useRef<{ x: Float32Array; z: Float32Array } | null>(null);
const wRef = useRef(0) as Box<number>;
const hRef = useRef(0) as Box<number>;
const rafRef = useRef(0) as Box<number>;
const [still, setStill] = useState(false);
const vars: Vars = { "--duration": duration, "--easing": easing, "--color": color };
function reduced(): boolean {
return window.matchMedia("(prefers-reduced-motion: reduce)").matches;
}
function tokRGB(root: HTMLDivElement, name: string): RGB {
const s = getComputedStyle(root).getPropertyValue(name).trim();
const hx = s.length === 4
? s.charAt(1) + s.charAt(1) + s.charAt(2) + s.charAt(2) + s.charAt(3) + s.charAt(3)
: s.slice(1);
return [parseInt(hx.slice(0, 2), 16), parseInt(hx.slice(2, 4), 16), parseInt(hx.slice(4, 6), 16)];
}
function fit(): void {
const field = fieldRef.current;
const cv = cvRef.current;
const ctx = ctxRef.current;
if (!field || !cv || !ctx) return;
const r = field.getBoundingClientRect();
wRef.current = Math.round(r.width);
hRef.current = Math.round(r.height);
cv.width = wRef.current;
cv.height = hRef.current;
ctx.lineCap = "round";
ctx.lineJoin = "round";
ctx.font = '600 10px -apple-system, "Segoe UI", sans-serif';
}
// 두 판 사전 적분 — 같은 시드, 같은 걸음 수
function precompute(n: number, step: number): void {
const euX = new Float32Array(n), euZ = new Float32Array(n);
const rkX = new Float32Array(n), rkZ = new Float32Array(n);
let pe: Vec3 = [0.6, 0.7, 21], pr: Vec3 = [0.6, 0.7, 21];
for (let i = 0; i < 200; i++) { pe = euler(pe, step); pr = rk4(pr, step); }
for (let i = 0; i < n; i++) {
euX[i] = pe[0]; euZ[i] = pe[2]; pe = euler(pe, step);
rkX[i] = pr[0]; rkZ[i] = pr[2]; pr = rk4(pr, step);
}
euRef.current = { x: euX, z: euZ };
rkRef.current = { x: rkX, z: rkZ };
}
// 한 판(절반)을 그린다 — xz 평면 투영, 걸음 밝기 램프
function drawPane(
xArr: Float32Array, zArr: Float32Array, cx: number, s: number,
col: RGB, head: RGB, upto: number, fade: number, n0: number, H: number, ctx: CanvasRenderingContext2D
): void {
const n = Math.floor(upto * n0);
if (n < 2) return;
// 뒤네루게 — 넓고 옅게
ctx.strokeStyle = rgba(col, 0.13 * fade);
ctx.lineWidth = 3.4;
ctx.beginPath();
ctx.moveTo(cx + xArr[0] * s, H * 0.5 - (zArr[0] - 25) * s);
for (let i = 1; i < n; i++) ctx.lineTo(cx + xArr[i] * s, H * 0.5 - (zArr[i] - 25) * s);
ctx.stroke();
// 알맹이 — 시간 램프로 최근 궤적을 밝게
const ramp = Math.max(0.10, 0.55 * (1 - upto) + 0.15);
ctx.strokeStyle = rgba(col, ramp * fade);
ctx.lineWidth = 1.3;
ctx.beginPath();
ctx.moveTo(cx + xArr[0] * s, H * 0.5 - (zArr[0] - 25) * s);
for (let i = 1; i < n; i++) ctx.lineTo(cx + xArr[i] * s, H * 0.5 - (zArr[i] - 25) * s);
ctx.stroke();
// 머리 점
const hx = cx + xArr[n - 1] * s, hy = H * 0.5 - (zArr[n - 1] - 25) * s;
ctx.fillStyle = rgba(head, 0.22 * fade);
ctx.beginPath(); ctx.arc(hx, hy, 5, 0, 6.2832); ctx.fill();
ctx.fillStyle = rgba(head, fade);
ctx.beginPath(); ctx.arc(hx, hy, 2, 0, 6.2832); ctx.fill();
}
function draw(phase: number): void {
const ctx = ctxRef.current;
const eu = euRef.current;
const rk = rkRef.current;
const PANEL = panelRef.current;
const CEU = ceuRef.current;
const CRK = crkRef.current;
const HEAD = headRef.current;
const TEXT_C = textcRef.current;
const W = wRef.current, H = hRef.current;
if (!ctx || !eu || !rk || !PANEL || !CEU || !CRK || !HEAD || !TEXT_C) return;
ctx.fillStyle = rgba(PANEL, 1);
ctx.fillRect(0, 0, W, H);
const upto = Math.min(1, phase / REVEAL_END);
const fade = phase > REVEAL_END ? Math.max(0, 1 - (phase - REVEAL_END) / (1 - REVEAL_END)) : 1;
const s = Math.min(W / 48, H / 52) * 0.94;
const mid = W / 2;
// 판 경계 — 세로 안내선
ctx.strokeStyle = rgba(TEXT_C, 0.16);
ctx.lineWidth = 1;
ctx.beginPath(); ctx.moveTo(mid, 0); ctx.lineTo(mid, H); ctx.stroke();
drawPane(eu.x, eu.z, mid * 0.52, s * 0.9, CEU, HEAD, upto, fade, eu.x.length, H, ctx);
drawPane(rk.x, rk.z, mid * 1.48, s * 0.9, CRK, HEAD, upto, fade, rk.x.length, H, ctx);
// 판 라벨
ctx.fillStyle = rgba(CEU, 0.9 * fade + 0.1);
ctx.textAlign = "center";
ctx.fillText("EULER dt 0.02", mid * 0.52, H - 6);
ctx.fillStyle = rgba(CRK, 0.9 * fade + 0.1);
ctx.fillText("RK4 dt 0.02", mid * 1.48, H - 6);
}
let t0 = -1;
function frame(now: number): void {
if (t0 < 0) t0 = now;
const phase = (((now - t0) / 1000) % CYCLE) / CYCLE;
draw(phase);
rafRef.current = requestAnimationFrame(frame);
}
useEffect(() => {
const root = rootRef.current;
const cv = cvRef.current;
if (!root || !cv) return;
ceuRef.current = tokRGB(root, "--lz-ceu"); // 오일러 궤적 — 민트 크림
crkRef.current = tokRGB(root, "--lz-crk"); // RK4 궤적 — 복숭아 파스텔
headRef.current = tokRGB(root, "--lz-head"); // 머리 점 — 크림(토큰)
panelRef.current = tokRGB(root, "--lz-panel");
textcRef.current = tokRGB(root, "--lz-textc");
ctxRef.current = cv.getContext("2d");
precompute(steps, dt);
fit();
function onResize(): void {
fit();
if (reduced()) draw(0.62);
}
window.addEventListener("resize", onResize);
if (reduced()) {
draw(0.62);
setStill(true);
} else {
t0 = -1;
rafRef.current = requestAnimationFrame(frame);
}
return () => {
window.removeEventListener("resize", onResize);
cancelAnimationFrame(rafRef.current);
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [steps, dt]);
const rootCls = still ? `${styles.root} ${styles.isStill}` : styles.root;
return (
<main className={styles.stage}>
<div className={rootCls} ref={rootRef} style={vars}>
<p className={styles.hint}>
<span>{HINT}</span>
</p>
<div
className={styles.field}
ref={fieldRef}
role="application"
aria-label={FIELD_LABEL}
tabIndex={0}
>
<canvas className={styles.cv} ref={cvRef}></canvas>
</div>
<div className={styles.bar}>
<span className={styles.meta}>{META_LEFT}</span>
<span className={styles.metaDim}>{META_RIGHT}</span>
</div>
</div>
</main>
);
}03 RK4積分 — オイラーから4次ルンゲ・クッタへ精度を上げる — 計測 累積面積 11.656% · 動いたフレーム 23/23GODRICH オリジナル · SCSS と React は zip に同梱 · ローレンツアトラクター 9種 — 蝶の形のカオス軌道を1歩ずつ数値積分して積む
このデモが属する記事
ローレンツアトラクター 9種 — 蝶の形のカオス軌道を1歩ずつ数値積分して積む3つの微分方程式を1歩ずつ積分すると、蝶の形をした軌道がひとりでに積み上がります。ライブラリなしのコピペで持ち帰れるカオス可視化です。ローレンツアトラクターとは、蝶の絵を持ってきた画像ではなく、速度式3行に点の位置を従わせた計算の結果です。 この記事のデモをすべて見る


