> This is limitiation of Spad compiler, sometimes it can not infer
> that needed conditions are satisfied. Possible workaround it to
> use runtime test like:
>
> if ECFI has coerce : Symbol -> ECFI and
> ECFI has _^ : (ECFI, Fraction (Integer)) -> ECFI then
>
> a_fun(f, expo) == approximate(f, expo)
>
> else
>
> a_fun(f, expo) == error "impossible"
>
> Drawback of this is that 'a_fun' must be exported (this is compiler
> limitation, you can not have conditions for internal functions).
>
OK, I am happy to use a workaround and it compiles fine. In practice it
*does* throw the error
(3) -> my_taylor(x^2+x, 'x, 0)
>> Error detected within library code:
impossible
I can use the ^ and coerce functions for ECFI without any issues
(see "(ff)^((1/3) :: FI)" in the code below).
I thought that maybe something is wrong with the interpreter, but even if I
use my_taylor within SPAD code
it fails, like
testfun : Integer -> Integer
testfun zz ==
x := coerce('x)$ECFI
x0 := 0 :: CFI
tseries := my_taylor( (x^2 + x) :: ECFI, 'x, x0)
zz
So although I can use coerce and ^ in the routines fine, the constraint in
approximate, which necessitates
the constraint on my_taylor, prohibits a call of the function. I'm hoping
that this is just some user error!
---- SNIP ----
)abbrev package MYTAYL MyTaylorExpansion
MyTaylorExpansion() : Exports == Implementation where
FI ==> Fraction(Integer)
CFI ==> Complex(Fraction(Integer))
ECFI ==> Expression(Complex(Fraction(Integer)))
Exports ==> with
my_taylor : (ECFI, Symbol, CFI) -> ECFI
Implementation ==> add
e_pak ==> ExpressionToUnivariatePowerSeries(CFI,ECFI)
if ECFI has coerce Symbol -> ECFI and
ECFI has _^ : (ECFI, Fraction (Integer)) -> ECFI then
my_taylor(ff, sym, x0) ==
eqn := equation(sym :: ECFI, x0 :: ECFI)$Equation(ECFI)
uts := UnivariatePuiseuxSeries(ECFI,sym,x0::ECFI)
any1 := AnyFunctions1(uts)
ts := retract(puiseux((sym::ECFI), eqn)$e_pak)$any1
--approx := (ff)^((1/3) :: FI)
approx := approximate(ts,3/1)$uts
approx
else
error "impossible"
---- SNIP ----
--
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/fricas-devel/CANL0awYKm4ZSVVci5aLaoAMDPEgDvDtx9LW%2B7R0xS79qooch2w%40mail.gmail.com.