[Maxima] Maxima values scheme

Barton Willis willisb at unk.edu
Tue Feb 20 13:57:34 CST 2007

```I'll take the [sol, condition number or false] idea:

(%i25) m : matrix([7,8],[1,2])\$
(%i26) b : matrix([1],[4])\$
(%i27) linsolve_by_lu(m,b);
(%o27) [matrix([-5],[9/2]),false]

(%i28) linsolve_by_lu(m,b,floatfield);
(%o28) [matrix([-5.0],[4.5]),25.30612244897958]

(%i29) linsolve_by_lu(m,b,bigfloatfield);
(%o29) [matrix([-5.0b0],[4.5b0]),25.30612244897958]

(%i30) mat_cond(m,'inf);
(%o30) 25

Thank you for letting me think out loud.

Barton

"Robert Dodier" <robert.dodier at gmail.com> wrote on 02/20/2007 01:40:03 PM:

> On 2/20/07, Barton Willis <willisb at unk.edu> wrote:
>
> > I could make linsolve_by_lu *always* return a two member list
> > [sol, cnd].
>
> I think that is the right thing to do.
>
> > But lu_factor doesn't compute a condition number
> > when it uses exact numbers. In this case, I think it would be
> > ok for cnd to be 0.
>
> I'll recommend a nonnumeric value here. How about false.
>
> > I don't like making a new global, say lu_condition, that gets
> > assigned to the latest condition number.
>
> Agreed -- returning information via globals is a mess.
>
> > As you suggest if [p] : [1,2] would just assign p and trash the
> > 2 might be ok too.
>
> Yeah -- the CL multiple-value stuff works like that, doesn't it?
> Not that we are obligated in any way, shape, or form to follow CL.
>
> With the CL multiple-value stuff, the caller can safely pretend that a
> multiple-value function has returned only one value.
> If in Maxima multiple values were represented as ordinary lists,
> that couldn't work the same. Maybe multiple values need to be
> represented by something other than a list, e.g. values(a, b, c).
> Just a thought.
>
> Robert
```