Math Is Fun Forum

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

You are not logged in.

#51 2012-05-07 22:26:28

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

Re: sum of digit

Did I? Well I never!


"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

#52 2012-05-07 22:30:29

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

Re: sum of digit

Yes, the select command is a big one. You used a pure function # and &, that is from the lambda calculus.


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

#53 2012-05-07 22:39:39

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

Re: sum of digit

That's a bit heavy for this lightweight. I copied the formula from the Help files, and I don't know (yet) what those functions actually do.

I remember using the double '&&' in my YOB puzzle solution and knew then what it did, but I don't know what a single '&' does.

I don't know any calculus, other than what you said I now 'know'.

Last edited by phrontister (2012-05-07 22:40:18)


"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

#54 2012-05-07 22:49:42

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

Re: sum of digit

# this is a slot operator, & this is the end of the operation or function.

Select[{1,2,3,4,5,6},#>5&]

Will yield just 6. Do you see why?

I don't know any calculus, other than what you said I now 'know'

If you can use M you know more calculus than I could ever hope to.


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

#55 2012-05-07 23:09:58

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

Re: sum of digit

I don't know the term 'slot operator' , or what # really does. I remember using # for alphametics solutions.

'6' is the element selected from the list by the '>5' constraint, which omits all numbers <=5. Same as in my use of Select for juan's problem.

Last edited by phrontister (2012-05-07 23:13:09)


"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

#56 2012-05-07 23:17:15

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

Re: sum of digit

The Select operator in this case goes down the list and picks them one at time and puts them in the slot ( # ) 1 > 5, 2 > 5, 3>5, 4>5, 5>5, 6>5. Only the 6>5 is true so that is the one that is returned. The #>5& is called a pure function because it has no name for itself or its parameters.


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

#57 2012-05-07 23:23:51

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

Re: sum of digit

Is the slot operator like the mapping operation I used earlier with FromDigits /@ Permutations?


"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

#58 2012-05-07 23:26:11

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

Re: sum of digit

Mapping is different. Mapping (/@) takes any function like FromDigits or one you write yourself and spreads it to every element of the list.


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

#59 2012-05-07 23:47:22

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

Re: sum of digit

Oh, I see. A kind of similar action with different tools.

The #>5& is called a pure function because it has no name for itself or its parameters.

I had no idea what 'pure function' meant. I thought it could be some highfalutin term like 'pure maths'!


"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

#60 2012-05-07 23:49:40

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

Re: sum of digit

Hi;

Not exactly similar. I have corrected post # 56 to be accurate. That will help.


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

#61 2012-05-08 00:23:01

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

Re: sum of digit

Not exactly similar.

I was really only referring to the fact that they both act on each element in the list...but I suppose there are many other commands that do too.

What is a 'slot'? Is it an area into which elements (for example) are put to facilitate performing some action on them?


"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

#62 2012-05-08 00:31:07

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

Re: sum of digit

I meant to tell you I used the wrong word in post #56. I meant Select, not slot.

Yes, the slot can be thought of as a generic variable. Data is put into it.

In other laguages you would have had to make up a function and given it a name. For instance

test(n)= If n>5 return n

That function ( in some language) when you put in test(6) it would return a 6. The pure function #>5& did the same thing but you did not have to name the input or the function.


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

#63 2012-05-08 01:34:07

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

Re: sum of digit

Ah, yes. That clears that up. I hadn't worked out what it was that you'd corrected.

...generic variable

That reminds me of the '@' in BASIC, which allows you to use a single array without having to DIM it like you'd have to with variable letters.


"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

#64 2012-05-08 02:00:28

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

Re: sum of digit

Hi phrontister;

Have fun with M. You are doing well with it. It is a little different but I like the fact that all the commands can map themselves over lists. Some like Sine do that automatically

Sin[{1,2,3,4,5}] will output,

see how Sine has wrapped itself around each element? No more loops!


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

#65 2012-05-08 02:42:00

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

Re: sum of digit

Hi Bobby,

I didn't know the extent of the mapping effect.

Here's one I got to work:

In[1]:= Total[N[Sqrt[{1, 2, 3, 4, 5}]]]

Out[1]= 8.38233

The range of stuff you can do with M is staggering!!!


"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

#66 2012-05-08 02:47:38

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

Re: sum of digit

Hi phro

Look at bobbym's problem in Bafflers with sqare root. Tell me if M works it out.


“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

#67 2012-05-08 02:50:20

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

Re: sum of digit

Hi;

The range of stuff you can do with M is staggering!!!

Yes, it makes me look good, that is staggering in itself.

N[Sqrt[Range[5]],50]//Total

yields

8.3823323474417620387383087344468466809530954887989


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

#68 2012-05-08 02:53:07

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

Re: sum of digit

A little tweak:

In[1]:= N[Total[Sqrt[{1, 2, 3, 4, 5}]], 50]

Out[1]= 8.3823323474417620387383087344468466809530954887989

The list is endless! And the calcs are so quick!


"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

#69 2012-05-08 02:53:55

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

Re: sum of digit

We think alike, look at my post above you!


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

#70 2012-05-08 02:58:28

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

Re: sum of digit

Hey! Did you see my post and copy it, and then snuck it in before mine (with a customised post time)??!


"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

#71 2012-05-08 02:59:41

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

Re: sum of digit

No, I did not but it is spooky!


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

#72 2012-05-08 03:05:12

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

Re: sum of digit

I now believe in ESP!

You introduced Range. I remember coming across that earlier today but didn't think to use it here.

What does '//' do? Is there an advantage using that option instead of mine?


"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

#73 2012-05-08 03:07:42

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

Re: sum of digit

Yes you do not have to match brackets or type them. Sometimes bracket matching is a pain.

100! //N is the same as N[100!]


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

#74 2012-05-08 03:13:27

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

Re: sum of digit

Yes, I see. Thanks.


"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

#75 2012-05-08 03:14:31

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

Re: sum of digit

Hi stefy,

Just looking at that problem 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

Board footer

Powered by FluxBB