What can cause a numerical simulation in C code to misbehave?
For example I a certain behaviour with a set of parameters.
Then, I change the stiffness of a spring or the value of damping (keeping then physically coherent) and I get a crazy response that don't correspond with the experimental results.
I use double instead of float and none of the variable overflows.
What am I overlooking?
>>51806423
Bruh do you even dt
>>51806705
What do you mean by dt?
>What could cause a numerical simulation in C code to misbehave
Anything involving floating point arithmetic
Anything involving built in integer types that may overflow.
And just for further emphasis, do not use floating point arithmetic for anything that needs absolute accuracy.
Also, make sure you're not reading the wrong memory addresses. That could fuck things up too.
>>51807195
>And just for further emphasis, do not use floating point arithmetic for anything that needs absolute accuracy.
What do you recommend, then?
>>51806423
Try arbitrary precision integer / decimal maths only.
Do verlet integration
>>51806423
>What may cause C to throw a fit he asks...
What won't is the correct question.
Anyhow, before compiling, have you done at least the basics? Prayed to assembly jesus? Sacrificed 3 ram sticks to the dark gods and install win10 on a sacrificial goat of a friend's pc?
If not wtf man?
>>51807376
He mistakenly installed win10 on his own computer and a NSA indian underage faggot acessed his code, and changed some variables thus resulting on a catastrophic error on his physics engine.
>>51807195
I am usind double precision (double) so the rounding errors should have a negligible influence (the operations don't always deal with *very* close values)
>make sure you're not reading the wrong memory addresses
My code is just additions multiplications and divisions of doubles. I don't think the mistake is hiding behind this point.
>>51807261
Verlet integration uses central difference (so the value at the step k+1, which is not yet computed). But I have a very small sampling time so I think Euler might do the job.
>>51807376
>Anyhow, before compiling, have you done at least the basics? I run some experiments already. The code seems to work when implemented on a micro controller but the same operations when asked to interact with a virtual environment (the simulation) is shitting the bed.
I use linux (ubuntu) and gcc to compile.
>>51807504
Consider using GNU emacs
>>51807504
If you can share the code I'll look at it. If you can't the fuck off