Strange behaviour in a simple problem



forwarded 194650 maxima@www.ma.utexas.edu
thanks

Greetings!  This bug has been filed by a Debian maxima user and looks
to be an issue with maxima proper.  I'm away from my email until 6/1,
and cannot receive sourceforge mail as my ISP blocks it as spam.  I
therefore cannot usefully register the bug on the website.  Please
excuse therefore the submission to this list instead.



Package: maxima
Version: 5.9.0-10
Severity: normal

I am trying to use maxima in a simple situation - writing down a
complicated function and differentiating it.

The attached file 'working' is a first case where things seem to be
fine. When I make this slightly more complicated, in the file
'bugdemo', things break badly.

In 
$ maxima < bugdemo

one gets absolute junk like:

Derivative in b0: 
(C10) 
(D10) - (0.01 t1

                                               - t1/TAU
               - t1/TAU   (B2 + B1) TAU (1 - %E        )           - t1 - 1
 (0.01 (- B2 %E         + ------------------------------ + b0) + 1)
                                        t1

                                   d
 PRINT(The NS functional form) - (--- (ns(b0, B1, B2, TAU, t) := 
                                  db0

                        - t
                1 - EXP(---)
                        TAU                - t
b0 + (B1 + B2) (------------) + (- B2) EXP(---)))
                     t                     TAU
                    ---
                    TAU


This is all quite strange. The string 'PRINT(The NS functional form)'
has no business to be in an expression. The string ':=' is appearing
in the output.

I am very new to maxima so this might well be something very obvious
which I might be missing.

Thanks,

        -Susan

-- System Information:
Debian Release: testing/unstable
Architecture: i386
Kernel: Linux zoe 2.4.20-xfs #1 SMP Die Dez 10 20:07:25 CET 2002 i686
Locale: LANG=C, LC_CTYPE=C

Versions of packages maxima depends on:
ii  libc6                     2.3.1-16       GNU C Library: Shared libraries an
ii  libgmp3                   4.1.2-3        Multiprecision arithmetic library
ii  libncurses5               5.3.20021109-2 Shared libraries for terminal hand
ii  libreadline4              4.3-4          GNU readline and history libraries
ii  tk8.3 [wish]              8.3.5-1        Tk toolkit for Tcl and X11, v8.3 -
ii  tk8.4 [wish]              8.4.2-2        Tk toolkit for Tcl and X11, v8.4 -

-- no debconf information


-- 
---------------------------------------------------------------------
Susan Thomas                                 Work +91-22-8400919 x550
susant@mayin.org                             Fax  +91-22-8402752
http://www.igidr.ac.in/~susant

Assistant Professor                          
Indira Gandhi Institute of Development Research,
Bombay, India

=============================================================================
Working example:
=============================================================================
print("The NS functional form")$
ns(b0,b1,b2,tau, t) := b0 + (b1+b2)*((1-exp(-t/tau))/(t/tau)) - b2*exp(-t/tau);

print("The log phi function")$
phi(x) := exp(-x*x/2)/sqrt(2*pi);
lphi(x) := log(phi(x));

print("A bond with 1 cashflow")$
mp(c,T, b0,b1,b2,tau) := c*((1 + 0.01*ns(b0,b1,b2,tau, T))^-T);
l(p, c,T, b0,b1,b2,tau,sigma) := lphi((p - mp(c,T, b0,b1,b2,tau))/sigma);
print("Derivative in b0:")$
diff(l(p, c,T, b0,b1,b2,tau,sigma), b0);
print("Derivative in b1:")$
diff(l(p, c,T, b0,b1,b2,tau,sigma), b1);
print("Derivative in b2:")$
diff(l(p, c,T, b0,b1,b2,tau,sigma), b2);
print("Derivative in tau:")$
diff(l(p, c,T, b0,b1,b2,tau,sigma), tau);

=============================================================================
Failing example:
=============================================================================
print("The NS functional form")$
ns(b0,b1,b2,tau, t) := b0 + (b1+b2)*((1-exp(-t/tau))/(t/tau)) - b2*exp(-t/tau);

print("The log phi function")$
phi(x) := exp(-x*x/2)/sqrt(2*pi);
lphi(x) := log(phi(x));

print("Market price of a bond with two cashflows")$
m2p(c1,c2,t1,t2, b0,b1,b2,tau) := (c1*((1 + 0.01*ns(b0,b1,b2,tau, t1))^-t1))
                                  +
                                  (c2*((1 + 0.01*ns(b0,b1,b2,tau, t2))^-t2));

l(p, c1,c2,t1,t2, b0,b1,b2,tau,sigma) :=
  lphi((p - m2p(c1,c2,t1,t2, b0,b1,b2,tau))/sigma);
print("Derivative in b0:")$
diff(l(p, c1,c2,t1,t2, b0,b1,b2,tau,sigma), b0);
print("Derivative in b1:")$
diff(l(p, c1,c2,t1,t2, b0,b1,b2,tau,sigma), b1);
print("Derivative in b2:")$
diff(l(p, c1,c2,t1,t2, b0,b1,b2,tau,sigma), b2);
print("Derivative in tau:")$
diff(l(p, c1,c2,t1,t2, b0,b1,b2,tau,sigma), tau);
=============================================================================