unary_reorder_expr {lazy.symbolic} | R Documentation |
Reorder unary oparators
Description
Japanese help file: unary_reorder_expr_JPH
Usage
unary_reorder_expr(
expr,
most_out,
add_exch_op,
exchangable_ops = c("inv", "(", "t", "-")
)
Arguments
expr |
input expression or string |
most_out |
The unary operator that should be moved to the outermost position. |
add_exch_op |
(optional) An additional unary operator to be added to the set of exchangeable operators. This is useful if you have custom unary operators. |
exchangable_ops |
A vector of unary operators that can be exchanged. The default is 'c("inv", "(", "t", "-")'. |
Details
This function is used to move unary operators (e.g., 'inv', 't', '-') to the outermost position in an expression, as much as possible. It is useful for handling nested unary operators or when you want to prioritize moving specific operators outward.
Value
an expression
Examples
modify_math_operators()
unary_reorder_expr("(t(inv(A)))", "inv")
unary_reorder_expr("(t(-(inv(A))))", "inv")
unary_reorder_expr("t(-(gune(A)))", "gune")
unary_reorder_expr("gune(t(-(inv(A))))", "inv")
unary_reorder_expr("(t(B + (inv(A))))", "inv")
unary_reorder_expr("t(-(gune(A)))", "gune", add_exch_op = "gune")
unary_reorder_expr("gune(t(-(inv(A))))", "inv", add_exch_op = "gune")
unary_reorder_expr("t(-(t(-(inv(A)))))", "inv"
, exchangable_ops = c("-", "(", "inv"))
unary_reorder_expr("t(inv(A))", "t")
unary_reorder_expr("inv(t(-(B)) - A)", "-")
[Package lazy.symbolic version 1.0.0.20250830 ]