LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 03-29-2019, 05:48 AM   #1
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 17,545

Rep: Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608
Maths Issue


Is there a calculator that calculates with 4 digit exponents? All handhelds give 3 digit exponents. I'm in probabilities, and need the result of this in scientific notation;

P = [ 0.75^1715 x 0.25^1596 x 0.5^1419 ].

Now I can find the some root of the indices, divide this (bigger) number into 1, and express the answer in scientific notation, and square back up the result, and get away with current equipment. That seems to be the same in simple examples.
 
Old 03-29-2019, 05:58 AM   #2
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2926Reputation: 2926Reputation: 2926Reputation: 2926Reputation: 2926Reputation: 2926Reputation: 2926Reputation: 2926Reputation: 2926Reputation: 2926Reputation: 2926
Those are some seriously small numbers!

Galculator works out P to be 4.79464779337e-1603 but I would advise comparing that against another calculator or two (try some online ones, for example).

Edit: Recalculated value.

Last edited by hydrurga; 03-29-2019 at 05:54 PM.
 
Old 03-29-2019, 06:34 AM   #3
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 24,252

Rep: Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964
https://apfloat.appspot.com/
probably you can try to download their applet too. Implementing it does not seem difficult (I made something like this for commodore 64).
 
Old 03-29-2019, 08:49 AM   #4
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,466

Rep: Reputation: 451Reputation: 451Reputation: 451Reputation: 451Reputation: 451
I use bc on the command line for such things. You have to specify scale for how many decimals. But then you can calculate correctly with super small and super big numbers. I don't think it can do scientific notation, because it would mean it has to round them somehow. Wouldn't it be better to just multiply with some super big number?


Code:
echo "scale=10000000000000000000000000000000000000000000000000000000000000000000000000000;0.75^1715 * 0.25^1596 * 0.5^1419" | bc -l | less
 
Old 03-29-2019, 11:41 AM   #5
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,954
Blog Entries: 13

Rep: Reputation: 4986Reputation: 4986Reputation: 4986Reputation: 4986Reputation: 4986Reputation: 4986Reputation: 4986Reputation: 4986Reputation: 4986Reputation: 4986Reputation: 4986
I don't know of a particular calculator which does this, but please remember when multiplying exponent numbers of different bases that you can also write the problem with the following considerations:
  • 0.75 = 0.25 * 3
  • 0.5 = 0.25 * 2
  • 0.75^1715 = 3^1715 x 0.25^1715
  • 0.5^1419 = 2^1419 x 0.25^1419
  • Result becomes: 3^1715 x 2^1419 x (0.25^1715 x 0.25^1596 x 0.25^1419)
  • Add the common exponents and it becomes: 3^1715 x 2^1419 x 0.25^4730
I'm sure there are other manipulations possible to make the problem easier. I'm not math genius, but do recall that a great deal of the discipline is to be capable of converting things in manners similar to this where it makes the problem more fundamental to solve.
 
Old 03-29-2019, 04:27 PM   #6
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 17,545

Original Poster
Rep: Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608
Quote:
Originally Posted by hydrurga View Post
Those are some seriously small numbers!

Galculator works out P to be 2.14001446e-2991 but I would advise comparing that against another calculator or two (try some online ones, for example).
Yes, and thanks for the reply. When you calculate Mendelian probabilities for retaining traits in a distributed population, I came up with those figures. I don't have galculator. Can you try 1/(2.14001446e-2991) to give me the format I was using? Is it anywhere near the 4.40 x 10^1604 I came up with? Also is 2.14001446e-2991 = 2.14001446 x 10^-2991?

@pan64:Thanks, I will go for that app tomorrow

Gutform: Thank you, but if bc does not do scientific notation, it's dead in the water for me. I'm not going to count hundreds of zeroes!

@rtmistler: Very interesting. I hadn't thought of manipulating that way. But I need scientific notation to dovetail with the rest of my figures, because probabilities are multiplied by each other, and it's important to have scientific notation to add the indices. I'm no great mathematician either. I actually did a lot of manipulation to simplify things this far.
 
Old 03-29-2019, 06:02 PM   #7
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2926Reputation: 2926Reputation: 2926Reputation: 2926Reputation: 2926Reputation: 2926Reputation: 2926Reputation: 2926Reputation: 2926Reputation: 2926Reputation: 2926
Quote:
Originally Posted by business_kid View Post
Yes, and thanks for the reply. When you calculate Mendelian probabilities for retaining traits in a distributed population, I came up with those figures. I don't have galculator. Can you try 1/(2.14001446e-2991) to give me the format I was using? Is it anywhere near the 4.40 x 10^1604 I came up with? Also is 2.14001446e-2991 = 2.14001446 x 10^-2991?
Oops, I went to confirm the galculator result with speedcrunch and found that somehow I had calculated it wrongly. The correct answer, with increased accuracy provided by speedcrunch) is:

4.79464779337093780339e-1603

1 divided by the above is 2.08565893282629910515e+1602.

Yes, e is indeed that.

I would recommend speedcrunch to you as it is easy to paste formulae into it.
 
Old 03-30-2019, 07:51 AM   #8
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 17,545

Original Poster
Rep: Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608
Thanks, Hydruga.

That figure of 2.08565893282629910515e+1602 looks like my number of zeroes was fairly close. Scientific notation is corrected to 2 decimal places, so the string of decimals while impressive, is lost in the editing.Engineering notation retains them until they get to the engineer, who decides how precise he's going to be :-/.

It seems like I was in the ballpark, but squared the figures part of the answer. Perhaps I infringed BODMAS. I don't see where. What I did was to calculate the slightly less improbable
Code:
0.75^1714 x 0.25^1596 x 0.5^1418
= (0.75^852)^2 x (0.25^798)^2 x (0.35^709)^2 # Dividing into 1
= (2.804e108)^2 x (2.778e480)^2 x (2.693e213)^2 # Now squaring up
= 7.862e216 x 7.717e960 x7.252e426 # And multiplying out
= 4.40e1604
Now the interesting thing is that 2 digits of that 'e1604' came from the multiplication of 7, as 7^3 = 343. I wonder is that where a difference arose? That I in fact did the wrong sum? But doing that surely would have given me a smaller answer.
 
Old 03-30-2019, 08:34 AM   #9
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2926Reputation: 2926Reputation: 2926Reputation: 2926Reputation: 2926Reputation: 2926Reputation: 2926Reputation: 2926Reputation: 2926Reputation: 2926Reputation: 2926
Observations:

. 1714/2 is 857, not 852.

. You changed the 0.5 on the first line to 0.35 on the second line.

. 1/(0.75^852) is 2.804e+106, not 2.804e+108

I still recommend speedcrunch. Less chance of making mistakes on individual lines if it does all the donkey work for you. However, I still advise, because of the nature of the numbers involved, using two separate calculators to confirm each other's results.
 
Old 03-30-2019, 09:22 AM   #10
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 17,545

Original Poster
Rep: Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608
857 is correct, and that mistake is real.
The 0.35 is only in translation to the browser -sorry about that. The calculations carry 0.5.

Multiplying through gives me 7.81e1601, but although I only need an estimate, I realise I am no longer bound by dodges and wheezes. I tried slackrepo for speedcrunch, but it made an unwanted directory as usual and then puked. I'll resort to Mint and sort this out. I need the capability to sort these thing out better than I have, and the great thing about Open Source is that it comes free.
 
Old 03-31-2019, 11:33 AM   #11
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 24,252

Rep: Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964
http://www.isthe.com/chongo/tech/com...lc-whatis.html
I downloaded/compiled and finally executed:
Code:
0.75^1715 * 0.25^1596 * 0.5^1419 * 10^1600
	~0.00479464779337093780
but using log (actually any logarithmic functions may help) - and there is no need to use special tools.
Code:
log (0.75^1715 * 0.25^1596 * 0.5^1419) = log (0.75)×1715 + log(0.25)×1596 + log(0.5)×1419 = −1602.31924329
result: 10^−1602.31924329 = 10^-1600 * 0.004794648
sorry these are the original numbers, you need to adjust if you have other/different numbers.

Last edited by pan64; 03-31-2019 at 11:35 AM.
 
Old 04-02-2019, 05:07 AM   #12
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 17,545

Original Poster
Rep: Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608
Getting somewhere finally.
I installed speedcrunch and galculator in Mint, and worked out the various expressions. 2 of them were straightforward. The (1/0.75)^857 x (1/0.75)^858, when bracketed that way behaved also, but speedcrunch can handle 4 bit exponents and even 5 bit ones

@pan64: that looks impressive. Where did the 10^1600 come from?
By restating things differently, I could make life easy
P = 0.75^1715 x 0.25^1596 x 0.51^419.. Now, without any Math really we can cheat on dividing into 1
P = 1 in (1.333^1715 x 4^1596 x 2^1419)
= 1.8618e214 x 7.7222e960 x 1.4506e427 = 2.0855e1602

There is a variation of this Mendelian probability thing that actually generates 5 bit exponents, and to it's credit, speedcrunch handles them flying.
 
Old 04-02-2019, 05:39 AM   #13
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 24,252

Rep: Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964
you can get it based on that logarithmic calculation but actually I just tried to calculate the following:
Code:
1/P = 0.75^-1715 * 0.25^-1596 * 0.5^-1419
Interestingly bc could handle it too and
Code:
echo '0.75^-1715 * 0.25^-1596 * 0.5^-1419' | bc | wc -c
1650
can give you a good starting point.

(I think you were talking about 4 and 5 digit exponents - instead of bits)

Last edited by pan64; 04-02-2019 at 05:42 AM.
 
Old 04-05-2019, 11:57 AM   #14
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 17,545

Original Poster
Rep: Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608
Quote:
Originally Posted by pan64
(I think you were talking about 4 and 5 digit exponents - instead of bits)
Yes, of course
 
Old 05-02-2019, 10:13 AM   #15
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 17,545

Original Poster
Rep: Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608Reputation: 2608
Resurrecting this thread briefly to correct Mathematical error, in case anyone uses my math as a statistics lesson. I'm doing Mendelian probabilities, once something has acquired a trait, what are the chances of retaining it for a given period. I was using the form
Code:
P = 1 in (1.333^1715 x 4^1596 x 2^1419)
but that's wrong. The 'x' signs marked are wrong as these traits are not interdependent. They should be added, not moltiplied. So the equation becomes
Code:
P = 1 in (1.333^1715 + 4^1596 + 2^1419)
, and here, we get another surprise, best observed once you convert to scientific notation.
Code:
= 1.2126e214 + 7.7222e960 + 1.4506e427
When you right justify those numbers, e214 & e427 appear way down the decimal places of e960; and as scientific notation is corrected to 2 places, They disappear without trace So the answer is 7.72e960.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Suggestions for Maths Software andrewlkho Linux - Software 3 04-11-2005 09:44 PM
please help me do maths :) darkRoom General 36 04-11-2005 01:03 PM
And some maths :-P Mathiasdm General 7 11-11-2004 03:48 PM
java + maths problem craddy Programming 2 03-04-2004 02:23 PM
PHP maths - coding algebraic formulas linuxfond Programming 2 10-03-2003 01:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 09:37 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration