Math Is Fun Forum

  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#101 2012-05-09 01:29:57

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 4,884

Re: sum of digit

Thanks. Done.

I'd better say goodnight. Very early start at work in the morning.

Last edited by phrontister (2012-05-09 01:33:00)


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Online

#102 2012-05-09 01:33:34

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: sum of digit

Try

Sqrt[2.] Do not forget the period after the 2


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#103 2012-05-10 01:38:38

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 4,884

Re: sum of digit

Yes, I got the extra decimal places. Without the period the display showed the square root symbol.

This gave an incorrect result: Sqrt[2*3]*Sqrt[2*3] - Sqrt[2.*3]*Sqrt[2.*3]
This gave a correct result: Sqrt[2.*3]*Sqrt[2*3] - Sqrt[2.*3]*Sqrt[2.*3]
This one's interesting: N[Sqrt[2.*3].Sqrt[2*3] - Sqrt[2.*3].Sqrt[2.*3], 20]

W|A yielded zero for all.

I was just playing around with the period, the dot and the '*' to see what different effects they had.

Last edited by phrontister (2012-05-10 01:47:49)


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Online

#104 2012-05-10 01:48:52

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: sum of digit

The problem I posed is designed to illustrate a technique. It is most effective against calculators. M tries to compensate for roundoff errors and usually does a good job.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#105 2012-05-10 02:02:29

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 4,884

Re: sum of digit

My answer for Sqrt[2.] is 1.4142135623730951, which is the same as Windows Calculator.

It is most effective against calculators.

I'm not sure what you mean by that.


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Online

#106 2012-05-10 02:07:08

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: sum of digit

Hi;

I am talking about the problem with the subtraction of two square roots. Most calculators unless they have extreme amounts of digits will give an answer of zero to that problem. Even M if used incorrectly will give 0.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#107 2012-05-10 02:31:12

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 4,884

Re: sum of digit

bobbym wrote:

Try

Sqrt[2.] Do not forget the period after the 2

Did you mean that I should try that in the difference between the two square roots problem?

My answer for N[Sqrt[2+1/10000000000000000]-Sqrt[2.],50] is 0.

But N[Sqrt[2+1/10000000000000000]-Sqrt[2],50] =
3.5355339059327375778100479863650260262257526608698*10^-17

Why is that?

Also, if I use Sqrt[3.] instead of Sqrt[3] I get a different answer (not zero) than the one you gave. But Sqrt[2.] results in 0. (???)


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Online

#108 2012-05-10 02:40:26

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: sum of digit

Hi;

Did you mean that I should try that in the difference between the two square roots problem?

No, that was meant to test whether you had adjusted your display precision correctly.

The first problem has 16-17 digits of precision. That is not enough to overcome the instability of the question. When you force M to work to 50 digits of precision he was able to get the correct answer.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#109 2012-05-10 02:59:54

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 4,884

Re: sum of digit

Hi Bobby,

W|A gives the right answers even without specifying precision.

When you force M to work to 50 digits of precision he was able to get the correct answer.

But not if I include the period (in my M7). Using 100 digits of precision:

...with Sqrt[3.] instead of Sqrt[3] I get 2.220446049250313*10^-16 instead of 2.88675134594812879848948268627538082462782983934251295103889170779953\
8687162958829196014249435742169*10^-17.

...and with Sqrt[2.] instead of Sqrt[2] I get zero instead of 3.53553390593273757781004798636502602622575266086977757726046890388419\
6341402064375958344406012265096*10^-17.


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Online

#110 2012-05-10 03:07:27

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: sum of digit

Alpha is doing it all automatically for you but it is much less reliable with its answers.


When you put in 2 you have an exact number. When you input 2. you have a floating point number which is just an approximation.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#111 2012-05-10 03:20:16

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 4,884

Re: sum of digit

Yes, I thought it was something like that. Not important with most of what I'd ever do.

Thanks, Bobby. Bed now...


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Online

#112 2012-05-10 03:25:24

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: sum of digit

Not important with most of what I'd ever do.

Could be. But at least you have been exposed to it.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#113 2012-05-10 03:32:56

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 4,884

Re: sum of digit

Yes, thanks for doing that.

Given the degree of precision required in certain fields and that M is so widely used in them (I think), the fact that these anomalies occur is actually quite interesting.

One day everything will be perfect...if we don't blow ourselves into smithereens first.

sleep


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Online

#114 2012-05-10 03:36:44

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: sum of digit

Hi phrontister;

These are not exactly anomalies. They are inherent in the way computers
do arithmetic. This is not well known at all but computers can not divide or subtract. They have trouble multiplying! This is not a software problem.

Have you forgotten a piece of work we did together on using subtraction in LB for a loop counter? That was an example of the difficulties computers have doing arithmetic.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#115 2012-05-10 10:18:35

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 4,884

Re: sum of digit

Good morning, Bobby...time for just this one.

Yes, I do recall that LB loop counter work. That was over two and a half years ago! I'd been a MIF member for only 2 months by then. How time flies when you're having fun! I re-read the old posts.

I hadn't realised until then that computers had difficulties with maths...even more difficulties than I do! And now you've shown they struggle in other areas.

Well, that just proves their human influence (see my signature).

Must go...catch you later.


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Online

#116 2012-05-10 10:22:59

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: sum of digit

Hi phrontister;

I guess man made computers, man makes mistakes, computers make mistakes.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#117 2012-05-13 07:53:20

anonimnystefy
Real Member
From: Harlan's World
Registered: 2011-05-23
Posts: 16,049

Re: sum of digit

phrontister wrote:

Everything in the second set of brackets.

I don't know what this does:

Nor this:

I've seen that funny symbol in other posts but I've never tried to work out what it means.

Hi phro

I remembered you like procedural programming so here is your explanation:

s=0;
for i=1 to n do
s=s+d[i];
end;
return s;

And

is the same as:


“Here lies the reader who will never open this book. He is forever dead.
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment
The knowledge of some things as a function of age is a delta function.

Offline

#118 2012-05-14 00:21:06

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 4,884

Re: sum of digit

Thanks for that, stefy.

It gave me a pretty good understanding of gAr's formula (I think).

I entered the formula into Excel (see image) and I also wrote a little program for it in LibertyBASIC that seems to work fine.

I looked up "sigma summation" on the net to get some more ideas (and MIF has a page on it too), but I'm not ready to travel very far down that road yet.


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Online

#119 2012-05-14 00:22:43

anonimnystefy
Real Member
From: Harlan's World
Registered: 2011-05-23
Posts: 16,049

Re: sum of digit

You're welcome.


“Here lies the reader who will never open this book. He is forever dead.
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment
The knowledge of some things as a function of age is a delta function.

Offline

#120 2012-05-14 00:26:21

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: sum of digit

Hi phrontister;

gAr's formula is made for a CAS rather than Excel.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#121 2012-05-14 02:51:56

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 4,884

Re: sum of digit

Hi Bobby,

Yes, I thought it probably would be, but my mind is on other things at the moment and as it was easy enough to do in Excel I thought I'd at least do it there.

Column A's digits can be deleted and replaced by a choice of digits. As each digit is entered (starting from A3), the adjacent column B cells display the sum of all permutations for the numbers entered...and the other cells also update.

'Conditional formatting' prevents cells from displaying error messages.

Last edited by phrontister (2012-05-14 02:57:53)


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Online

#122 2012-05-14 04:30:25

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: sum of digit

Hi phrontister;

but I'm not ready to travel very far down that road yet.

Supposing there was a number 1357982. To use sigma or summation you
just type:

Sum[i,{i,{1,3,5,7,9,8,2}}]

answer will be 35. Great thing about a CAS, you learn as you go.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#123 2012-05-14 15:43:10

juantheron
Member
Registered: 2011-10-19
Posts: 312

Re: sum of digit

Thanks member for heavy and Nice discussion

Offline

#124 2012-05-14 21:58:30

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: sum of digit

Hi juantheron;

Most of it was about things not directly related to your question. But it is where your question seemed to go.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

Board footer

Powered by FluxBB