[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Re: [Axiom-mail] sum()

**From**: |
David MENTRE |

**Subject**: |
Re: [Axiom-mail] sum() |

**Date**: |
Tue, 22 Jun 2004 18:34:33 +0200 |

**User-agent**: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) |

Hello Daniel,
"Daniel Yokomiso" <address@hidden> writes:
>*> You tried: *
>*> *
>*> > f: Integer -> Integer;*
>*> > f(0)==1; f(1)==2;*
>*> > f(n)==sum(f(i)*f(n-i), i=0..(n-1))*
>*> *
>*> Try*
>*> *
>*> f: Integer -> Integer; *
>*> f(0)==1; f(1)==2; *
>*> f(n)==reduce(+,[f(i)*f(n-i) for i in 1..(n-1)])*
>*> *
>*> I have no good explanation why sum won't work.*
>
>* "sum" doesn't work because your definition is different. The original*
>* has "i" ranging from 0 to (n - 1), while yours ranges from 1 to (n -*
>* 1). Using "i" from 0 makes the definition incorrect.*
I don't agree with you. The range of i was one bug (when i=0,
f(n)=...*f(n-0)...=...*f(n)... -> stack overflow).
But there is another type bug.
-> f: Integer -> Integer; f(0)==1; f(1)==2; f(n)==sum(f(i)*f(n-i), i=1..(n-1))
-> f(3)
Compiling function f with type Integer -> Integer
Conversion failed in the compiled user function f .
Cannot convert from type Variable i to Integer for value
i
sum expects (rationalFunction, symbolOrSegmentBinding), from Axiom book
p. 683 in its paper form (Operations appendix).
f as defined by Marcus is not a rationalFunction and thus cannot be
defined using sum.
reduce is a program loop and not the mathematical Sum operator, that's
why it works.
Yours,
david
--
David MENTRE <address@hidden> -- http://www.nongnu.org/axiom/