# [Maxima] rat and bothcoef error

nijso beishuizen nijso at hotmail.com
Tue Feb 21 03:02:09 CST 2012

```Hello Richard and others,

The bothcoef description doesn't say that expr needs to be in polynomial form. Bothcoef calls ratcoef or coeff if I understand the manual correctly? So there is the need for expr to be in polynomial form because it calls the other routines.

I need something like the example in bothcoef, a routine that checks if expr is a linear function of the form a*x+b (I don't actually need to know a and b). The problem is that the expression can contain anything except differential operators (so also sin(x), 1/x, integrals and unknown functions like f(x)).

I have browsed the manual and maybe a better method would be to use the example from defmatch then:
(%i1) matchdeclare (a, lambda ([e], e#0 and freeof(x, e)), b, freeof(x));
(%o1)                         done
(%i2) defmatch (linearp, a*x + b, x);

This seems to do work... Well at least I understand now why bothcoef is not supposed to work on general expressions. Thanks!
Kind regards,
Nijso

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.math.utexas.edu/pipermail/maxima/attachments/20120221/2422fdb9/attachment.html>
```