Timeline for Calculate position given velocity and acceleration at a given timestep
Current License: CC BY-SA 4.0
9 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jul 11, 2019 at 19:39 | comment | added | Danilo Souza Morães | Your code is really good and I learned a lot from it, but i focused more on the floating point precision of it than the actual integration part. But I see what you meant now. Thank you! | |
| Jul 11, 2019 at 18:18 | comment | added | Ocelot | @DaniloSouzaMorães you don't get it. Euler method precision depends on the amount of steps, which is what demonstrated in the code in the first place, floating point precision problem was described as a "bonus". | |
| Jul 11, 2019 at 18:00 | comment | added | Danilo Souza Morães | You dont get it. At 20 steps, both double and float precision result in 2.1 when the correct answer according to the displacement formula is 2. That 0.1 in error is due to the Euler method as Alex pointed out, not due to floating point precision. | |
| Jul 11, 2019 at 9:01 | comment | added | Ocelot | @DaniloSouzaMorães my answer does address that one, it's when we have 20 steps. And the explanation for that is literally the whole code, to show you that the error becomes smaller with the increasing amout of steps. But I guess I should have just linked a few wikipedia articles instead and called it a day. | |
| Jul 10, 2019 at 21:52 | comment | added | Danilo Souza Morães | My example clearly stated timestep = 0.1 as being one of the values I couldn't explain. You answer doesn't address that one. Single precision isn't the culprit for those values. It is a valuable answer nonetheless, hence the upvote. | |
| Jul 9, 2019 at 17:21 | history | edited | Ocelot | CC BY-SA 4.0 | More clean and detailed test code; added 48 characters in body |
| Jul 9, 2019 at 17:03 | comment | added | Ocelot | @DaniloSouzaMorães look closely at the code, first we calculate exact solution and output it first, then we increment steps three times which increases accuracy of the integration, and finally I show that in case of single precision floating point type, at extreme amount of steps happens huge error accumulation, which is not the case for double precision. | |
| Jul 8, 2019 at 23:09 | comment | added | Danilo Souza Morães | I think your example is not correct. s(20 steps): 2.100000 should have been 2.0 according to the displacement formula: s = u*t+0.5f*a*pow(t, 2.0f); where t=2 = s = 0*2 + 0.5f * 1.0 * pow(2, 2.0f) = 2.0; My question is exactly about that 0.1 at t = 2. Why is it 2.1 and not 2.0 as the formula correctly outputs? Notice there are no floating point errors at t=2; | |
| Jul 7, 2019 at 19:22 | history | answered | Ocelot | CC BY-SA 4.0 |