Previous Page Next Page Contents

simplify -- simplify an expression

Introduction

simplify(f) tries to simplify the expression f by applying term rewriting rules.

simplify(f, target) restricts the simplification to term rewriting rules applicable to the target function(s).

Call(s)

simplify(f <, target>)
simplify(l <, target>)

Parameters

f - an arithmetical expression
l - a set, a list, an array, or a polynomial of type DOM_POLY

Options

target - one of the identifiers cos, sin, exp, ln, sqrt, logic, or relation

Returns

an object of the same type as the input object f or l, respectively.

Overloadable:

f, l

Side Effects

Without a target option, simplify reacts to properties of identifiers.

Further Documentation

Chapter ``Manipulating Expressions'' of the Tutorial.

Related Functions

collect, combine, expand, factor, match, normal, radsimp, rectform, rewrite

Details

Option: target

Example 1

simplify tries to simplify algebraic expressions:

>> simplify(exp(x)-exp(x/2)^2) 
                                     0
>> f := sin(x)^2 + cos(x)^2 + (exp(x) - 1)/(exp(x/2) + 1):
   simplify(f)
                                    / x \
                                 exp| - |
                                    \ 2 /

Only special simplifications occur if special target functions are specified:

>> simplify(f, sin)
                                         / x \
                             exp(x) + exp| - |
                                         \ 2 /
                             -----------------
                                  / x \
                               exp| - | + 1
                                  \ 2 /
>> simplify(f, exp)
                           2         2      / x \
                     cos(x)  + sin(x)  + exp| - | - 1
                                            \ 2 /
>> delete f:

Example 2

The option sqrt serves for simplifying radicals:

>> simplify(sqrt(4 + 2*sqrt(3)), sqrt)
                                  1/2
                                 3    + 1
>> x := 1/2 + sqrt(23/108):
   y := x^(1/3) + 1/3/x^(1/3):
   z := y^3 - y
      /                             /  1/2   1/2       \1/3 \3
      |             1               | 3    23          |    |
      | ------------------------- + | ---------- + 1/2 |    |  -
      |   /  1/2   1/2       \1/3   \     18           /    |
      |   | 3    23          |                              |
      | 3 | ---------- + 1/2 |                              |
      \   \     18           /                              /
      
         /  1/2   1/2       \1/3
         | 3    23          |                  1
         | ---------- + 1/2 |    - -------------------------
         \     18           /        /  1/2   1/2       \1/3
                                     | 3    23          |
                                   3 | ---------- + 1/2 |
                                     \     18           /
>> simplify(z, sqrt)
                                     1
>> delete x, y, z:

Example 3

The option logic serves for simplifying Boolean expressions:

>> simplify((a and b) or (a and (not b)), logic)
                                     a

Example 4

User-defined functions can have "simplify" attributes. For example, suppose we know that f is an additive function (but we do not know more about f). Hence we cannot compute the function value of f at any point except zero, but we can tell MuPAD to use the additivity:

>> f := funcenv( x -> if iszero(x) then 0 else procname(x) end):
   f::simplify := proc(F)
                    local argument;
                    begin
                      argument := op(F,1);
                      if type(argument) = "_plus" then
                        map(argument, f)
                      else
                        F
                      end
                    end:
>> f(x + 3*y) - f(3*y) = simplify(f(x + 3*y) - f(3*y))
                        f(x + 3 y) - f(3 y) = f(x)

We could still refine the "simplify" attribute of f such that it also turns f(3*y) into 3*f(y). However, it is certainly a matter of taste whether f(x)+f(y) is really simpler than f(x+y). The reverse rule (rewriting f(x)+f(y) as f(x+y)) is not context-free and cannot be implemented in a "simplify" attribute.

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000