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

Login

Username

Password

Not registered yet?

#101 2012-04-30 23:45:25

anonimnystefy
Real Member

Offline

Re: Generating Functions

Procedural form?


The limit operator is just an excuse for doing something you know you can't.
“It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment
 

#102 2012-04-30 23:48:35

bobbym
Administrator

Offline

Re: Generating Functions

Loops and such.


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.
 

#103 2012-04-30 23:50:12

anonimnystefy
Real Member

Offline

Re: Generating Functions

There is no other way.At least not that I know of.But Maxima allows while loops.


The limit operator is just an excuse for doing something you know you can't.
“It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment
 

#104 2012-04-30 23:51:23

bobbym
Administrator

Offline

Re: Generating Functions

While loops are procedural. Why are you not using math commands to do math?


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.
 

#105 2012-04-30 23:58:25

anonimnystefy
Real Member

Offline

Re: Generating Functions

What would you to sum those terms then?


The limit operator is just an excuse for doing something you know you can't.
“It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment
 

#106 2012-05-01 00:03:45

bobbym
Administrator

Offline

Re: Generating Functions

Sum[x^k,k,1,6] yields


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.
 

#107 2012-05-01 00:08:53

anonimnystefy
Real Member

Offline

Re: Generating Functions

Code:

CombGF(list) := block([i, a, m, s],
i = 1,
m = 1,
while i <= length(list) do
[
a = get(list,i),
s=sum(x^k/k!,k,1,i),
m = m * s,
delete(a,list,1),
i = i + 1
],
print(m)
);

Last edited by anonimnystefy (2012-05-01 00:11:39)


The limit operator is just an excuse for doing something you know you can't.
“It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment
 

#108 2012-05-01 00:16:17

bobbym
Administrator

Offline

Re: Generating Functions

You do not need the while loop and you are jumping ahead. Let's get the OGF's down first.

To have the probability gf for 2 die:

Sum[x^k/6,k,1,6]^2 yields


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.
 

#109 2012-05-01 00:18:58

anonimnystefy
Real Member

Offline

Re: Generating Functions

I want the function to do everything for me.I just have to input 6,6 instead of just 6 to get probability for 2 dice.


The limit operator is just an excuse for doing something you know you can't.
“It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment
 

#110 2012-05-01 00:25:02

bobbym
Administrator

Offline

Re: Generating Functions

I want the function to do everything for me.I just have to input 6,6 instead of just 6 to get probability for 2 dice.

That is overkill. You make functions that do the minimum and use other commands on them. You do not try to make functions to do everything.

You make a function that inputs the parameters you need and then you use the series inside the function.

Here is pseudocode:

gf(a,b,d)

Begin:

Sum[x^k/d,k,a,b]

End:

Now when you call gf(1,6,6) you get:



Congratulations you just threw a die!

To throw 2 you just go

gf(1,6,6)^2

Simple, no need to make a function throw  n die when you just have to square or cube or raise to the 10th power...

I want you to work on creating a function gf that inputs the 3 parameters as I have indicated.


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.
 

#111 2012-05-01 01:51:13

anonimnystefy
Real Member

Offline

Re: Generating Functions

This code both compiles and runs,but doesn't give a good output:

Code:

CombGF(list) := block([i, a, m, s],
i : 1,
m : 1,
while i <= length(list) do
[
a : first(list),
print(a),
s : sum(x^k, k, 0, a),
m : m * s,
list:rest(list),
i : i + 1
],
print(m)
);

and the output for:

list:[1,1,2,3];
CombGF(list);

is:

[1,1,2,3]
1
1
(x+1)^2

Last edited by anonimnystefy (2012-05-01 01:51:46)


The limit operator is just an excuse for doing something you know you can't.
“It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment
 

#112 2012-05-01 02:08:14

anonimnystefy
Real Member

Offline

Re: Generating Functions

Done it! Could you do a little test on the code:

Exp GF:

Code:

CombEGF(list) := block([i, a, m, s],
i : 1,
m : 1,
l : length(list),
while i <= l do
[
a : first(list),
s : sum(x^k/k!, k, 0, a),
m : m * s,
list : rest(list),
i : i + 1
],
m
);
©anonimnystefy 2012

Ordinary GF:

Code:

CombOGF(list) := block([i, a, m, s],
i : 1,
m : 1,
l : length(list),
while i <= l do
[
a : first(list),
s : sum(x^k, k, 0, a),
m : m * s,
list : rest(list),
i : i + 1
],
m
);
©anonimnystefy 2012

The coefficient of OGF:

Code:

OGFcoeff(list,n) := ratcoeff(CombOGF(list),x^n);
©anonimnystefy 2012

The coefficient of EGF:

Code:

EGFcoeff(list,n) := ratcoeff(CombEGF(list),x^n)*n!;
©anonimnystefy 2012

Notice that I multiply by n! in the EGFcoeff function to get the final result immediately.

Last edited by anonimnystefy (2012-05-01 02:50:58)


The limit operator is just an excuse for doing something you know you can't.
“It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment
 

#113 2012-05-01 03:19:51

bobbym
Administrator

Offline

Re: Generating Functions

Hi;

Please look at my hidden text message in post 110.


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.
 

#114 2012-05-01 03:24:18

anonimnystefy
Real Member

Offline

Re: Generating Functions

I did even more than that.The function CombOGF can create those generating functions.


The limit operator is just an excuse for doing something you know you can't.
“It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment
 

#115 2012-05-01 03:40:32

bobbym
Administrator

Offline

Re: Generating Functions

You missed alot of what I am trying to say by sticking to the procedural
approach. It is not uncommon for people being introduced into new
fields to try to keep what they already know.

While this is usually a good idea in the case of programming it can
be disastrous. I wanted you to tear down your Pascal or Basic famework
and learn another one.


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.
 

#116 2012-05-01 03:42:48

anonimnystefy
Real Member

Offline

Re: Generating Functions

But this solution works.It is applicable in many situations.

Last edited by anonimnystefy (2012-05-01 03:42:59)


The limit operator is just an excuse for doing something you know you can't.
“It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment
 

#117 2012-05-01 03:47:32

bobbym
Administrator

Offline

Re: Generating Functions

I understand that it is tough to do what I ask. Of the two people I taught neither could accomplish it. Perhaps you remember this:

Yibka: Once you start down the path of procedural programming forever will it
dominate your destiny, consume you it will as it did Bit One's apprentice.

Lukky: Is the procedural paradigm stronger?

Yibka: No, no no! Easier! More seductive...


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.
 

#118 2012-05-01 03:49:15

anonimnystefy
Real Member

Offline

Re: Generating Functions

I do not remember that.Where is that from?

But,I am willing to try if you have the patience.


The limit operator is just an excuse for doing something you know you can't.
“It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment
 

#119 2012-05-01 03:53:20

bobbym
Administrator

Offline

Re: Generating Functions

I do not remember that.Where is that from?

I think we have been lied to on every level by our masters. I was assured many times that that was standard knowledge.

But,I am willing to try if you have the patience.

I have the patience but do have I have the lifespan of several millenia?


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.
 

#120 2012-05-01 03:57:31

anonimnystefy
Real Member

Offline

Re: Generating Functions

Well you have already live hundreds of millenia,so that won't be the problem.Let's get started if you want.


The limit operator is just an excuse for doing something you know you can't.
“It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment
 

#121 2012-05-01 03:58:50

bobbym
Administrator

Offline

Re: Generating Functions

Show me a full output of your best and most complicated example using your function.


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.
 

#122 2012-05-01 04:25:40

anonimnystefy
Real Member

Offline

Re: Generating Functions

Hi bobbym

Inout:

Code:

list : [1,2,3,4,5,6,7,8,9,10,11,12,13];
CombOGF(list);

Output;

Code:

[1,2,3,4,5,6,7,8,9,10,11,12,13]
(%o74) (x+1)*(x^2+x+1)*(x^3+x^2+x+1)*(x^4+x^3+x^2+x+1)*(x^5+x^4+x^3+x^2+x+1)*(x^6+x^5+x^4+x^3+x^2+x+1)*
(x^7+x^6+x^5+x^4+x^3+x^2+x+1)*(x^8+x^7+x^6+x^5+x^4+x^3+x^2+x+1)*(x^9+x^8+x^7+x^6+x^5+x^4+x^3+x^2+x+1)*
(x^10+x^9+x^8+x^7+x^6+x^5+x^4+x^3+x^2+x+1)*(x^11+x^10+x^9+x^8+x^7+x^6+x^5+x^4+x^3+x^2+x+1)*
(x^12+x^11+x^10+x^9+x^8+x^7+x^6+x^5+x^4+x^3+x^2+x+1)*
(x^13+x^12+x^11+x^10+x^9+x^8+x^7+x^6+x^5+x^4+x^3+x^2+x+1)

The limit operator is just an excuse for doing something you know you can't.
“It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment
 

#123 2012-05-01 04:38:33

bobbym
Administrator

Offline

Re: Generating Functions

Okay, how do you throw a die 4 times and get the probability of having the
sum of them equal 20?

Taking a break, be back in a while.


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.
 

#124 2012-05-01 04:50:17

anonimnystefy
Real Member

Offline

Re: Generating Functions

Hi bobbym

35/1296?

Okay,see you later!

Last edited by anonimnystefy (2012-05-01 04:51:12)


The limit operator is just an excuse for doing something you know you can't.
“It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment
 

#125 2012-05-01 05:55:41

bobbym
Administrator

Offline

Re: Generating Functions

That is correct! Okay, then use yours.


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.
 

Board footer

Powered by FluxBB