# [Maxima] On broken wheels and user contributed code

Richard Hennessy rich.hennessy at verizon.net
Thu Jun 4 15:41:21 CDT 2009

```You are probably right that the Fourier expansion is used a lot but using periodic is much faster and is not an approximation to the
function.

try

f(x):= ''(periodic(pw([-10,-x^3,0,-x^2,10],x),x,-10,10));

This is the fastest way.  By the way my email has been down for a while but it is back up again, hence the late reply.

Rich

----- Original Message -----
From: "dlakelan" <dlakelan at street-artists.org>
To: "Richard Hennessy" <rich.hennessy at verizon.net>; "Maxima Mailing List" <maxima at math.utexas.edu>
Sent: Tuesday, May 26, 2009 5:41 PM
Subject: Re: [Maxima] On broken wheels and user contributed code

Richard Hennessy wrote:
> Maybe I should have explained this better.
>
> periodic(expr,x,a,b):=
> block
> (
>     ratsubst(a+mod(x,b-a),x,expr)
> )\$
>
> The idea is the expr is modified so it repeats it's behavior between a and b for all x an infinite number of times.  Hence the
> name
> periodic.
>
> Rich

Rich, this sounds like a somewhat useful concept but by the time you
have a periodic function perhaps expansion in terms of sin and cos are a
better way to get approximations?

It seems to me the most useful reason for the PW package is to replicate
the typical stuff done in engineering where people just fit a few
piecewise polynomials through or around a cloud of datapoints and then
codify it into law saying "this is the function to use to evaluate the
behavior of xyz". See for example the AISC steel design buckling
strength equations, or the typical way in which people represent stress
vs strain for materials that have different "regimes" like elastic /
plastic models.

```