Thank you, that indeed explains the issue. My confusion
arose because the equation (obviously) has to take the symbol as FE.
My next issue is when trying to construct a list of series expansions (see
my snippet later):
(I added the [1,1,1] at the end to not introduce more errors from trying to
use 'approximate')
(Ultimately I want to obtain a Matrix or Lists of Lists of series
expansions)
testseries := map((elem:FE): uts +-> retract(taylor(elem, eqn)$e_pak)$any1,
ff) :: List(uts)
This fails with:
>> Apparent user error:
Cannot coerce (CONS (CLOSEDFN (LAMBDA ((elem ) ($$ )) (PROG (eqn $ uts
any1) (SETQ eqn (QREFELT $$ 3)) (SETQ $ (QREFELT $$ 2)) (SETQ uts (QREFELT
$$ 1)) (SETQ any1 (QREFELT $$ 0)) (RETURN (PROGN (SPADCALL (SPADCALL elem
eqn (QREFELT $ 15)) (compiledLookupCheck (QUOTE retract) (LIST (devaluate
uts) (LIST (QUOTE Any))) any1))))))) (VECTOR any1 uts $ eqn))
of mode (Mapping uts FE)
to mode ##2
If I leave out the anonymous function type signature,
testseries := map(elem +-> retract(taylor(elem, eqn)$e_pak)$any1, ff)
:: List(uts)
the error changes to:
>> Apparent user error:
Cannot coerce elem
of mode uts
to mode ##2
Is this another user error or a problem with the compiler?
Another unrelated question: Assuming I pass a series expansion wrapped as
type 'Any' to some function,
am I able to reconstruct the underlying series type just from that?
Schematically, having
myseries of type Any, can I do something like unwrapped :=
retract(myseries)$AnyFunctions1(dom(myseries)),
(where dom returns the domain and not an SExpression),
or can I pass the underlying domain as another parameter to a function?
Along the lines of:
doSomethingWithSeries : (Any, Type)-> Expression(Integer)
doSomethingWithSeries (ser, type) ==
unwrapped := retract(ser)$AnyFunctions1(type)
approximate(unwrapped,5)
--- SNIP ---
)abbrev package MYTAYL MyTaylorExpansion
MyTaylorExpansion(R, FE) : Exports == Implementation where
R : Join(GcdDomain, Comparable, RetractableTo Integer, _
LinearlyExplicitOver Integer)
FE : Join(AlgebraicallyClosedField, TranscendentalFunctionCategory, _
FunctionSpace R)
Exports ==> with
my_taylor : (List(FE), Symbol, R) -> List(FE)
Implementation ==> add
e_pak ==> ExpressionToUnivariatePowerSeries(R,FE)
my_taylor(ff, sym, x0) ==
eqn := equation(sym :: FE, x0 :: FE)$Equation(FE)
uts := UnivariateTaylorSeries(FE,sym,x0::FE)
any1 := AnyFunctions1(uts)
testseries := map((elem:FE): uts +-> retract(taylor(elem,
eqn)$e_pak)$any1, ff) :: List(uts)
[1,1,1] :: List(FE)
--- SNIP ---
I have tried something similar using interpreted FriCAS:
EI ==> Expression(Integer)
dostuff3(x0, sym, lst) ==
local uts, any1, x
uts := UnivariatePuiseuxSeries(EI,sym, x0)
any1 := AnyFunctions1(uts)
map((elem:EI): uts +-> retract(puiseux(elem, equation(sym ::
EI,x0)))$any1, lst)
x := 'x :: Symbol
expr := x^2 + x :: EI
lst := [expr,expr,expr]
dostuff3(3::EI, x, lst)
which results in
Local variable or parameter used in type
We will attempt to interpret the code.
Cannot compile a $-expression involving a local variable.
FriCAS will attempt to step through and interpret the code.
any1 is not a valid type.
Thanks again for the great help. I think once I've stepped through the
struggles with the parametrized types
for series anything else should reduce to getting familiar with the API.
--
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/CANL0awbddM_VQ5Wn4CKoyb9cN08DWubO42WPG7VcezC2hvWm5g%40mail.gmail.com.