<Majiir>
Is there any way, even if it has to be a specialized application, to figure out what h to use without doing all that guessing?
<egg|laptop|egg>
Majiir: btw, you may have heard the incantation "RK4", that's just a particular fixed-step one-step method (of the Runge-Kutta kind, and developped by Runge and Kutta), of fourth order. It's kind of meh, but common. back to the eggsplanation
<SnoopJeDi>
Domain knowledge always helps, Majiir
<egg|laptop|egg>
Majiir: well, you can sort of try heuristics depending on your problem, but it's hard to get something good
<Majiir>
How would I apply domain knowledge in, say, orbital mechanics (seeing as egg has that knowledge) to do that?
<egg|laptop|egg>
Majiir: but the *magically* above is well-understood
<egg|laptop|egg>
and works well
<egg|laptop|egg>
so I do that for the predictions, rather than applying orbital-mechanics specific stuff
<egg|laptop|egg>
because, well, the general algorithms work well enough so that's what people use
<egg|laptop|egg>
Majiir: now, there are several ways to go about the *magically*
<egg|laptop|egg>
one method is to integrate with the same method two steps at h/2 and one at h
<kmath_>
<eggleroy> a while ago @whitequark mentioned "the goddamn numerical blowup in nbody" apropos KSP; the plight of Bop shows that: https://t.co/JGlyKsd6AK
<egg|laptop|egg>
Majiir: Eggsploratory!
<egg|laptop|egg>
Majiir: so in general, you can eggspect things like embedded RK to work well
<egg|laptop|egg>
unless you encounter stiffness
<egg|laptop|egg>
then things are evil
<Majiir>
Just to recap so my simple brain can chew on this
<egg|laptop|egg>
chomp
<egg|laptop|egg>
chomp chomp
<Majiir>
Let's say I wanted to model a spherical object falling through an infinite uniform atmopshere
<Majiir>
atmosphere, even
<Majiir>
Eventually, no matter what its initial velocity, it's going to basically just be falling down at terminal velocity
<Majiir>
I would love for that to approach zero processing power per unit time
<egg|laptop|egg>
I think that should?
<Majiir>
It sounds like I can do this with an adaptive step size since eventually, numerical issues aside, all integrators are going to just kinda shrug and give me the same result: it's going down.
<egg|laptop|egg>
Majiir: methods of order k have the property that they solve exactly a problem whose solution is a polynomial of order k
<Majiir>
Neat
<Majiir>
Now the solution might not be polynomial here, but with enough floating point error it might eventually become that? :D
<egg|laptop|egg>
in a way you can see them as fitting a polynomial to the trajectory
<egg|laptop|egg>
Majiir: well, when it reaches terminal velocity, it's a line
<Majiir>
Yep
<egg|laptop|egg>
you hardly get lower-order than that
<egg|laptop|egg>
Euler is exact on that
<SnoopJeDi>
yea, you can think of numerical solutions as basically a really convoluted fitting problem
<Majiir>
Does it ever *precisely* become a line?
<SnoopJeDi>
inasmuch as functions are vectors
<egg|laptop|egg>
SnoopJeDi: of course they are
<Majiir>
If I had a computer with infinite precision, would I be able to toss a ball sideways in this simulation and ever get a linear solution?
<egg|laptop|egg>
hmm
<Majiir>
My impression is no, if we're talking simple drag equation sort of stuff
<egg|laptop|egg>
ferram4: is terminal velocity reached in finite time in that ideal case
<Majiir>
but my horizontal velocity will be so small that eventually I get what I want anyway regardless: the integration step just gets huge
<ferram4>
Terminal velocity is never reached in finite time in a uniform atmosphere.
<ferram4>
It is approached asymptotic
<egg|laptop|egg>
Majiir: but then that's because your solution isn't a line, your asymptotic cost will go down fast
<Majiir>
Yep
<egg|laptop|egg>
so your step will be finite in proportion of the nonfinite time to terminal velocity
<egg|laptop|egg>
where proportion here is sloppy and loose
<egg|laptop|egg>
but hey
<egg|laptop|egg>
it's ten to two I can be imprecise
<ferram4>
In a non-uniform atmosphere and with non-uniform gravity it will become even worse. :P
<Majiir>
This has been very helpful! I haven't dived into the maths as deeply as you all, but this is exactly what I was looking for
<Majiir>
I am trying to size up how much maths I will need to learn for a project
<Majiir>
It sounds like not taking differential equations in college was a big mistake
<egg|laptop|egg>
Majiir: now I would like to point out a fun thing.
<SnoopJeDi>
the upshot is that any course in differential equations is mostly "here are all the tricks in the bag" anyway
<egg|laptop|egg>
you mentioned initially the very naive approach (let's call it the shitty game engine method) of doing physics
<SnoopJeDi>
Verlet integration?
<egg|laptop|egg>
SnoopJeDi: nah, that's the point I want to make
<egg|laptop|egg>
that's a bit confusing because I'm half-functional in my writing here
<Majiir>
I get the idea, I've seen this before
<egg|laptop|egg>
that's x += v dt; v += f(x, t) dt
<egg|laptop|egg>
leapfrog
<egg|laptop|egg>
or verlet
<egg|laptop|egg>
or Newton, it's in the principia
<egg|laptop|egg>
or Delambre
<egg|laptop|egg>
or Stoermer
<egg|laptop|egg>
ahem
<Majiir>
Hehe
icefire has joined #kspacademia
<egg|laptop|egg>
Majiir: it's good
<Majiir>
So the thing I'm concerned with most isn't accuracy -- not yet
<egg|laptop|egg>
well I mean it's 2nd order
<SnoopJeDi>
well, Verlet is distinct from leapfrog, the latter means you're updating the position and velocity (or whatever pair you like) at different times
<egg|laptop|egg>
better order than Euler's first
<Majiir>
It's more about minimizing computation, and also about deferring as much computation as possible
<egg|laptop|egg>
SnoopJeDi: they're used interchangeably in various parts of the literature
<SnoopJeDi>
There are many ways to be wrong, egg|laptop|egg ;P
<egg|laptop|egg>
SnoopJeDi: I will drown you in review articles
<Majiir>
I'm willing to accept typical game-physics levels of accuracy, and the systems I expect to model are fairly simple: basic drag models, that sort of thing
<egg|laptop|egg>
Majiir: now, this has a very important property
<Majiir>
The core thing I'm trying to do is murder fixed timesteps very murderously
<egg|laptop|egg>
2nd order is neat and all
<egg|laptop|egg>
but this is symplectic
<SnoopJeDi>
The great thing about Verlet Majiir is that it's not really a big step up in complexity, and effectively no change in computational demand, but it gives you such nice stability
<egg|laptop|egg>
Majiir: this means that if you give it a pendulum that starts at rest 30 deg off from the vertical, it's not going to fly to 60 deg from the vertical as time goes on
<egg|laptop|egg>
which it would with Euler
<egg|laptop|egg>
Euler pumps energy into the system
<egg|laptop|egg>
this, over the long term, keeps energy sane
<egg|laptop|egg>
this is very very important
<ferram4>
And allows drag models to somehow cause velocities to increase in certain situations. O_o
<egg|laptop|egg>
ferram4: wheeee
<Majiir>
Can Verlet be applied to more sophisticated integrators as well, or is that typically part of the definition of the integrator?
<ferram4>
Majiir, just remember: fear the long timestep when you're dealing with drag. It is tempting, but sometimes the drag will send your projectile flying back at you faster than it started.
<egg|laptop|egg>
SnoopJeDi: I'd argue it's less code complexity if you don't require dense output on both v and x (or are ok with having one of them at half-steps)
<egg|laptop|egg>
Majiir: there are more sophisticated symplectic or conjugate symplectic integrators
<egg|laptop|egg>
Majiir: Principia has 37 of them
<egg|laptop|egg>
Majiir: however
<egg|laptop|egg>
sadly
<egg|laptop|egg>
tragically
<egg|laptop|egg>
horresco referens
<SnoopJeDi>
egg|laptop|egg, I meant algorithmic complexity anyhow, since code complexity is going to depend on the expressivity of your language, heh
<Majiir>
ferram4, I initially asked because I want to make the timestep long when I *can* and then very short when I *must* -- and I'm curious what techniques there are for that
<ferram4>
And symplecticity for drag: don't bother, you're basically ignoring the energy removed from drag anyway, so the error isn't that big a deal. Still not nice, but you've basically got a system (your object) that's constantly bleeding energy anyway.
<egg|laptop|egg>
that seems overly implementation-oriented and not aiming very far though
<egg|laptop|egg>
RK4 is meh :-p
<egg|laptop|egg>
and Majiir seems interested is things that border on researchy
* egg|laptop|egg
emerges from a sea of numerical integration papers
<Majiir>
I am interested in borderline researchy things, but really I'm trying to do my own research on a thing and I don't have all the foundational not-even-that-researchy stuff :D
<SnoopJeDi>
the two are not mutually exclusive
<egg|laptop|egg>
Majiir: yeah, feel free to ask me, I am very much into that sort of stuff
<Majiir>
Like I said, I'm trying to murder fixed timesteps very murderously. That's about all that's set in stone at this point, and the rest is hand-wavey ideas
<egg|laptop|egg>
Majiir: btw, I have 138 papers into my papers dir; most of them are principia-related
<egg|laptop|egg>
I am pretty much swimming in a sea of numerics papers
<SnoopJeDi>
papers dir D:
* SnoopJeDi
hugs EndNote
<Majiir>
My hunch is that murdering fixed timesteps murderously leads to a whole lot of computational advantages
<egg|laptop|egg>
Majiir: it does, but it breaks one of the very few hard guarantees that you can get in that field
<egg|laptop|egg>
it all depends on the sort of thing you want to do
<Majiir>
Yeah
<egg|laptop|egg>
if you're doing orbits, symplecticity is very attractive
<egg|laptop|egg>
because the truth is pretty much a cute Hamiltonian that you can pet
<Majiir>
So far I'm thinking games, and very particularly excluding the case of orbital simulation games
<egg|laptop|egg>
if you're in the ferram4 sector
<egg|laptop|egg>
well
<egg|laptop|egg>
that's madness
<egg|laptop|egg>
there's no Hamiltonian worth mentioning
<Majiir>
I figured if I tried to tackle orbit games I'd have to just become an egg anyway
<egg|laptop|egg>
no need to even try symplecticity
<egg|laptop|egg>
Majiir: well, only a part of egg
<egg|laptop|egg>
Majiir: a lot of my madness is just that I have strongly typed myself into many layers of insanity
<egg|laptop|egg>
which is good
<SnoopJeDi>
With games, it's usually best to just go do something
<egg|laptop|egg>
it catches bugs in that physicsy code all the time
<SnoopJeDi>
What you build usually sucks and you consider why and you learn a lot in the process
<egg|laptop|egg>
SnoopJeDi: nonsense
<egg|laptop|egg>
SnoopJeDi: it is good to get stuck building libraries
<Majiir>
SnoopJeDi, in this case I am not trying to write any particular game -- but what you say is true about software projects in general
<egg|laptop|egg>
for the fun lies in the writing of abstractions
<Majiir>
I'm trying to bound my problem a bit, because I've struggled to really develop the idea
<SnoopJeDi>
egg|laptop|egg, you are the local authority on writing libraries ;P
<SnoopJeDi>
I meant it is best to learn-by-doing with games
<Majiir>
I was half hoping egg would tell me that what I want is just impossible and here's a theorem proving it
<Majiir>
It's both fortunate and not that he gave me a solution instead :D
<SnoopJeDi>
You can read AABB articles all day long and not relaly "get" it
<egg|laptop|egg>
Majiir: I can show you my abstractions; they can help perhaps with understanding what is what
<Majiir>
show me ur abstractions gurl
<egg|laptop|egg>
hah
<ferram4>
Ultimately a lot of what you want exactly depends on what your requirements are... which are dependent on what you're trying to do.
<Majiir>
Yep
<Majiir>
This does help me figure out what to even think about tackling though
<ferram4>
Building an integrator is a lot like any other kind of engineering. :P
<egg|laptop|egg>
PDE man strikes again :D
<Majiir>
It's really helpful to know that fixed timesteps are necessary for simpl..simplececiticity that one
<ferram4>
And as a result, they all suck, just to different degrees. :P
<Majiir>
It stops me from going down the rabbit hole of trying to figure that out on my own :|
<egg|laptop|egg>
Majiir: yeah, it's a fun theorem, I can find you that paper
<ferram4>
Fortunately, this is math, and so things can be proven.
<egg|laptop|egg>
Majiir: oh note
<egg|laptop|egg>
DoublePrecision
<Majiir>
I really am imagining egg just drowning in a sea of papers
<ferram4>
Also, you have gotten the egg to throw papers at you, take cover.
e_14159 has quit [Ping timeout: 194 seconds]
<SnoopJeDi>
ferram4, which is, after all, just a specific application of Sturgeon's Law
<egg|laptop|egg>
your state is a DoublePrecision
<egg|laptop|egg>
this is Very Important
<egg|laptop|egg>
without compensated summation you will be engulfed by a tidal wave of roundoffs in long-time integration
<ferram4>
Nah, we can just simplify things to shorts. It'll be all good.
<Majiir>
^ that was my next question
<Majiir>
How does fixed-point do?
<Majiir>
(in general)
<Majiir>
...well, in general with integrators
<egg|laptop|egg>
it doesn't. Nobody does numerics in fixed point that I know of.
<Majiir>
And everybody uses fixed timesteps in game engines with shittygameintegration :D
<Majiir>
Is there a reason it's always floating-point?
<egg|laptop|egg>
Majiir: note that here, what happens is that lest you fuck up missing a compensated summation, the truncation error (from using an integrator rather than formal integration) will dominate FP error
<Majiir>
I understand what you are saying, but I don't follow why that's the case
<egg|laptop|egg>
so you use FP because it allows you fancy things like multiplying and understanding what comes out of that, and it's fast, and all glory to our dark Lord Kahan
<egg|laptop|egg>
Majiir: well
<egg|laptop|egg>
Majiir: I can only give you a conceptual wishywashy answer
<Majiir>
That's acceptable
<egg|laptop|egg>
if you multiply matrices, the operations you do, in infinite precision, give you the matrix product; exactly. It's a bit convoluted, and the convolutions are there to appease our Lord Kahan. But you're really multiplying matrices.
<egg|laptop|egg>
but if you integrate with a fixed step of finite size, and do your computation in infinite precision, then you get a shitty error
<egg|laptop|egg>
that you can estimate, and say "it's order k in the size of the step"
<egg|laptop|egg>
but still, you have an error
<egg|laptop|egg>
formally
<egg|laptop|egg>
even if you do it with reals that don't exist
<Majiir>
That makes 900% sense
<Majiir>
but how do we know those errors dominate?
<egg|laptop|egg>
because the steps are kinda large, compared to the sort of things that are FP errors :-p
<Majiir>
Haha okay
e_14159 has joined #kspacademia
<egg|laptop|egg>
or because we plot the thing, and we see where we hit the floor of FP
<Majiir>
That wasn't as uber cool mathy as I was hoping, but it works :D
<egg|laptop|egg>
and there, yes, what limits you is FP
<egg|laptop|egg>
but above that floor it behaves like the pretty theoretical polynomials
<Majiir>
So basically either you're bound by the integrator which you'd expect, or you're bound by FP which means your integrator is just super good anyway
<kmath_>
<eggleroy> Double-double sum vs. ill-conditioned compensated summation in multistep integrators: hitting the floor vs. going u… https://t.co/0C7k1P7sUm
* UmbralRaptor
puts the yxala to work on micronerva.
<egg|principia|egg>
UmbralRaptor: I am drowning in a sea of mad KSP reference frames and principia pointers in the boonies instead of drowning in a sea of papers
<egg|principia|egg>
can I go back to drowning in the sea of papers :'(
regex has joined #kspacademia
GreeningGalaxy has joined #kspacademia
GreeningGalaxy has quit [Quit: SIGNAL LOST]
Qboid has joined #kspacademia
* e_14159
hands egg|principia|egg a bunch of cluster software frameworks.
<kmath_>
<FakeUnicode> Accurate solar system model hurtling through space ⚵♁☄☿ ⚶ ♃♄☀♅♂︎ ♀︎⚴ ?⚳♆♇ ⚷ ⚶⚴♂︎♇ ♁♆?☿⛅ ⚳♀︎♅♄ ⚷ ♃⚵☄ ⚵ ♆☄ ♄ ♀︎♁⚴ ♂︎⚳ ♅♇☀?⚶♃ ⚷☿
<egg|principia|egg>
!u ♅
<Qboid>
U+2645 URANUS (♅)
<egg|principia|egg>
they're using the one with the Herschel monogram
<egg|principia|egg>
clearly the neptune one should be the LV >_>
<egg|principia|egg>
UmbralRaptor: you don't have a header image?
<egg|principia|egg>
something something spectra
<UmbralRaptor>
Maybe.
<soundnfury>
egg|principia|egg: that egg isn't drowning, it's _floating on_ a sea of papers.
<soundnfury>
(Apparently egg is less dense than paper)
* UmbralRaptor
? poorly defined wavelength cutoffs for typical magnitudes.
<egg|principia|egg>
soundnfury: you're seeing but a still frame! it sinks deeper at every wave of printouts
<soundnfury>
nonsense, the majority of its volume is above the papers
<soundnfury>
so as more papers are added, it will rise
<soundnfury>
(the egg shall rise again!)
<egg|principia|egg>
UmbralRaptor: hmm, try setting the theme colour to that of the egg in that picture, not sure if it looks good https://twitter.com/eggleroy
egg|principia|egg is now known as egg
<egg>
s/try/tried
<Qboid>
egg meant to say: also I am rather busy with trieding to update principia to 1.2 anyway
<egg>
uh wat
<egg>
right I /nicked
egg is now known as egg|zzz|egg
regex has quit [Remote host closed the connection]