Skip to contents

refine(expr, assumptions) rewrites expr using what ask() can decide under the assumptions: Abs(x) becomes x when x is known to be nonnegative, (-1)^(x + 1) becomes -(-1)^x for integer x, a predicate or relation that the assumptions decide becomes TRUE or FALSE, and so on for powers, exp(), re(), im(), arg(), sign(), atan2(), sin(), cos(), floor(), ceiling(), Heaviside() and elements of symmetric matrices. The arguments are refined first.

Usage

refine(expr, assumptions = TRUE, ...)

Arguments

expr

An expression.

assumptions

Assumptions such as Q$positive(x), or TRUE for none.

...

Further assumptions, joined to assumptions with &.

Value

The refined expression.

Examples

x <- Symbol("x")
refine(sqrt(x^2), Q$real(x))
#> Abs(x)
refine(sqrt(x^2), Q$positive(x))
#> x
refine(Q$real(x), Q$positive(x))
#> True