Don't Trust Machines

Find ordered quadruples of integer (a,b,c,d) (a,b,c,d) such that {a+b+c+d=0sina+sinb+sinc+sind=0.\begin{cases} a+b+c+d & =0\\ \sin a + \sin b+ \sin c +\sin d &=0. \end{cases}

I thought I had a solution to this question, and worked it out through pencil and paper. When I used Just-Basic (the free Windows version) to test all the possibilities, it confirmed my result. I was excited and submitted the answer, but was told that I was wrong so I filed a report. However, when I tested all the possibilities using a Python program in SAGE - I got a different answer. Intrigued, I have since gone back and found my mistakes and also why Just-Basic screwed up.

So what happened? We seldom get bit by the fact that calculators, computers, and poorly written programs can often miss things because of rounding errors or the fact that binary conversions are not always exact. The default precision of calculations is often unknown. Different machines and various programming languages combine to create peculiar results if we are not careful and fail to take these problems into consideration. It is never easy to know exactly what is happening "under the sheets".

Moral of the story - Don't trust machines - use what is between your ears better - especially when you are doing exact calculations in Algebra or Number Theory!

As a further illustration of this topic, try this question Remember the "Windows Calculator" is running on a machine.

Note by Bob Kadylo
5 years, 1 month ago

No vote yet
1 vote

  Easy Math Editor

This discussion board is a place to discuss our Daily Challenges and the math and science related to those challenges. Explanations are more than just a solution — they should explain the steps and thinking strategies that you used to obtain the solution. Comments should further the discussion of math and science.

When posting on Brilliant:

  • Use the emojis to react to an explanation, whether you're congratulating a job well done , or just really confused .
  • Ask specific questions about the challenge or the steps in somebody's explanation. Well-posed questions can add a lot to the discussion, but posting "I don't understand!" doesn't help anyone.
  • Try to contribute something new to the discussion, whether it is an extension, generalization or other idea related to the challenge.
  • Stay on topic — we're all here to learn more about math and science, not to hear about your favorite get-rich-quick scheme or current world events.

MarkdownAppears as
*italics* or _italics_ italics
**bold** or __bold__ bold

- bulleted
- list

  • bulleted
  • list

1. numbered
2. list

  1. numbered
  2. list
Note: you must add a full line of space before and after lists for them to show up correctly
paragraph 1

paragraph 2

paragraph 1

paragraph 2

[example link](https://brilliant.org)example link
> This is a quote
This is a quote
    # I indented these lines
    # 4 spaces, and now they show
    # up as a code block.

    print "hello world"
# I indented these lines
# 4 spaces, and now they show
# up as a code block.

print "hello world"
MathAppears as
Remember to wrap math in \( ... \) or \[ ... \] to ensure proper formatting.
2 \times 3 2×3 2 \times 3
2^{34} 234 2^{34}
a_{i-1} ai1 a_{i-1}
\frac{2}{3} 23 \frac{2}{3}
\sqrt{2} 2 \sqrt{2}
\sum_{i=1}^3 i=13 \sum_{i=1}^3
\sin \theta sinθ \sin \theta
\boxed{123} 123 \boxed{123}

Comments

you do not have to trust your machines, you have to trust yourself that you wrote the correct code. Do you mind sharing the basic code?

And yes, floating point arithmetic is like that. When you are doing numerical analysis, I suggest you watch out for small errors like that. That is why there is a whole branch of mathematics devoted to it

Agnishom Chattopadhyay - 5 years, 1 month ago

Log in to reply

Here is the first program that missed some valid ordered quadruples (a,b,c,d) and gave 1025 (wrong):

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
trips=0
cnt=0
for a=-10 to 10
for b=-10 to 10
for c=-10 to 10
for d=-10 to 10
S=(a+b+c+d)
Ss=(sin(a)+sin(b)+sin(c)+sin(d))
if S=0 and Ss=0 then cnt=cnt+1: print cnt,a,b,c,d,S,Ss
trips=trips+1
next d
next c
next b
next a
print "Done !!!",trips;" loops"

LAST 2 LINES OF OUTPUT:

1
2
1025          10            10            -10           -10           0             0
Done !!!      194481 loops

Here is the program, after the fix, which got the correct answer:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
trips=0
cnt=0
for a=-10 to 10
for b=-10 to 10
for c=-10 to 10
for d=-10 to 10
S=(a+b+c+d)
Ss=(sin(a)+sin(b)+sin(c)+sin(d))
if S=0 and abs(Ss)<=.000000002 then cnt=cnt+1: print cnt,a,b,c,d,S,Ss
trips=trips+1
next d
next c
next b
next a
print "Done !!!",trips;" loops"

LAST 2 LINES OF OUTPUT:

1
2
'correct answer'          10            10            -10           -10           0             0
Done !!!      194481 loops

This last program is in Python running on cloud.sagemath.com and it got the correct answer first try.

1
2
3
4
5
6
7
8
   cnt=0
    for a in srange(-10,11):
        for b in srange(-10,11):
            for c in srange(-10,11):
                for d in srange(-10,11):
                    if a+b+c+d==0 and sin(a)+sin(b)+sin(c)+sin(d)==0:
                        cnt+=1
    print cnt

Sorry about the poor formatting - I'm just learning LaTeX. I hope Calvin Lin doesn't feel I've given too much away about his question. That's why I left out 'correct answer'

P.S. I have come across some of your work on Brilliant and found your animated graphs extraordinary!

Especially on this question where you made some graphs for Otto K Bretscher ! Just absolutely Brilliant !

Bob Kadylo - 5 years, 1 month ago

Log in to reply

That's nice. Thanks. I fixed your formatting.

I am glad that you've figured the solution out. Dealing with numeric error is a common problem you've to deal with in the field of numeric analysis. It is easier for SAGE because SAGE is not just normal python, sage is a Computer Algebra System built on top of python which is optimised to deal specifically with mathematical problems.

I guess the moral isn't Don't trust computers but Computers are useful as long as you use your brain. Computing is an important part of the mathematics that is emerging today. You might want to check out this and Experimental Mathematics

Agnishom Chattopadhyay - 5 years, 1 month ago

Log in to reply

@Agnishom Chattopadhyay Thank you - it looks much better now! My original errors have developed into an amazing learning experience in Math, Computing, and LaTeX ! Where did you learn about those " ``` " characters' function?

The two Wikipedia references you suggested I check out were very interesting and linked to countless other articles I really enjoyed ! You've made this 'Note' twice as valuable.

Bob Kadylo - 5 years, 1 month ago

Log in to reply

@Bob Kadylo I got them from the Formatting Guide.

Glad that you liked them :)

Agnishom Chattopadhyay - 5 years, 1 month ago

I agree, except that in my case I can't trust the grey matter either. You might be interested in my solution to the first problem you mention above.

Bill Bell - 5 years, 1 month ago

@bobbym none You might want to comment here.

Agnishom Chattopadhyay - 5 years, 1 month ago

Log in to reply

Comparing two floating point numbers for equality... a recipe for disaster.

bobbym none - 5 years, 1 month ago

Log in to reply

Nice point ! I think that sums up what happened here very well !

Bob Kadylo - 5 years, 1 month ago

Log in to reply

@Bob Kadylo Hi Agnishom; I do not know, he never answers any of my calls or emails...

Hi Bob; Computers are tricky, the point is get answers out of them. That you did, so you did well.

bobbym none - 5 years, 1 month ago

Log in to reply

@Bobbym None Humans are trickier.

Knuth does not have an email. I suggest you ask him directly.

Agnishom Chattopadhyay - 5 years, 1 month ago

What is Donald Knuth's suggestion about that?

Agnishom Chattopadhyay - 5 years, 1 month ago
×

Problem Loading...

Note Loading...

Set Loading...