{-# LANGUAGE NoImplicitPrelude #-}{- |
Define Transcendental functions on arbitrary fields.
These functions are defined for only a few (in most cases only one) arguments,
that's why discourage making these types instances of 'Algebra.Transcendental.C'.
But instances of 'Algebra.Transcendental.C' can be useful when working with power series.
If you intent to work with power series with 'Rational' coefficients,
you might consider using @MathObj.PowerSeries.T (Number.PartiallyTranscendental.T Rational)@
instead of @MathObj.PowerSeries.T Rational@.
-}moduleNumber.PartiallyTranscendental(T,fromValue,toValue)whereimportqualifiedAlgebra.TranscendentalasTranscendentalimportqualifiedAlgebra.AlgebraicasAlgebraicimportqualifiedAlgebra.FieldasFieldimportqualifiedAlgebra.RingasRingimportqualifiedAlgebra.AdditiveasAdditive-- import qualified Algebra.ZeroTestable as ZeroTestableimportNumericPreludeimportPreludeBaseimportqualifiedPreludeasPnewtypeTa=Cons{toValue::a}deriving(Eq,Ord,Show)fromValue::a->TafromValue=lift0lift0::a->Talift0=Conslift1::(a->a)->(Ta->Ta)lift1f(Consx0)=Cons(fx0)lift2::(a->a->a)->(Ta->Ta->Ta)lift2f(Consx0)(Consx1)=Cons(fx0x1)instance(Additive.Ca)=>Additive.C(Ta)wherenegate=lift1negate(+)=lift2(+)(-)=lift2(-)zero=lift0zeroinstance(Ring.Ca)=>Ring.C(Ta)whereone=lift0onefromIntegern=lift0(fromIntegern)(*)=lift2(*)instance(Field.Ca)=>Field.C(Ta)where(/)=lift2(/)instance(Algebraic.Ca)=>Algebraic.C(Ta)wheresqrtx=lift1sqrtxrootn=lift1(Algebraic.rootn)(^/)xy=lift1(^/y)xinstance(Algebraic.Ca,Eqa)=>Transcendental.C(Ta)wherepi=undefinedexp=\0->1sin=\0->0cos=\0->1tan=\0->0x**y=ifx==1||y==0then1elseerror"partially transcendental power undefined"log=\1->0asin=\0->0acos=\1->0atan=\0->0legacyInstance::alegacyInstance=error"legacy Ring instance for simple input of numeric literals"instance(P.Numa)=>P.Num(Ta)wherefromIntegern=lift0$P.fromIntegernnegate=P.negate-- for unary minus(+)=legacyInstance(*)=legacyInstanceabs=legacyInstancesignum=legacyInstanceinstance(P.Numa)=>P.Fractional(Ta)wherefromRational=P.fromRational(/)=legacyInstance