Przemyslaw.Gruchala Posted December 26, 2012 Posted December 26, 2012 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.
Przemyslaw.Gruchala Posted December 27, 2012 Author Posted December 27, 2012 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)
Przemyslaw.Gruchala Posted December 27, 2012 Author Posted December 27, 2012 Anyone interested in reversed calculator? Input mass and velocity. Output rest mass. Or enter mass and rest mass. Output velocity.
alpha2cen Posted December 30, 2012 Posted December 30, 2012 How about using more precision compiler? JavaScript call--->external compiled program with more precision compiler. Is it possible?
Przemyslaw.Gruchala Posted December 30, 2012 Author Posted December 30, 2012 (edited) Compilers don't have precision. Precision is "property" of floating point format. There are two built-in in math co-processors (which are part of processor since Intel 486) IEEE 754 http://en.wikipedia.org/wiki/Single_precision_floating-point_format 32 bit floating point format http://en.wikipedia.org/wiki/Double_precision_floating-point_format 64 bit floating point format Using any low-level language such as C/C++ it's possible to code any precision custom floating point format. But it's time and money consuming task, every math operation must be recreated and carefully tested. JavaScript is interpreted language (script), so it's your web browser and your computer which is doing the all calculations. It can't execute program which is on server, and running program from local disk would be serious leak in security (imagine somebody calling "dir c:" and he would have all structure of your disk... then do echo <c:\file.txt and have your data) You can see mine calculator pressing ctrl-u to show page source html. To have more precision there would be needed to: - create c/c++ custom floating point format - create c/c++ executable doing the same what does javascript code. - change the way html form tag is handling entered data, and instead of using javascript send your data to web server, which would run PHP, and execute program, then send output to you. Edited December 30, 2012 by Przemyslaw.Gruchala
alpha2cen Posted December 31, 2012 Posted December 31, 2012 This is an example of a good compiler. Hardware, operating system, good compiler and good conecton to the http program make high precision computing results. http://en.wikipedia.org/wiki/Extended_precision
Przemyslaw.Gruchala Posted December 31, 2012 Author Posted December 31, 2012 80 bit floating point has precision just 18 digits in decimal (2^63 is the largest value it can have, without loosing precision). I was rather thinking about making class MineOwnFloat { const MineOwnFloat & operator += ( const MineOwnFloat &src ); const MineOwnFloat & operator -= ( const MineOwnFloat &src ); const MineOwnFloat & operator *= ( const MineOwnFloat &src ); const MineOwnFloat & operator /= ( const MineOwnFloat &src ); [etc. etc ] }; And have f.e. 1000 digits precision. Or million digits precision.
alpha2cen Posted December 31, 2012 Posted December 31, 2012 The method of solving square root is important at the high precision computation. Good compiler gives more accurate answer at the long digit computation. http://www.codeproject.com/Articles/69941/Best-Square-Root-Method-Algorithm-Function-Precisi
Przemyslaw.Gruchala Posted December 31, 2012 Author Posted December 31, 2012 (edited) Interesting article. But I bet author made serious mistake - in Visual Studio Project Properties window Code Generation used Floating Point Model - Precise. In such model the all floating point operations are in math linked library and are called from main code (it's clearly visible while disassembling/watching generated assembly code). After using Code Generation > Floating Point Model Fast, they're not called but inlined. This explain why inline version: double sqrt13(double n) { __asm{ fld n fsqrt } } is 87% faster than regular sqrt( double n ) Edited December 31, 2012 by Przemyslaw.Gruchala
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now