axiom-developer
[Top][All Lists]

## [Axiom-developer] [ExampleSolution1] (new)

 From: Bill Page Subject: [Axiom-developer] [ExampleSolution1] (new) Date: Tue, 15 Mar 2005 04:42:42 -0600

Changes http://page.axiom-developer.org/zope/mathaction/ExampleSolution1/diff
--
Here is one way to write the function N0 so that it returns
a fully symbolic result. The key point is to provide Axiom
with more specific type information.
\begin{axiom}
N0 : Union(Variable t, Expression Integer, Integer) ->
Union(Expression Integer,Integer)
N0(t) ==
if t case Integer then
if (t<0) or (t>1) then
return 0
if (t>=0) and (t<=1) then
return 1
operator('N0)(t)
\end{axiom}
Test the function
\begin{axiom}
N0(t)
N0(-1)
N0(0)
N0(1)
N0(2)
\end{axiom}
Now we can define the function N
\begin{axiom}
N : (Union(Variable t,Expression Integer,Integer), Integer, Integer) ->
Union(Expression Integer,Integer)
N(t,i,p) ==
if p=0 then
return N0(t-i)
else
(t-i)/p*N(t,i,p-1)+(i+1-t)/p*N(t,i+1,p-1)
\end{axiom}
And use it for symbolic calculation
\begin{axiom}
N(t,0,3)
D(N(t,0,3),t)
\end{axiom}
--