# HP Forums

Full Version: HP-48: extract coefficient of power series
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

The following problem was posted recently in a math-forum:

Quote:
Every 10 minutes a bacteria has 3 possible actions. It will die, remain the same, or split into two. The probability of it dying is 1/4, staying the same is 1/4, and splitting is 1/2. All future bacteria share this probability. If you start with one bacteria, what is the probability that there will be exactly 6 bacteria after 30 min?

Among others the following solution was posted:

Quote:
There is a huge literature on this sort of random processes, going under the name of branching processes. For the current problem, define the function f (z)=1/4+1/4z+1/2z2, and consider the third iterate f(f(f(z))), and especially the coefficient in front of z6.

My first attempt to use WolframAlpha failed so I decided to give it a try using my HP-48GX:

```f:   \<< \-> z '(1+z+2*z^2)/4' \>>
g:   \<< \-> z 'f(f(f(z)))' \>>
```

When I calculated g(z) I wondered how to extract the 6th coefficient. So I came up with this solution:

```\<< \-> n
\<<
z g
z n TAYLR
1 n START
z \.d
NEXT
n ! /
\>>
\>>
```

Would there be an easier way to find that coefficient? And does somebody happen to know how to do this calculation with WolframAlpha?

Thomas

Edited: 20 Oct 2012, 8:39 a.m.

With the 50G

'f(z)=(1+z+2*z^2)/4' DEFINE

'f(f(f(z)))' EVAL

->

'(16*z^8+32*z^7+88*z^6+104*z^5+265*z^4+224*z^3+358*z^2+152*z+809)/2048'

The z^6 coef is : 11/256

But I dont understand the mathematical aspect of this....

Edited: 20 Oct 2012, 11:53 a.m.

Quote:
The z^6 coef is : 11/256

Correct! Is there a way to extract that number from the expression? It appears that EVAL behaves differently on the HP-50G. With the HP-48GX the expression I get with f(f(f(z))) isn't changed at all.

Quote:
But I dont understand the mathematical aspect of this....

I had a look at the Wikipedia article Branching process:

Let dn be the extinction probability by the n-th generation.

Then using the generating function f(z) we get: dn+1 = f(dn).

Therefore the extinction probability after k more steps is: dn+k = fk(dn).

After expanding the expression we get: dn+k = fki dni where fki is the i-th coefficient of fk(z).

On the other hand if we knew how many offsprings we have after k steps we could calculate the extinction probability with exactly that sum.

HTH

Thomas

Edited: 21 Oct 2012, 8:34 a.m.

If you simply look at how polynomials multiply, it will tell you a lot.

(1+ax)(1+bx) = 1 + ax + bx + abx^2

If you look at the coefficient of x, which is a+b, it basically "counts" how many x's there are. There's a contribution of "a" from 1+ax and a contribution of "b" from 1+bx.

In the original problem, we have z representing a single population. z^2 would represent when the population splits and now there are two of them. z^3 would mean that we have 3 bacteria -- but they could have arrived in several ways: x splits int x1 and x2, and then x2 splits again while x1 remains fixed would be one example. This would be represented by a product of z and z^2. Or we could also have x1 splitting while x2 remains fixed (this would be a product of z^2 and z).

So (1+2z+z^2)/4 = 1/4 z^0 + 1/2 z^1 + 1/4 z^2

1/4 z^0 = 1/4 probability 0 bacteria

1/2 z^1 = 1/2 probability 1 bacteria remains at 1

1/4 z^2 = 1/4 probability 1 bacteria splits into two (z^2).

[(1+2z+z^2)/4 ]^2 -- this would represent two cycles, and let's consider the coefficients of z's.

z^0 = 0 bacteria:
How do we obtain the coefficient of z^0 -- the only way is from 1/4z^0 * 1/4z^0 = 1/16z^0

z^1 = 1 bacteria:
How do we obtain the coefficient of z^1 -- the only way is from 1/4z^0 * 1/2z^1 OR 1/2z^1 * 1/4z^0 = 1/8z^1 + 1/8z^1 = 1/4z^1
(the 1/4z^0 from the first (1+2z+z^2)/4 multiplied with the 1/2z from the second (1+2z+z^2)/4, and vice versa).

z^2 = 2 bacteria:
How do we obtain the coefficient of z^2 -- the only way is from
1/4z^0 * 1/4z^2 = 1/16*z^2

OR

1/2z^1 * 1/2z^1 = 1/4*z^2

OR

1/4z^2 * 1/4z^0 = 1/16*z^2

Summing up: 3/8*z^2

etc.

So when you consider how polynomial multiplication works, it matches up precisely with the sum and/or product of probabilities based on possible outcomes.

Edited: 21 Oct 2012, 11:58 p.m.