32 bit or 64 bit?

R

ram.rachum

I have a physical system set up in which a body is supposed to
accelerate and to get very close to lightspeed, while never really
attaining it. After approx. 680 seconds, Python gets stuck and tells
me the object has passed lightspeed. I put the same equations in
Mathematica, again I get the same mistake around 680 seconds. So I
think, I have a problem with my model! Then I pump up the
WorkingPrecision in Mathematica to about 10. I run the same equations
again, and it works! At least for the first 10,000 seconds, the object
does not pass lightspeed.
I concluded that I need Python to work at a higher precision.

I conclude that your algorithm is numerical wrong. It probably suffers
from a rounding error which increases itself in every iteration.
Increasing the precision doesn't solve your problem. It's only going to
hide the fact that your algorithm doesn't do its job.

Please don't get me wrong. I don't want to imply that you are an idiot
who doesn't know what he is doing. :] Most likely you weren't taught how
to write numerical sound algorithms. Let's all blame your school or
university. *g*

Numerics is a complex area and it took me more than a year to learn the
basics. Don't be embarrassed!

I'll try to read some. But I used mpmath to pump up the precision in
my code, and now the problem doesn't happen. So I think it's okay for
now.
 
R

ram.rachum

I conclude that your algorithm is numerical wrong. It probably suffers
from a rounding error which increases itself in every iteration.
Increasing the precision doesn't solve your problem. It's only going to
hide the fact that your algorithm doesn't do its job.
Please don't get me wrong. I don't want to imply that you are an idiot
who doesn't know what he is doing. :] Most likely you weren't taught how
to write numerical sound algorithms. Let's all blame your school or
university. *g*
Numerics is a complex area and it took me more than a year to learn the
basics. Don't be embarrassed!

I'll try to read some. But I used mpmath to pump up the precision in
my code, and now the problem doesn't happen. So I think it's okay for
now.

Thanks to all contributors for your advice.

Ram Rachum.
 
R

ram.rachum

You need to change your representation.  Try redoing the algebra using
(c-v) as the independent variable, and calculate that.

Cheers,

Phil Hobbs

That was suggested. Problem is, that sometimes the velocities are near
zero. So this solution, by itself, is not general enough.
 
R

Richard Brodie

That was suggested. Problem is, that sometimes the velocities are near
zero. So this solution, by itself, is not general enough.

Maybe working in p, and delta-p would be more stable.
 
R

ram.rachum

Maybe working in p, and delta-p would be more stable.

That's a good one. It will, however, involve complicated calculations
for obtaining v from p, so it might be slower than mpmath. I'll
consider it.
 
R

ram.rachum

(e-mail address removed) wrote: [snip]
I have a physical system set up in which a body is supposed to
accelerate and to get very close to lightspeed, while never really
attaining it. After approx. 680 seconds, Python gets stuck and tells
me the object has passed lightspeed. I put the same equations in
Mathematica, again I get the same mistake around 680 seconds. So I
think, I have a problem with my model! Then I pump up the
WorkingPrecision in Mathematica to about 10. I run the same equations
again, and it works! At least for the first 10,000 seconds, the object
does not pass lightspeed.
I concluded that I need Python to work at a higher precision.
[snip]
You need to change your representation.  Try redoing the algebra using
(c-v) as the independent variable, and calculate that.

Or represent the velocity as c*tanh(b), where b is the independent
variable.  If memory serves, this is the representation in which
constant acceleration corresponds to db/dt = constant.

See my comment to Brodie.
 
R

ram.rachum

Are you sure?  I sort of doubt that you're spending zillions of
iterations getting closer and closer to zero.   It would be worth
actually doing the error analysis and finding out.

Cheers,

Phil Hobbs


See my comment to Brodie.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top