function, return



Hi,

I have 2 functions :
Give_G[p]
GiveG[p]

The return value should be the same  polynomial
Testing for p:4 gives diffrent results.
GiveG[p] gives good result.
Why is it ?

Regards

Adam



===========================
f(z,c):=z*z+c $

/* iterated function */
fn(n, z, c) :=
     if n=1 	then f(z,c)
			else f(fn(n-1, z, c),c) $
/* roots of Fn are periodic point of  fn function */
Fn(n,z,c):=fn(n, z, c)-z $

/*  Gn = irreducible divisors of Fn */

/* gives irreducible divisors of polynomial */
GiveG[p]:=
block(

  [f:divisors(p),t:1],
  g,
  f:delete(p,f),
  if p=1
	then return(Fn(p,0,c)),
  for i in f do t:t*GiveG[i],
  g: Fn(p,0,c)/t,
  return(ratsimp(g))
   )$


/* gives bad results for p:4 */
Give_G[p]:=
block(
  /* local variables */
  [f:divisors(p), /* list of divisors of p */
  t:1],           /* t is temporary variable = product of Gn for 
(divisors of p) other then p */
  g:Fn(p,0,c),	 /* c is a center when z=0  is periodic */
  f:delete(p,f), /* delete p from list of divisors */

  if p=1 then return(g),
  /* else */
  for i in f do t:t*GiveG[i],
  g: g/t,
  return(ratsimp(g))
   )$