Go to the first, previous, next, last section, table of contents.


Grenzwerte

----------------------------------------------------------------------
> module Limes          (  Extended(..), mapE, limes
>                       )
> where
----------------------------------------------------------------------

----------------------------------------------------------------------
> import CPS            renaming (zero to dontknow)
>
> import Function       (  Function(..), Prim(..),
>                          minus, (***), zero, one, mone, two, mtwo  )
----------------------------------------------------------------------

Typdefinitionen

----------------------------------------------------------------------
> data Signum           =  Neg | Zero | Pos
>                       deriving (Eq, Text)
----------------------------------------------------------------------

----------------------------------------------------------------------
> instance Num Signum where
>     Zero * _          =  Zero
>     _    * Zero       =  Zero
>     Neg  * Neg        =  Pos
>     Neg  * Pos        =  Neg
>     Pos  * Neg        =  Neg
>     Pos  * Pos        =  Pos
>
>     fromInteger n
>         | n < 0       =  Neg
>         | n == 0      =  Zero
>         | n > 0       =  Pos
----------------------------------------------------------------------

Repr"asentation eigentlicher und uneigentlicher Werte.

----------------------------------------------------------------------
> data Extended val     =  MInfty | Proper val | Infty
>                       deriving (Eq)
----------------------------------------------------------------------

----------------------------------------------------------------------
> type Value            =  Extended Function
----------------------------------------------------------------------

----------------------------------------------------------------------
> isProper MInfty       =  False
> isProper (Proper _)   =  True
> isProper Infty        =  False
----------------------------------------------------------------------

----------------------------------------------------------------------
> mapE f MInfty         =  MInfty
> mapE f (Proper v)     =  Proper (f v)
> mapE f Infty          =  Infty
----------------------------------------------------------------------

Vorzeichen

----------------------------------------------------------------------
> signOf MInfty         =  unit Neg
> signOf (Proper (Ratio n))
>     | n < 0           =  unit Neg
>     | n == 0          =  unit Zero
>     | n > 0           =  unit Pos
> signOf Infty          =  unit Pos
> signOf _              =  dontknow                     -- catch all
----------------------------------------------------------------------

Eigentliche und uneigentliche Grenzwerte

----------------------------------------------------------------------
> limes                 :: Value -> Function -> Maybe Value
> limes a f             =  firstSolution (lim a f) ()
----------------------------------------------------------------------

Grenzwerte primitiver Funktionen.

----------------------------------------------------------------------
> limPrim               :: Value -> Prim -> BT st Value res
> limPrim MInfty f      =  case f of
>     Exp               -> proper zero
>     Arctan            -> proper (mtwo *** (Prim Arctan :.: one))
>     Arccot            -> proper (Ratio (4 % 1) *** (Prim Arctan :.: one))
>     Sinh              -> minfty
>     Cosh              -> infty
>     Tanh              -> proper mone
>     Coth              -> proper mone
>     Abs               -> infty
>     _                 -> dontknow                     -- catch all
> limPrim v@(Proper a) f        =  case f of
>     Tan               -> dontknow
>     Cot               -> dontknow
>     Ln                -> signOf v &= \s -> case s of
>         Neg           -> dontknow
>         Zero          -> minfty
>         Pos           -> proper (Prim Ln :.: a)
>     Coth              -> signOf v &= \s -> case s of
>         Zero          -> dontknow
>         _             -> proper (Prim Coth :.: a)
>     _                 -> proper (Prim f :.: a)        -- catch all
> limPrim Infty f       =  case f of
>     Exp               -> infty
>     Ln                -> infty
>     Arctan            -> proper (two *** (Prim Arctan :.: one))
>     Arccot            -> proper zero
>     Sinh              -> infty
>     Cosh              -> infty
>     Tanh              -> proper zero
>     Coth              -> proper zero
>     Abs               -> infty
>     _                 -> dontknow                     -- catch all
----------------------------------------------------------------------

Grenzwerte von Funktionen.

----------------------------------------------------------------------
> lim                   :: Value -> Function -> BT st Value res
> lim a n@(Ratio _)     =  proper n
> lim a n@(Const _)     =  proper n
> lim a (Prim f)        =  limPrim a f
> lim a (Fun f)         =  dontknow
> lim a (Derive n f)    =  dontknow
> lim a Id              =  unit a
> lim a (f :.: g)       =  lim a g                              &= \lg ->
>                          lim lg f
> lim a (Summ fs)       =  accumulat [ lim a f | f<-fs ]        &= \lfs ->
>                          if MInfty `elem` lfs then
>                              if Infty `elem` lfs then
>                                  hospital a n d
>                              else
>                                  minfty
>                          else
>                              if Infty `elem` lfs then
>                                  infty
>                              else
>                                  proper (Summ [ f | Proper f<-lfs ])
>     where n           =  Summ [ Prod gs :^: mone | gs<-remove fs ]
>           d           =  Prod fs :^: mone
> lim a (Prod fs)       =  accumulat [ lim a f | f<-fs ]        &= \lfs ->
>                          if all isProper lfs then
>                              proper (Prod [ f | Proper f<-lfs ])
>                          else
>                              accumulat [ signOf f | f<-lfs ]  &= \sfs ->
>                              if Zero `elem` sfs then
>                                  hospital a n d
>                              else
>                                  case product sfs of
>                                      Neg -> minfty
>                                      Pos -> infty
>     where n           =  Prod [] --HACK: nur vorl"aufig
>           d           =  Prod [] --HACK: nur vorl"aufig
> lim a (f :^: g)       =  lim a (Prim Exp :.: g *** (Prim Ln :.: f))
----------------------------------------------------------------------

----------------------------------------------------------------------
> minfty                =  unit MInfty
> proper n              =  unit (Proper n)
> infty                 =  unit Infty
----------------------------------------------------------------------

Satz von de L'Hospital

----------------------------------------------------------------------
> hospital a f g        =  dontknow
----------------------------------------------------------------------

Hilfsfunktionen

----------------------------------------------------------------------
> remove []             =  []
> remove (a:x)          =  x : [ a:x' | x'<-remove x ]
----------------------------------------------------------------------


Go to the first, previous, next, last section, table of contents.