Takes the expression x and returns an equivalent expression in lowered form.


  1. Expand a simple expression:

    julia> expand((x + y)^2)
    x^2 + 2*x*y + y^2

    This example expands the expression (x + y)^2 to its expanded form.

  2. Expand an expression with variables:

    julia> expand((a + b)*(c + d))
    a*c + a*d + b*c + b*d

    It expands the expression (a + b)*(c + d) to its expanded form, distributing the multiplication.

  3. Expand a complex expression:
    julia> expand((x + y + z)^3)
    x^3 + 3*x^2*y + 3*x^2*z + 3*x*y^2 + 6*x*y*z + 3*x*z^2 + y^3 + 3*y^2*z + 3*y*z^2 + z^3

    The function can handle more complex expressions, demonstrated here by expanding (x + y + z)^3.

Common mistake example:

julia> expand(sin(x)^2)
ERROR: MethodError: no method matching expand(::Float64)

In this example, the expand function is applied to a float value instead of an expression. The expand function expects an expression as its argument, so make sure to pass an expression to it for correct usage.

See Also

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field

Checking you are not a robot: