← Main book chapter 10
Contents / index
Browser back
← Previous chapter
Next chapter →
Laboratory
Memory
Cards
Sort
Match
Visuals
Coding
Quiz
Programming practice
RK4 update — Chapter 10
Fix the RK4 weighted average.
Language:
JavaScript
Student code
function rk4(y,t,h,f){ const k1=f(t,y), k2=f(t+h/2,y+h*k1/2), k3=f(t+h/2,y+h*k2/2), k4=f(t+h,y+h*k3); return y+h*(k1+k2+k3+k4)/4; }
Check code
Show corrected code
Reset buggy code
Feedback
Corrected code