The Naked Scientists

The Naked Scientists Forum

Author Topic: Special Relativity Mass Calculator  (Read 7006 times)

Offline UltimateTheory

  • Sr. Member
  • ****
  • Posts: 107
  • Thanked: 1 times
    • View Profile
    • Ultimate Theory of the Universe
Special Relativity Mass Calculator
« on: 26/12/2012 08:46:37 »
Hello!

I have Christmas present to you:

on-line Special Relativity Mass Calculator

http://www.ultimate-theory.com/en/2012/12/26/special-relativity-mass-calculator

It takes rest mass m0, velocity and speed of light as parameters, in units you want, and calculates final mass.

It's working with floating point precision of web browser - it's using JavaScript to calculate mass.

ps. It appears that the latest version of Chrome is buggy and there is need to click Calculate button. In Firefox it's immediately calculating after change of value.


 

Offline syhprum

  • Neilep Level Member
  • ******
  • Posts: 3822
  • Thanked: 19 times
    • View Profile
Re: Special Relativity Mass Calculator
« Reply #1 on: 26/12/2012 16:59:36 »
I was a little disappointed I put in a slightly greater velocity than c but it made no attempt at an answer, could not the energy be included too
 

Offline UltimateTheory

  • Sr. Member
  • ****
  • Posts: 107
  • Thanked: 1 times
    • View Profile
    • Ultimate Theory of the Universe
Re: Special Relativity Mass Calculator
« Reply #2 on: 27/12/2012 01:06:24 »
I was a little disappointed I put in a slightly greater velocity than c but it made no attempt at an answer, could not the energy be included too

You're disappointed by mr. Einstein not by mine calculator.

Equation is:

m=m0/sqrt(1-v*v/c*c)

This equation was designed to always be infinity after using v>c

If v==c then sqrt(1-c*c/c*c) = sqrt(1-1) = sqrt(0) - division m0/0 - not possible.

If v>c then sqrt(negative value) and it's illegal in math.
 

Offline UltimateTheory

  • Sr. Member
  • ****
  • Posts: 107
  • Thanked: 1 times
    • View Profile
    • Ultimate Theory of the Universe
Re: Special Relativity Mass Calculator
« Reply #3 on: 27/12/2012 01:42:41 »
The largest velocity that I am able to enter is

v = 299792457.99999997

after using 299792457.999999971 there is produced error/infinity (floating precision of computer, it might differ between web browsers, they have different implementations of JavaScript)

1 kg at rest mass has in such speed 54794158.00594377 kg (55 million times bigger)
 

Offline JP

  • Neilep Level Member
  • ******
  • Posts: 3366
  • Thanked: 2 times
    • View Profile
Re: Special Relativity Mass Calculator
« Reply #4 on: 27/12/2012 03:15:08 »
If v>c then sqrt(negative value) and it's illegal in math.

The square root of a negative is defined as an imaginary number.  Most physicists agree that such a particle can't exist, but it has been proposed and is called a tachyon: http://en.wikipedia.org/wiki/Tachyon
 

Offline UltimateTheory

  • Sr. Member
  • ****
  • Posts: 107
  • Thanked: 1 times
    • View Profile
    • Ultimate Theory of the Universe
Re: Special Relativity Mass Calculator
« Reply #5 on: 27/12/2012 05:47:05 »
I was talking about from point of view of programming that sqrt(-value) is causing error.

But if you want I can change equation to:

m=m0/sqrt(abs(1-v*v/c*c))

I have tested this and surprisingly when v=2c, the result is m=m0/sqrt(3), so if m0 = 1 kg, m=0.577 kg.
 

Offline flr

  • Sr. Member
  • ****
  • Posts: 302
  • Thanked: 2 times
    • View Profile
Re: Special Relativity Mass Calculator
« Reply #6 on: 27/12/2012 06:47:57 »

Rather poorly programmed utility and impractical to use.

- The speed of light shall be as a constant in program and not as input.
- There should be only a single line with the result, in units that can be selected with a selector at the end.
- There should be a reset button.
- Add compute on paste event and on key up event; that may remove the compute button and save the user of one click.
- Add compute on select units.

And most importantly: debug it. If fails sometimes: It generated NaN at speeds lower than the speed of light.
 

Offline UltimateTheory

  • Sr. Member
  • ****
  • Posts: 107
  • Thanked: 1 times
    • View Profile
    • Ultimate Theory of the Universe
Re: Special Relativity Mass Calculator
« Reply #7 on: 27/12/2012 08:07:05 »
Quote
- The speed of light shall be as a constant in program and not as input.

It's input because one person might want to use 3*10^8, second might want to use proper 299792458 m/s - which is default value, so user has nothing to enter..

Quote
- There should be only a single line with the result, in units that can be selected with a selector at the end.

It's for user convenience to show result in couple units at the same time. Especially it's so easy to do it.

I was rather thinking about reverse - handling British & USA inches, foots and miles.

Quote
- There should be a reset button.

True. Done.

Quote
- Add compute on paste event and on key up event; that may remove the compute button and save the user of one click.

Changed onchange to onkeyup. Works fine in Firefox & Chrome (unlike onchange which doesn't work in Chrome).

But web browser doesn't send onkeyup event when user picked unit from drop-down list. And onchange must be present to handle it.

Quote
- Add compute on select units.

Web browsers are buggy. Firefox is computing while changing units in drop-down list, Chrome doesn't. I don't have other web browsers (IE) to check it.

Quote
And most importantly: debug it. If fails sometimes: It generated NaN at speeds lower than the speed of light.

Give example for v and m0 which is showing it.
And when you find it-check in other web browser.


« Last Edit: 27/12/2012 08:12:07 by UltimateTheory »
 

Offline JP

  • Neilep Level Member
  • ******
  • Posts: 3366
  • Thanked: 2 times
    • View Profile
Re: Special Relativity Mass Calculator
« Reply #8 on: 27/12/2012 15:45:39 »
I was talking about from point of view of programming that sqrt(-value) is causing error.

But if you want I can change equation to:

m=m0/sqrt(abs(1-v*v/c*c))

I have tested this and surprisingly when v=2c, the result is m=m0/sqrt(3), so if m0 = 1 kg, m=0.577 kg.


Technically, the mass becomes imaginary when v>c, so you'd need an if statement to set m=i m0/sqrt(abs(1-v*v/c*c)). You do get the odd property that you noted: the magnitude of energy of mass decreases as speed increases. 

Of course, you could also have it return a statement saying that velocities above c aren't attainable by any known matter (tachyons are an interesting theoretical aside, but probably don't exist and certainly haven't been observed).
 

Offline flr

  • Sr. Member
  • ****
  • Posts: 302
  • Thanked: 2 times
    • View Profile
Re: Special Relativity Mass Calculator
« Reply #9 on: 27/12/2012 17:16:41 »
It looks much better now. And easier to use.

The difference in behavior from browser to browser is not that much due to the fact "browsers are buggy" but rather due to slight different implementations of (for example) javascript engine (and other things like default styling, etc). People who design web pages or small web utilities knows these differences and write their codes accordingly such that it works similar in all main browsers.

If you do the exercise of changing your code such that it work similar in IE && firefox && chrome && safari && opera, you will see. 
 

Offline UltimateTheory

  • Sr. Member
  • ****
  • Posts: 107
  • Thanked: 1 times
    • View Profile
    • Ultimate Theory of the Universe
Re: Special Relativity Mass Calculator
« Reply #10 on: 27/12/2012 17:45:23 »
Anyone interested in reversed calculator? Input mass and velocity. Output rest mass.

Or enter mass and rest mass. Output velocity.
 

Offline yor_on

  • Naked Science Forum GOD!
  • *******
  • Posts: 11999
  • Thanked: 4 times
  • (Ah, yes:) *a table is always good to hide under*
    • View Profile
Re: Special Relativity Mass Calculator
« Reply #11 on: 29/12/2012 08:31:01 »
Nice Xmas present UT, and yeah, one for next year too, maybe? :)

You could maybe make it in two versions, using the original formula for the first, then add a button saying 'tachyons' and, if pressed, change to the other? (2in1)
 

Offline AndroidNeox

  • Sr. Member
  • ****
  • Posts: 251
  • Thanked: 2 times
    • View Profile
Re: Special Relativity Mass Calculator
« Reply #12 on: 13/01/2013 01:58:17 »
You could probably easily add fields for space and time dilation, too. Maybe just a field to show how much length contracts and time slows.

Thanks. It's a fun toy.
 

Offline UltimateTheory

  • Sr. Member
  • ****
  • Posts: 107
  • Thanked: 1 times
    • View Profile
    • Ultimate Theory of the Universe
Re: Special Relativity Mass Calculator
« Reply #13 on: 25/08/2013 17:34:44 »
You could probably easily add fields for space and time dilation, too. Maybe just a field to show how much length contracts and time slows.

I added Lorentz Factor output.
And new unit "c" for velocity, for easier calculating relativistic velocities.
 

The Naked Scientists Forum

Re: Special Relativity Mass Calculator
« Reply #13 on: 25/08/2013 17:34:44 »

 

SMF 2.0.10 | SMF © 2015, Simple Machines
SMFAds for Free Forums