Sponsored links: Algebra eBooks
 

Help Index

A

B

C

D

E

F

G

H

I

J

K

L

M

N

O

P

Q

R

S

T

U

V

W

X

Y

Z

The Maxima on-line user's manual

Algebra Calculator

Search:

Tree_reduce Calculator

Tree_reduce

Function: tree_reduce (<F>, <s>)

tree_reduce (f, [a, b, c, d]);
 tree_reduce (f, [a, b, c, d, e]);

Function: tree_reduce (<F>, <s>, <s_0>) Extends the binary function <F> to an n-ary function by composition, where <s> is a set or list.

tree_reduce is equivalent to the following: Apply <F> to successive pairs of elements to form a new list [<F>(<s_1>, <s_2>), <F>(<s_3>, <s_4>), ...], carrying the final element unchanged if there are an odd number of elements. Then repeat until the list is reduced to a single element, which is the return value.

When the optional argument <s_0> is present, the result is equivalent tree_reduce(<F>, cons(<s_0>, <s>).

For addition of floating point numbers, tree_reduce may return a sum that has a smaller rounding error than either rreduce or lreduce.

The elements of <s> and the partial results may be arranged in a minimum-depth binary tree, thus the name "tree_reduce".

Examples:

tree_reduce applied to a list with an even number of elements.

          (%i1) tree_reduce (f, [a, b, c, d]);
          (%o1)                  f(f(a, b), f(c, d))

tree_reduce applied to a list with an odd number of elements.

          (%i1) tree_reduce (f, [a, b, c, d, e]);
          (%o1)               f(f(f(a, b), f(c, d)), e)

(%o1)                                true
(%i2) 

Tree_reduce Example

Related Examples

tree_reduce

tree_reduce (f, [a, b...

tree_reduce (f, [a, ...

Calculate

tree_reduce

? tree_reduce;

Calculate

tree_reduce

tree_reduce (f, [a, b...

tree_reduce (f, [a, ...

Calculate

tree_reduce

? tree_reduce;

Calculate