simplify: Basic Symbolic Expression Simplification

Description Usage Arguments Details Value See Also Examples

View source: R/simplr.R

Description

simplify simplifies sexp by applying basic algebraic simplification rules. simplifyq quotes its argument, i.e. simplifyq(X) is equivalent to simplify(quote(X)).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
simplify(sexp)

simplifyq(sexp)

## S3 method for class 'call'
simplify(sexp)

## S3 method for class 'function'
simplify(sexp)

## S3 method for class 'numeric'
simplify(sexp)

## S3 method for class 'integer'
simplify(sexp)

## S3 method for class 'name'
simplify(sexp)

Arguments

sexp

An R object to simplify. See details.

Details

simplify is a S3 generic method with support for objects of class numeric, integer, name, call, and function. SimplR uses code from the Ev3 computer algebra system to implement expression simplification. The following simplification steps are performed:

Value

The simplified expression.

See Also

http://www.lix.polytechnique.fr/~liberti/Ev3.pdf

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
simplifyq(3*2+1)              #=> 7

simplifyq(1 * x)              #=> x
simplifyq(x / x)              #=> 1
simplifyq(x - x)              #=> 0
simplifyq(x + 1 - 1)          #=> x

simplifyq(f(x) + f(x) + y)    #=> y + 2 * f(x)
simplifyq(sin(x)^2+cos(x)^2)  #=> 1

simplify(function(a,b) a + a + 3 * f(b) * 5 / f(b))
#=> function(a, b) 15 + 2 * a

Example output

[1] 7
x
[1] 1
[1] 0
x
y + 2 * f(x)
[1] 1
function (a, b) 
15 + 2 * a

simplr documentation built on May 29, 2017, 12:22 p.m.

Related to simplify in simplr...