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

You are not logged in.

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

anonimnystefy
Real Member
From: The Foundation
Registered: 2011-05-23
Posts: 15,597

Re: Generating Functions

Procedural form?


“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

Offline

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

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 88,521

Re: Generating Functions

Loops and such.


In mathematics, you don't understand things. You just get used to them.

I agree with you regarding the satisfaction and importance of actually computing some numbers. I can't tell you how often I see time and money wasted because someone didn't bother to run the numbers.

Online

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

anonimnystefy
Real Member
From: The Foundation
Registered: 2011-05-23
Posts: 15,597

Re: Generating Functions

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


“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

Offline

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

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 88,521

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 agree with you regarding the satisfaction and importance of actually computing some numbers. I can't tell you how often I see time and money wasted because someone didn't bother to run the numbers.

Online

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

anonimnystefy
Real Member
From: The Foundation
Registered: 2011-05-23
Posts: 15,597

Re: Generating Functions

What would you to sum those terms then?


“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

Offline

#106 2012-04-30 02:03:45

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 88,521

Re: Generating Functions

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


In mathematics, you don't understand things. You just get used to them.

I agree with you regarding the satisfaction and importance of actually computing some numbers. I can't tell you how often I see time and money wasted because someone didn't bother to run the numbers.

Online

#107 2012-04-30 02:08:53

anonimnystefy
Real Member
From: The Foundation
Registered: 2011-05-23
Posts: 15,597

Re: Generating Functions

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-04-30 02:11:39)


“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

Offline

#108 2012-04-30 02:16:17

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 88,521

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 agree with you regarding the satisfaction and importance of actually computing some numbers. I can't tell you how often I see time and money wasted because someone didn't bother to run the numbers.

Online

#109 2012-04-30 02:18:58

anonimnystefy
Real Member
From: The Foundation
Registered: 2011-05-23
Posts: 15,597

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.


“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

Offline

#110 2012-04-30 02:25:02

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 88,521

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 agree with you regarding the satisfaction and importance of actually computing some numbers. I can't tell you how often I see time and money wasted because someone didn't bother to run the numbers.

Online

#111 2012-04-30 03:51:13

anonimnystefy
Real Member
From: The Foundation
Registered: 2011-05-23
Posts: 15,597

Re: Generating Functions

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

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-04-30 03:51:46)


“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

Offline

#112 2012-04-30 04:08:14

anonimnystefy
Real Member
From: The Foundation
Registered: 2011-05-23
Posts: 15,597

Re: Generating Functions

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

Exp GF:

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:

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:

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

The coefficient of EGF:

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-04-30 04:50:58)


“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

Offline

#113 2012-04-30 05:19:51

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 88,521

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 agree with you regarding the satisfaction and importance of actually computing some numbers. I can't tell you how often I see time and money wasted because someone didn't bother to run the numbers.

Online

#114 2012-04-30 05:24:18

anonimnystefy
Real Member
From: The Foundation
Registered: 2011-05-23
Posts: 15,597

Re: Generating Functions

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


“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

Offline

#115 2012-04-30 05:40:32

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 88,521

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 agree with you regarding the satisfaction and importance of actually computing some numbers. I can't tell you how often I see time and money wasted because someone didn't bother to run the numbers.

Online

#116 2012-04-30 05:42:48

anonimnystefy
Real Member
From: The Foundation
Registered: 2011-05-23
Posts: 15,597

Re: Generating Functions

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

Last edited by anonimnystefy (2012-04-30 05:42:59)


“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

Offline

#117 2012-04-30 05:47:32

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 88,521

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 agree with you regarding the satisfaction and importance of actually computing some numbers. I can't tell you how often I see time and money wasted because someone didn't bother to run the numbers.

Online

#118 2012-04-30 05:49:15

anonimnystefy
Real Member
From: The Foundation
Registered: 2011-05-23
Posts: 15,597

Re: Generating Functions

I do not remember that.Where is that from?

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


“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

Offline

#119 2012-04-30 05:53:20

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 88,521

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 agree with you regarding the satisfaction and importance of actually computing some numbers. I can't tell you how often I see time and money wasted because someone didn't bother to run the numbers.

Online

#120 2012-04-30 05:57:31

anonimnystefy
Real Member
From: The Foundation
Registered: 2011-05-23
Posts: 15,597

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.


“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

Offline

#121 2012-04-30 05:58:50

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 88,521

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 agree with you regarding the satisfaction and importance of actually computing some numbers. I can't tell you how often I see time and money wasted because someone didn't bother to run the numbers.

Online

#122 2012-04-30 06:25:40

anonimnystefy
Real Member
From: The Foundation
Registered: 2011-05-23
Posts: 15,597

Re: Generating Functions

Hi bobbym

Inout:

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

Output;

[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)

“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

Offline

#123 2012-04-30 06:38:33

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 88,521

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 agree with you regarding the satisfaction and importance of actually computing some numbers. I can't tell you how often I see time and money wasted because someone didn't bother to run the numbers.

Online

#124 2012-04-30 06:50:17

anonimnystefy
Real Member
From: The Foundation
Registered: 2011-05-23
Posts: 15,597

Re: Generating Functions

Hi bobbym

35/1296?

Okay,see you later!

Last edited by anonimnystefy (2012-04-30 06:51:12)


“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

Offline

#125 2012-04-30 07:55:41

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 88,521

Re: Generating Functions

That is correct! Okay, then use yours.


In mathematics, you don't understand things. You just get used to them.

I agree with you regarding the satisfaction and importance of actually computing some numbers. I can't tell you how often I see time and money wasted because someone didn't bother to run the numbers.

Online

Board footer

Powered by FluxBB