simple linsolve from Binninga "Binomial Option Pricing Modle" returns []



Larry Evans <cppljevans at suddenlink.net> writes:
> The following wxmaxima session:
>
> (%i7) InMoney: 55*long+1.06*short=5;
> (%o7) 1.06*short+55*long=5
> (%i8) outMoney: 48.5*long+1.06*short=0;
> (%o8) 1.06*short+48.5*long=0
> (%i9) linsolve([InMoney,OutMoney],[long,short]);
> rat: replaced 1.06 by 53/50 = 1.06
> (%o9) []
>
> give the wrong answeer.

I tried out your code and found the mistake. Here's my transcript:

  Maxima branch_5_30_base_132_gd543604 http://maxima.sourceforge.net
  using Lisp SBCL 1.0.57.0.debian
  Distributed under the GNU Public License. See the file COPYING.
  Dedicated to the memory of William Schelter.
  The function bug_report() provides bug reporting information.
  (%i1) InMoney: 55*long+1.06*short=5;
  (%o1)                      1.06 short + 55 long = 5
  (%i2) outMoney: 48.5*long+1.06*short=0;
  (%o2)                     1.06 short + 48.5 long = 0
  (%i3) solve([InMoney,OutMoney]);

  solve: more unknowns than equations.
  Unknowns given :  
  [OutMoney, short, long]
  Equations given:  
  [1.06 short + 55 long = 5, OutMoney]
   -- an error. To debug this try: debugmode(true);

Hmm. Weird. But look carefully: OutMoney is not the same thing as
outMoney (the former is an unknown variable; the latter is an equation
you defined). Fixing the case:

  (%i4) solve([InMoney,outMoney]);

  rat: replaced 1.06 by 53/50 = 1.06

  rat: replaced 48.5 by 97/2 = 48.5

  rat: replaced 1.06 by 53/50 = 1.06
                                      24250         10
  (%o4)                   [[short = - -----, long = --]]
                                       689          13

Or, calling linsolve():

  (%i5) linsolve([InMoney,outMoney], [long, short]);

  rat: replaced 1.06 by 53/50 = 1.06

  rat: replaced 48.5 by 97/2 = 48.5

  rat: replaced 1.06 by 53/50 = 1.06
                                   10            24250
  (%o5)                    [long = --, short = - -----]
                                   13             689
  (%i6) float(%);
  (%o6)       [long = .7692307692307693, short = - 35.19593613933237]


Here, linsolve() is rather less helpful when given confusing inputs than
solve() is. I suppose it's not really a bug: an overdetermined set of
linear equations just doesn't have any nonzero solutions, so returning
an empty list is the right thing to do.


Rupert
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 315 bytes
Desc: not available
URL: <http://www.math.utexas.edu/pipermail/maxima/attachments/20130823/fcb11576/attachment.pgp>;