Macaulay2 » Documentation
Packages » Macaulay2Doc » The Macaulay2 language » making new classes » printing and formatting for new classes » expression
next | previous | forward | backward | up | index | toc

# expression -- convert to an expression

- Usage:
    `expression x`
- Inputs:
  - x
- Outputs:
  - an expression, constructed from x using the mathematical structure of x, if present

## Description

Here is example of a function that expresses small rational numbers as Egyptian fractions using expression.

    i1 : egyptian = method();

    i2 : egyptian QQ := x -> if x == 0 then 0 else (
         	    n := ceiling(1/x);
         	    expression(1/n) + egyptian(x - 1/n));

    i3 : egyptian(30/31)

         1   1   1    1      1         1
    o3 = - + - + - + --- + ----- + ---------
         2   3   8   107   15922   633759288

    o3 : Expression of class Sum

## For the programmer

The object expression is a method function with a single argument.

The source of this document is in /build/macaulay2-88fgJW/macaulay2-1.25.11+ds/M2/Macaulay2/packages/Macaulay2Doc/functions/expression-doc.m2:91:0.