axiom-developer
[Top][All Lists]

## [Axiom-developer] [ExampleSolution1] Still a problem.

 From: wyscc Subject: [Axiom-developer] [ExampleSolution1] Still a problem. Date: Wed, 16 Mar 2005 05:31:31 -0600

Changes http://page.axiom-developer.org/zope/mathaction/ExampleSolution1/diff
--

)clear all

<pre>From wyscc, March 16, 2005 05:06:00</pre>

The above does not really solve the problem on differentiation of a piecewise
function, which, in my opinion, is an unreasonable expectation in general
because of the multitude of ways to define the conditions; it may help if one
uses the Heaviside function. The numerical definition of <code>N0(t)</code> is
actually totally ignored in the definition of <code>N(t,i,p)</code> and thus
also in the differentiation process, by the use of
<code>operator('No)(t)</code>. Indeed, in the expression for <code>N</code> or
its derivative with respect to <code>t</code>, the  "function" <code>N0</code>
is still an <code>operator</code>, and as such, <code>N0(2)</code> is
undefined! In other words, there is a distinction between the numerically
defined function <code>N0</code> and the operator <code>N0</code>. This is
illustrated below.

Aside: I am getting into something I don't quite understand: the first group of
code is not meant to be there, but it somehow returns something wrong. If the
commented line <code>--dNdt(t)</code> is removed, the result for the
<code>subst</code> line is what I expect. If the order of the commands is as
for the second group, the result is ok too.
Finally if I copied the block to the end and run it a second time, everything
is also ok. But his may go away after I save. Image is in:
http://page.axiom-developer.org/zope/mathaction/images/1141703130-18px.png.

\begin{axiom}
N(2,0,3)
dNdt(t)==D(N(t,0,3),t)
--dNdt(t)
subst(dNdt(t), t=2)
dNdt(2)
\end{axiom}

Compared with

\begin{axiom}
dNdt(t)==D(N(t,0,3),t)
subst(dNdt(t), t=2)
N(2,0,3)
dNdt(2)
\end{axiom}

Notice that the evaluation for <code>N0(2)</code> is not really done. One way
to avoid this error is to use substitution instead of a function call, as done
in the second line above.

The last function call <code>dNdt(2)</code> is deliberate, to illustrate a
common error when mixing numeric and symbolic computation: first define the
derivative as a function of <code>t</code> and then evaluate the derivative at
some value of <code>t</code>. This does not work because when the derivative is
called the system (Axiom, or other systems) will substitute the value of
<code>t</code> before differentiating.

\begin{axiom}
N(2,0,3)
dNdt(t)==D(N(t,0,3),t)
--dNdt(t)
subst(dNdt(t), t=2)
dNdt(2)
\end{axiom}

--