Search code examples
functionsplitexpressionmaximasimplification

Maxima. Function of independent variables as a factor


Is there a function that selects a function of independent variables as a factor?

For example, if you write:

'integrate(2*y*x^2, x);

you will get:

2*y*'integrate(x^2, x);

Like that, only without an integral?:

[2*y, x^2]

Solution

  • From the documentation:

    Function: partition (expr, x)

    Returns a list of two expressions. They are (1) the factors of expr (if it is a product), the terms of expr (if it is a sum), or the list (if it is a list) which don’t contain x and, (2) the factors, terms, or list which do.

    Examples:

    (%i1) partition (2*a*x*f(x), x);
    (%o1)                     [2 a, x f(x)]
    (%i2) partition (a+b, x);
    (%o2)                      [b + a, 0]
    (%i3) partition ([a, b, f(a), c], a); 
    (%o3)                  [[b, c], [a, f(a)]]