# [Maxima] suppressing error messages

Barton Willis willisb at unk.edu
Tue Sep 16 07:06:15 CDT 2008

```Do we have a way to suppress error messages? I tried ttyoff : true,
but that didn't work.

It might be nice if errcatch automatically suppressed error
messages. Example: 'safer_subst' substitutes into an algebraic
expression. When the substitution yields division by zero, it
rationalizes the expression and tries again: (Alternatively, 'limit'
might be a better way to do this; nevertheless, I'd still like to know
how to suppress error messages).

(%i29) sol : solve(a*x^2 + x + 1,x);
(%o29) [x=-(sqrt(1-4*a)+1)/(2*a),x=(sqrt(1-4*a)-1)/(2*a)]

I'd like to suppress the division by 0 messages:

(%i30) safer_subst([a=0],sol);
Division by 0
Division by 0
(%o30) [x=und,x=-1]

equationp(e) := block([inflag : true], not(mapatom(e)) and is(op(e) =
"="));

recip(e) := if listp(e) or equationp(e) then map('recip, e)
else if is(equal(e,0))=true then 'und else 1/e;

safer_subst(l, e) := block([algebraic : true, r, ttyoff : true],
if listp(e) or equationp(e) then map(lambda([s], safer_subst(l,s)), e)
else (
r : errcatch(subst(l,e)),
if emptyp(r) then recip(safer_subst(l, ratsimp(1/e))) else first(r)));

Barton

```