$SPAD/src/input donsimple.input

Donald J. Bindner December 3, 2016

Abstract

Demonstrate the definition of algebra functions that use two kinds of argument sytles.

Contents

2

— * —

)set break resume
)spool donsimple.output
)set message test on
)set message auto off
)clear all
)sys cp $AXIOM/../../src/input/donsimple.input.pamphlet .
)lisp (tangle "donsimple.input.pamphlet" "donsimp.spad" "donsimp.spad")
)co donsimp

———-

— donsimp.spad —

)abbrev package DONSIMP donSimple
donSimple(): Exports == Implementation where
  F   ==> Float
  SF  ==> Segment F
  EF  ==> Expression F
  SBF ==> SegmentBinding F
  Exports ==> with
    simple: (F->F,SF) -> F
    ++ simple(a,b)
    ++
    ++X simple(x+->x^2,1..2)
    simple: (EF,SBF) -> EF
    ++ simple(a,b)
    ++
    ++X simple(x^2,x=1..2)
  Implementation ==> add
    simple(func:F->F, sf:SF) ==
      a:F := lo(sf)
      b:F := hi(sf)
      func(b) - func(a)
    simple(func:EF, sbf:SBF) ==
      a:F := lo(segment(sbf))
      b:F := hi(segment(sbf))
      x:Symbol := variable(sbf)
      eval(func,kernel(x),b::EF) - eval(func,kernel(x),a::EF)

———-

— * —

--S 1 of 2
simple(1/x,x=2..3)
--R
--R   (1)  - 0.1666666666 666666667
--R                                                      Type: Expression(Float)
--E 1
--S 2 of 2
simple(x+->1/x,2..3)
--R
--R   (2)  - 0.1666666666 666666667
--R                                                                  Type: Float
--E 2
)spool
)lisp (bye)

———-

References

[1] http://axiom-wiki.newsynthesis.org/SandBoxNumericalIntegration