LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-13-2023, 12:09 AM   #76
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 4,471
Blog Entries: 7

Rep: Reputation: 2573Reputation: 2573Reputation: 2573Reputation: 2573Reputation: 2573Reputation: 2573Reputation: 2573Reputation: 2573Reputation: 2573Reputation: 2573Reputation: 2573

Quote:
Originally Posted by kernelhead View Post
I truly do wander if something bad could happen, like a bridge collapse or a rocket explode, due to using the wrong standard - or has it already happened?
20 years ago there was a mid-air plane collision caused by the use of differing standards: https://en.wikipedia.org/wiki/2002_%...-air_collision

At the time, some pilots were being trained to follow instructions from the Traffic Collision Avoidance System, and other pilots were being trained to ignore TCAS and follow instructions from Air Traffic Control. A seemingly small thing, but it lead to tragedy in this case.

I would hope engineers are trained the same way around the globe... Otherwise you're right: It could be a disaster waiting to happen.
 
Old 04-13-2023, 01:09 AM   #77
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,039

Rep: Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347
Quote:
Originally Posted by kernelhead View Post
I offered the 2 online calculators as an argument to the statement "Calculators around the world all work the same, in order of precedence left to right."

& to show that calculators around the world don't all work in the same way.

If the 2 calculators didn't show their work on screen, like the Ubuntu calculator doesn't, then wouldn't we conclude that multiplication takes priority over division. And the fact that the 2 online calculators do show their work, I don't think it is a definite conclusion, either, that they aren't making multiplication a priority, because they are still doing the "10•2" on the bottom before considering the 20 on top (& before considering the division sign)...
The answer is based on the operator precedence. Unfortunately you cannot find the relevant part on the wiki page: https://en.wikipedia.org/wiki/Order_of_operations.
We have an additional operation, called implied (or implicit) multiplication, see for example here: https://www.themathdoctors.org/order...ultiplication/.
This is what was missing. I think this rule is not really implemented in some calculators....
 
Old 04-13-2023, 01:46 AM   #78
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,269
Blog Entries: 24

Rep: Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206
Quote:
Originally Posted by kernelhead View Post
I truly do wander if something bad could happen, like a bridge collapse or a rocket explode, due to using the wrong standard - or has it already happened? We can all hope that plenty of parenthesis are being deployed to prevent this!
Nov. 10, 1999: Metric Math Mistake Muffed Mars Meteorology Mission

And this, caused by an integer overflow, technically a software bug but still a math error...

A software vulnerability in Boeing's new 787 Dreamliner jet has the potential to cause pilots to lose control of the aircraft, from which:

Quote:
Dreamliners have four main GCUs associated with the engine mounted generators. If all of them were powered up at the same time, "after 248 days of continuous power, all four GCUs will go into failsafe mode at the same time, resulting in a loss of all AC electrical power regardless of flight phase.
Yes, it happens...

Last edited by astrogeek; 04-13-2023 at 02:12 AM.
 
Old 04-13-2023, 05:23 AM   #79
brianL
LQ 5k Club
 
Registered: Jan 2006
Location: Oldham, Lancs, England
Distribution: Slackware64 15; SlackwareARM-current (aarch64); Debian 12
Posts: 8,302
Blog Entries: 61

Rep: Reputation: Disabled
Speedcrunch gives 1.

https://heldercorreia.bitbucket.io/speedcrunch/

Code:
48/8(14-8)
= 1
P.S.
I'd like to know how KCalc arrived at 48/8(14-8) = 806 after closing brackets, then 0.0595533498759 after pressing = ?

Last edited by brianL; 04-13-2023 at 05:32 AM.
 
Old 04-14-2023, 05:35 AM   #80
goumba
Senior Member
 
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Fedora, OpenSUSE, FreeBSD, OpenBSD, macOS (hack). Past: Debian, Arch, RedHat (pre-RHEL).
Posts: 1,335
Blog Entries: 7

Rep: Reputation: 402Reputation: 402Reputation: 402Reputation: 402Reputation: 402
Quote:
Originally Posted by brianL View Post
I'd like to know how KCalc arrived at 48/8(14-8) = 806 after closing brackets, then 0.0595533498759 after pressing = ?
Wrong mode and poster didn't notice?

I get 36. KCalc 22.12.3.

Last edited by goumba; 04-14-2023 at 05:36 AM. Reason: Corrected typo, let's not add them into the confusion!
 
Old 04-14-2023, 10:03 AM   #81
brianL
LQ 5k Club
 
Registered: Jan 2006
Location: Oldham, Lancs, England
Distribution: Slackware64 15; SlackwareARM-current (aarch64); Debian 12
Posts: 8,302
Blog Entries: 61

Rep: Reputation: Disabled
Quote:
Originally Posted by goumba View Post
Wrong mode and poster didn't notice?

I get 36. KCalc 22.12.3.
I checked the mode after the 1st time I got those odd results. It was the correct mode: Simple.
I get 36 with the multiplication sign between 48/8 and (14-8).
 
Old 04-14-2023, 08:03 PM   #82
kernelhead
Member
 
Registered: Jun 2022
Posts: 247

Original Poster
Rep: Reputation: 5
nt.

-didn't know how to delete this post

Last edited by kernelhead; 04-14-2023 at 08:49 PM.
 
Old 04-14-2023, 08:47 PM   #83
kernelhead
Member
 
Registered: Jun 2022
Posts: 247

Original Poster
Rep: Reputation: 5
nt.

-didn't know how to delete this post.

Last edited by kernelhead; 04-14-2023 at 08:50 PM.
 
Old 09-11-2023, 03:05 PM   #84
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,249

Rep: Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323
On second thought, never mind.

I had a link, but I got so disgusted when reviewing kernelhead's friend's confidently-wrong stupidity that I decided not to post it.

For the record, the correct answer is that the question is malformed. The link was valuable as a discussion how what is essentially the applied math community agreed to deal with that, but I knew that some people here would try to take it as more than that.

Last edited by dugan; 09-11-2023 at 04:21 PM.
 
2 members found this post helpful.
Old 09-11-2023, 06:15 PM   #85
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,269
Blog Entries: 24

Rep: Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206
Thanks for the post anyway dugan, it gave me the opportunity to read the entire thread again, to which I add the following comments.

I have no relevant degrees but have always had a love of math and physics myself, having studied extensively and enjoyed a successful career directly related to that study.

It seems to me the equation as originally posted is simply ambiguous, the ambiguity being whether or not the parenthesized term is part of the denominator or not (post #69 and others). Being ambiguous, neither form can be said to be correct and the other incorrect. If there is an actual intent that it be one way or the other it is up to the person originating the expression to force that ordering by parenthesis.

I was taught, or at least learned in public school in the 1960's that multiplication and division have the same precedence, resolved by left-to-right ordering in absence of parenthesis.

I first encountered the expression PEMDAS when educating my own children (all home schooled), and understood it to mean:
Code:
Parenthesis, Exponents, Multiplication and Division, Addition and Subtraction
... and taught it that way. (And one of the refs previously cited in this thread presents it exactly this way).

Requiring that PEMDAS specifies multiplication to have a higher precedence than division without the same requirement for addition and subtraction seems somehow disingenuous.

I learned my first advanced math using a slide rule, and was always keenly aware that it was up to me to force precedence in written expressions if there were any reasonable possibility that they might be understood differently by others. Had 48/8(14-8) ever arisen and led to differing results one would have just asked what was intended. I cannot imagine one insisting theirs was correct and the other wrong in such a case and arguing about it.

We no longer use slide rules but have a variety of wonderful electronic devices to solve our equations, but the same operator discipline must apply. Unless we we are going to insist that every device conforms to a single input expression format and produces the identical output, we must recognize that it is up to the operator to assure that the input correctly expresses their intent within the limitations of the given device. Nothing else seems reasonable.

The argument that this supposed error derives from the C programming language seems just silly to me.

Last edited by astrogeek; 09-11-2023 at 06:46 PM.
 
Old 09-11-2023, 06:52 PM   #86
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,249

Rep: Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323
The main argument I've seen for doing it the other way (both in this thread and in the link I held back) is that 8(14 - 8) and 8 * (14 - 8) are not the same. That's what the nonsense about "juxtaposition" is about.
 
Old 09-11-2023, 09:40 PM   #87
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,249

Rep: Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323
Somebody wanted a statement from an actual math expert?

https://twitter.com/LongFormMath/sta...75300204114254
 
1 members found this post helpful.
Old 09-11-2023, 11:13 PM   #88
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,269
Blog Entries: 24

Rep: Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206
From the X link posted by dugan, worth permanently preserving here...

Quote:
Jay Cummings
@LongFormMath
I have a math PhD, it’s a dumb (and ambiguous, but mostly just dumb) question

Problem given as: 8÷2(2+2)=?
Thanks dugan.

Last edited by astrogeek; 09-11-2023 at 11:16 PM.
 
Old 09-12-2023, 02:00 AM   #89
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,039

Rep: Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347
Quote:
Originally Posted by astrogeek View Post
I first encountered the expression PEMDAS when educating my own children (all home schooled), and understood it to mean:
Code:
Parenthesis, Exponents, Multiplication and Division, Addition and Subtraction
... and taught it that way. (And one of the refs previously cited in this thread presents it exactly this way).

Requiring that PEMDAS specifies multiplication to have a higher precedence than division without the same requirement for addition and subtraction seems somehow disingenuous.
The problem is that this PEMDAS is wrong. We have an additional operation (as it was already explained in post #77). That is the implied/implicit multiplication. It is not mentioned on the wiki page you linked, therefore that wiki page is incomplete too. This operation has a relatively high precedence: PEIMDAS
You cannot discuss this question without knowing the existence of this additional possibility (just because it is all about that I). And obviously you cannot find the correct answer without that (that will lead to confusion and misunderstanding).
What is really surprising: this I operation is very little known, they don't teach it at school and even those who work with it (=make calculators or teach it) don't know anything about it.
Even more interesting is that this I operation is all around us, a part of our everyday life. You always speak about 2 apples, 5 tickets or similar. And if you have 30 eggs and you want to put them in baskets (which can hold 10 eggs), you realize: 30e/10e = 3, and it will never be 3e**2.
 
Old 09-12-2023, 12:42 PM   #90
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,269
Blog Entries: 24

Rep: Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206Reputation: 4206
Quote:
Originally Posted by pan64 View Post
What is really surprising: this I operation is very little known, they don't teach it at school and even those who work with it (=make calculators or teach it) don't know anything about it.
Even more interesting is that this I operation is all around us, a part of our everyday life. You always speak about 2 apples, 5 tickets or similar. And if you have 30 eggs and you want to put them in baskets (which can hold 10 eggs), you realize: 30e/10e = 3, and it will never be 3e**2.
I will reserve comments on implied multiplication itself for another post, if at all, but the above is contrived, and is just wrong.

"30 eggs" does not involve multiplication of number, 30, and physical object, eggs. What would it even mean to multiply a number and an egg?

If you write 30e to mean 30 eggs then the only possible way to interpret it is 30 times the unit quantifier, an egg, the unit always and by definition being 1 (think unit vectors, for example).

So, for this case e explicitly and always equals 1, the unit of "egg", and 30*1/10*1 = 3, a pure number, not an egg, no matter how you parenthesize it, with no special precedence rules necessary.

Code:
30*1/10*1 = 30/10*1 = 3*1 = 3

30*(1/10*1) = 30*0.1*1 = 3*1 = 3

(30*1)/10*1 = 3*1*1 = 3*1^2 = 3
   -OR-
30*1
---- * 1 = 3*1*1 = 3*1^2 = 3
 10
This illustrates the problem with contrivances such as the original problem in this thread - contrivances inevitably beget contrivances and we all lose our way!

Last edited by astrogeek; 09-12-2023 at 01:06 PM.
 
  


Reply



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
LXer: Calculator N+ is an open source scientific calculator for your smartphone LXer Syndicated Linux News 0 11-27-2019 06:21 AM
Ubuntu calculator problem (or is it just me?) cajunchief Linux - Laptop and Netbook 5 09-27-2011 10:24 AM
LXer: Improved Calculator App in Ubuntu 10.10 LXer Syndicated Linux News 0 07-14-2010 10:50 PM
I can't figure out what is wrong with this code-its a calculator written in c AceofSpades19 Programming 17 03-04-2007 01:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:52 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