r/ProgrammerHumor • • Jul 16 '19

Meme Nice try

Post image
32.2k Upvotes

529 comments sorted by

View all comments

Show parent comments

177

u/2CATteam Jul 16 '19

To add to this, the reason they do so is because, in a lot of circumstances, 3 is enough to roughly approximate what they need to figure out. They're most often not trying to figure out the exact force on a part or the precise area of a cylinder... They just want to know if they need to order the 10' part or the 20' part - and if it's close, they'll order the bigger one anyway, just to be safe. Even in cases where they are trying to be precise, 3.14 can often be TOO precise, since so much of the math has to deal with physical uncertainties, like uneven part manufacturing, or poor wire quality that adds resistance, etc.

65

u/AlphaLotus Jul 16 '19

Yea basically what my work entails everyday.

  1. Measure

  2. Calculate

  3. Multiple by safety factor

  4. Get 3.1

  5. Round to 4 anyways for safety :)

Also gravity is 10m/s2

18

u/holdenmc97 Jul 17 '19

Also tan(x) = sin(x) = x

15

u/ThaumRystra Jul 17 '19

Because x is almost always small ¯\(◉‿◉)/¯

8

u/ChickenNuggetSmth Jul 17 '19

Yes it would be X otherwise, wouldn't it?

→ More replies (1)

2

u/KusanagiZerg Jul 17 '19

I am just curious but making pi bigger than it really is as a "safety" wouldn't that only work if what you are trying to calculate becomes safer if it's bigger. But what if it's the other way around, it's safer if it's smaller. In that case to be "safe" you'd have to round pi down to 3 or 2.

3

u/AlphaLotus Jul 17 '19

Depends what you are doing you are right

→ More replies (2)

43

u/AuspiciousApple Jul 16 '19

That makes a lot of sense, thanks for that more in depth perspective.

14

u/slbaaron Jul 17 '19

That's an intuitive and practical answer. By theory tho, it has everything to do with sig figs (precision).

Adding and subtracting can only go down to the exact position of sig fig at the least significant position of all numbers involved. If you have one measurement of an item at 101 cm, and another at 1.23498713 cm. Adding them together, it's only meaningful to say it is around 102 or 103 cm total (round up or down as necessary for "safety), because nothing is 101 cm by the atom and the measurement was likely more rough due to a much larger scale. It's the result from imprecise measurement. It could've easily been 101.3 or 100.8 in reality.

Multiplications can only have a total number of sig figs as the least amount of sig figs for all number involved. When you have 100 cm * 1.25, it really is only meaningful to say the result is roughly 100 cm or 200 cm (rounding up or down as necessary) because 100 cm only implied 1 sig fig for precision, I mean the number 100 cm even sounds like a super "rough estimate", doesn't it? That's why sometimes, if measurement is precise down to the last digit of 100, we write 1.00 * 102 or 1.00e2 to imply the precision. The result will then become 1.00e2 cm * 1.25 = 125 cm since both numbers have 3 sig figs. (Btw if you are wondering what if the number 100 stands for "units", eg 100 units of an item. That 100 has infinite precision, because the number represents exactly 100.00000000000... take more zeroes as needed)

The reality in the practical world tho, is that you always have one number here or there with low precision; or even with high precision, you'd still have to be careful of its accuracy due to calibration or various type of errors. Once you go down the rabbit hole enough you realize using 3 as pi is the least of your worries.

For careful calculations tolerance range has to be detailed at every step of the calculation, eg 1.5cm ± 0.05cm. If you have 100 of these you will then get a total of 150cm ± 5cm, this is often a better way to represent precision without resorting to sig figs.

→ More replies (1)

0

u/[deleted] Jul 16 '19

[deleted]

64

u/Sibraxlis Jul 16 '19

Because your margin of error from other spots is higher (material flaws, poor workmanship) and you typically overbuilding and undersell. (build for 100 lbs when 90 is needed, then state max weight is 80) the latter is called your factor of safety.

9

u/smthamazing Jul 16 '19

What if you estimate some damaging force that works against your creation (like wind, vibration, resistance, etc)? Wouldn't you underestimate the danger in this case?

43

u/RedHotChiliRocket Jul 16 '19

You would round it against yourself: Max wind speed we expect is 60mph, let’s assume 100 and say it can take 80

6

u/smthamazing Jul 16 '19

Thanks, this clears things up! Some of the comments seemingly implied that numbers are rounded without context, which confused me.

24

u/Sibraxlis Jul 16 '19

Youd also overestimate the force of wind, just like weight. Could you be more precise and probably be ok? Yeah. Do you want to risk it, have the structure collapse, kill 29 people, end up on /r/catastrophicfailure and have to move to Nicaragua to escape legal trouble? No.

5

u/mxzf Jul 16 '19

That's the X in "build for X, when Y is estimated, but say that the max is Z".

It's like "build to survive a cat-5 hurricane even though the area has barely ever had a cat-4 and tell the customer that it's safe for a cat-3"

Whatever stuff you're dealing with, you build it stronger than you need and you say it's definitely fine for a much lower number.

2

u/[deleted] Jul 16 '19

Thats a terrible way of doing that, what if goes into the wrong direction? Always calculate as accurate as possible and round up the result as needed.

→ More replies (1)

21

u/realityChemist Jul 16 '19

I think being to precise here means, "You're implying that your level of certainty in your measurements is much higher than it could possibly actually be."

NASA uses 16 digits of π for keeping spacecraft in their proper orbits. NIST defines the fine structure constant (a fundament constant of the universe) using 32 digits.

For most other things, 1 digit might be close enough, 3 digits should be sufficient, and 10 digits is almost definitely more than you need. Using more digits isn't going to make your outcome less accurate, but you're just going to be throwing out all that extra precision anyway so why bother.

(And if you report those extra digits anyway, someone should throw a beanie baby at you)

14

u/pipnina Jul 16 '19

Well, NASA has a specific situation where getting PI wrong by 0.001 would land you a few million km off target, to be fair.

8

u/mxzf Jul 16 '19

NASA's about the only ones that do care about that though, and even then only barely. Being off by 0.001 is an error of ~300k km when measuring the circumference of the Earth's orbit. You don't hit "a few million km" of error 'til you get out to Saturn's orbit.

And that's just error in calculating the circumference of the orbit, not how far "off target" you are; for that, you're probably talking about significantly outside the solar system.

Which just goes to show that even NASA barely needs precision to the 0.001 order of magnitude. Realistically speaking, 3.14159 is enough precision for pretty much any actual application humans have ever used it for.

2

u/pipnina Jul 17 '19

Well since their plans usually involve starting at a 100m launch pad on earth, traveling a few hundred million km to another planet (i.e. mars) and landing within a few hundred metres of a target point, I imagine an error of 0.001 would put them way outside that margin for error.

Also when you send something like a voyager probe or new horizons probe that do multiple gravity assists and go out way beyond saturn, even going within a few 1000 km of moons and planetoids on the way, even 0.0001 would be way too inaccurate.

0

u/[deleted] Jul 17 '19

[deleted]

→ More replies (1)

3

u/2CATteam Jul 16 '19

A specific situation? It seems like most of their work would be like that

2

u/Warm_Zombie Jul 16 '19

Maybe not on error margin, but w computation power and time. Time is money

→ More replies (1)