Speaking of 2nd-order linear ODEs w/ const factor (a.k.a. mass-spring-damper systems), I wrote a blog post[0] deriving all possible general solutions in a concise matrix that makes it easily implementable in code.
The following is the complete solution in Lua:
function sprung_response(t,pos,vel,k,c,m)
local decay = c/2/m
local omega = math.sqrt(k/m)
local resid = decay*decay-omega*omega
local scale = math.sqrt(math.abs(resid))
local T1,T0 = t , 1
if resid<0 then
T1,T0 = math.sin( scale*t)/scale , math.cos( scale*t)
elseif resid>0 then
T1,T0 = math.sinh(scale*t)/scale , math.cosh(scale*t)
end
local dissipation = math.exp(-decay*t)
local evolved_pos = dissipation*( pos*(T0+T1*decay) + vel*( T1 ) )
local evolved_vel = dissipation*( pos*(-T1*omega^2) + vel*(T0-T1*decay) )
return evolved_pos , evolved_vel
end
[0] https://esporttoys.pages.dev/2022/11/21/damped
This is a good example. That was math heavy, it took me too long to parse for basic understanding and honestly I am not sure I got it right. The LUA code was easy to understand even though those variable names force you to read all the code, and guess what is what.
It has been a long time since I did diff eq at work, and I agree with the PDF the more I knew the less I understood. I dont know why I need to have the math tainted by the unclean reality to understand, and if that hinders my understanding of them.
My grad school was basically working through F=Ma-Cv-Kx in all it's expanding varied glory, working up to full blown finite element analysis.
Ultimately it all comes down to choosing the most convenient basis functions for the questions you're answering.
> My grad school was basically working through F=Ma-Cv-Kx in all it's expanding varied glory, working up to full blown finite element analysis.
If I'm understanding correctly, you want another = there for a standard damped spring: F = ma = -Cv - Kx.
F is a forcing function, not the resultant force. It’s often arranged this way with all the derivatives on one side (as opposed to having the resultant force, ma, on one side of the equality by itself) so that it matches the general form of a non-homogeneous second-order linear differential equation.
(At least I assume this is what the original commenter meant!).
Ah, that makes more sense. Thanks!