====================================================================
MappingPackage examples
====================================================================

We can construct some simple maps that take a variable x
into an equation:

  p:=(x:EXPR(INT)):EXPR(INT)+->3*x
  q:=(x:EXPR(INT)):EXPR(INT)+->2*x+3

Now we can do the four arithmetic operations, +, -, *, / on these
newly constructed mappings. Since the maps are from the domain
Expression Integer to the same domain we can also use symbolic
values for the argument. All of the following will return 0,
showing that function composition is equivalent to the result
of doing the operations individually.

  (p+q)(4)-(p(4)+q(4))
  (p+q)(x)-(p(x)+q(x))
  
  (p-q)(4)-(p(4)-q(4))
  (p-q)(x)-(p(x)-q(x))

  (p*q)(4)-(p(4)*q(4))
  (p*q)(x)-(p(x)*q(x))

  (p/q)(4)-(p(4)/q(4))
  (p/q)(x)-(p(x)/q(x))

We can construct simple maps from Integer to Integer but this
limits our ability to do division.

  r:=(x:INT):INT+-> (x*x*x)
  s:=(y:INT):INT+-> (y*y+3)

Again, all of these will return 0:

  (r+s)(4)-(r(4)+s(4))
  (r-s)(4)-(r(4)-s(4))
  (r*s)(4)-(r(4)*s(4))

If we want to do division with Integer inputs we create the
appropriate map:

  t:=(x:INT):EXPR(INT)+-> (x*x*x)
  u:=(y:INT):EXPR(INT)+-> (y*y+3)

  (t/u)(4)-(t(4)/u(4))

We can even recover the original functions if we make a map
that always returns the constant 1:

  h:=(x:EXPR(INT)):EXPR(INT)+->1

    theMap(Closure)
             Type: (Expression Integer -> Expression Integer)

  (p/h)(x)

     3x
                                     Type: Expression Integer
  (q/h)(x)

    2x + 3
                                     Type: Expression Integer

See Also:
o )show MappingPackage1
o )help MappingPackage2
o )help MappingPackage3
o )help MappingPackage4

