# [Maxima] Integrating abs(x)?

Alasdair McAndrew amca01 at gmail.com
Mon Jul 14 16:11:24 CDT 2008

```Thanks for your replies.  What I really want to do is calculate the total
variation of some functions f; this being defined as the integral of the
absolute value of the derivative of f (see
http://en.wikipedia.org/wiki/Total_variation).  The integral of abs was just
a test case.

I can probably use pmint, but the results it produces aren't really useful.
For example:

(%i1) pmint(abs(sin(x)),x);
(%o1) -cos(x)*abs(sin(x))/sin(x)

which is true, but doesn't allow me to enter values for which sin(x)=0.
This is too restrictive.

I could probably do all this numerically, but I would rather obtain
closed-form solutions than numerical approximations.

I'll keep fiddling.

cheers,
Alasdair

On Tue, Jul 15, 2008 at 1:19 AM, Barton Willis <willisb at unk.edu> wrote:

> You can try pmint. Last I checked, you can download pmint from
> http://wxmaxima.sourceforge.net/pmint.mac.
> I don't know enough about how pmint works to know if my value for the
> darboux polynomial of the absolute
> value function is correct. So be careful!
>
> Examples:
>
> (%i9) put(abs, [lambda([u], u), true], 'darboux_poly)\$
>
> (%i11) pmint(abs(x),x);
> (%o11) (x*abs(x))/2
>
> (%i12) pmint(abs(6*x),x);
> (%o12) 3*x*abs(x)
>
> (%i13) pmint(x * abs(x/5),x);
> (%o13) (x^2*abs(x))/15
>
> (%i14) pmint(x^2 * abs(x^3),x);
> Solution check failes!
> (%o14) (x^3*abs(x)^3)/6
>
> (%i15) ratsimp(diff(%,x));
> (%o15) (x^2*abs(x)^3+x^4*abs(x))/2
>
> Barton
>
>

--
Blog: http://amca01.wordpress.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.math.utexas.edu/pipermail/maxima/attachments/20080715/e91fb3b2/attachment.htm
```