[Maxima] simplifying sums of numbers
robert.dodier at gmail.com
Sat Dec 30 00:32:36 CST 2006
On 12/29/06, sen1 at math.msu.edu <sen1 at math.msu.edu> wrote:
> I have a linear interpolation function f made from around 500 data
> points in the plane
I'm curious about the application -- is it function approximation,
statistics, or what?
> Using linearinterpol gives a function with many summands (as a sum of
> characteristic functions of affine maps). I have two questions.
> 1. In actually evaluating the function f at some point x there seems
> to be a lot of wasted time since a lot of zeroes are being summed.
> Is there a better way, short of rewriting the routine?
I'm pretty sure determining which polygon a point falls
into is a well-known problem in computational geometry.
Presumably it is a simple matter of programming to go from
characteristic functions to polygons ...
> 2. Even using the routine, the answer shows up as a sum of many
> numbers times characteristic functions. How do I see the actual
> sum as a floating point number?
Trying the example shown by ? linearinterpol, I get
- ((9 x - 39) charfun2(x, minf, 3)
+ (30 - 6 x) charfun2(x, 7, inf)
+ (30 x - 222) charfun2(x, 6, 7)
+ (18 - 10 x) charfun2(x, 3, 6))/6
I think ev(<charfun mess>, x = 3.5) for example should cause that
to yield a number.
One way to simplify away some zero terms is to use assume, e.g.
assume (x > 5.5);
ev (<charfun mess>);
=> - ((18 - 10 x) charfun(x < 6)
+ charfun(6 <= x and x < 7) (30 x - 222)
+ charfun(7 <= x) (30 - 6 x))/6
(As it stands, Maxima dislikes some unevaluated Boolean
expressions, hence boolsimp.)
Hope this helps
More information about the Maxima