axiom-developer
[Top][All Lists]

## [Axiom-developer] [Piecewise Functions] (new)

 From: Bill Page Subject: [Axiom-developer] [Piecewise Functions] (new) Date: Tue, 21 Jun 2005 23:18:53 -0500

Changes http://page.axiom-developer.org/zope/mathaction/PiecewiseFunctions/diff
--
Consider the following function, given in recursive manner:
\begin{axiom}
N0(t|(t<0) or (t>1))==0
N0(t|(t>=0) and (t<=1))==1
N(t,i,0)==N0(t-i)
N(t,i,p|p>0)==(t-i)/p*N(t,i,p-1)+(i+1-t)/p*N(t,i+1,p-1)
\end{axiom}
This is a way to create (uniform) bsplines. Now try to differentiate $N$
\begin{axiom}
D(N(t,0,3),t)
\end{axiom}

Yack!!! This is obviously wrong! $t\mapsto N(t,0,3)$ is $C^2$ continuous
and **is not constant** Despite what Axiom seems to claim here.

\begin{axiom}
N(t,0,3)
\end{axiom}

On the other hand the function is not constant.
See this:
\begin{axiom}
N0(t|(t<0) or (t>1))==0;
N0(t|(t>=0) and (t<=1))==1;
N(t,i,0)==N0(t-i);
N(t,i,p|p>0)==(t-i)/p*N(t,i,p-1)+(i+1-t)/p*N(t,i+1,p-1);
for x in -5..15 repeat output N(x/10,0,3)
\end{axiom}

Drawing the plot (unfortunately not available here) would
show it even more clearly.

But in 'D(N(t,0,3),t)' you are not calling the function N
with numeric parameters. In 'N(t,0,3)' the type of t is
'Variable t'. Ultimately 'N(t,0,3)=0' because of your function
definition 'N0(t|(t<0) or (t>1))==0'. This is '0' because
't>1' is 'true' when 't' is of type 'Variable t'. You can
see why if you use the option ')set message bottomup on' to
see the mode map selection
\begin{axiom}
)set message bottomup on
t>1
\end{axiom}

Axiom interprets both 't' and '1' as being of type 'POLY INT'
and the function '>' is defined by the lexical ordering of the
polynomials.

This result is counter-intuitive, but once you understand why
Axiom gives this result then you will be in a good position to
understand the rest of Axiom's type system!

It is possible to write the function N0 so that it returns the
desired result. See ExampleSolution1.

--