On Sat, Apr 22, 2023 at 02:41:55PM -0700, Sid Andal wrote:
> The following 2D example describes the problem:
>
> PR ==> PAdicRational(11)
> SQ ==> SQMATRIX(2, PR)
> LS ==> List SQ
>
> M : SQ := [[10, 7], [3, 8]]
>
> ┌10 7┐
> (4) │ │
> └3 8┘
>
> N : SQ := [[9, 2], [5, 1]]
>
> ┌9 2┐
> (5) │ │
> └5 1┘
>
> S : LS := [M, N]
>
> ┌10 7┐ ┌9 2┐
> (6) [│ │, │ │]
> └3 8┘ └5 1┘
>
> AP := ALGSC(PR, 2, ['A, 'B], S)
>
> (7)
>
> AlgebraGivenByStructuralConstants(PAdicRational(11),2,[A,B],[[[10,7],[3,8]],[
> [9,2],[5,1]]])
>
> V := basis()$AP
>
> (8) [A, B]
> (A, B) := (V.1, V.2)
>
> (9) B
>
> )clear p M N S V
>
> (10) -> (U, V, W) : AP
> (11) -> U := 9*A + 10*B
>
> (11) 10 B + 9 A
> (12) -> V := 8*A + 7*B
>
> (12) 7 B + 8 A
> (13) -> W := U*V
>
> 2
> 2 3
> (13) (1 + 3 11 + 10 11 )B + (3 + 2 11 + 5 11 + 11 )A
> (14) ->
>
> All scalar coefs are padic integers and an algebra over the ring
> of padic integers would've been sufficient. However, ALGSC requires
> the Ring to be a Field, so, PAdicRational was chosen, instead.
Well, basic things in ALGSC work for CommutativeRing, it is relatively
simple change to allow CommutativeRing. Field is needed to have
equation solvers, which is needed for example for LeftUnit. In
principle equation solving can be done for PrincipalIdealDomain,
so for Integer or PAdicInteger. However, that would require more
work.
> The problem now is to rewrite the product W into the following form
> or into something equivalent:
>
> 2 3
> (B + 3A) + (3B + 2A)11 + (10B + 5A)11 + A 11
>
> where the powers of the prime (11, in this case) are factored out.
You did not write what you consider "rewrite"? Basically, in FriCAS
you need a domain to represent your values. I attach a simple domain
which is only good for printing, but you probably want more.
To try it you need newest FriCAS from git ('retract' from padic
rationals to padic integer is implemented only in git version).
Compile the attached Spad file. Then ')read' the attached
input file. Final line of outut is:
1 2 11
(17) B + 3 A + (3 B + 2 A)11 + (10 B + 5 A)11 + O(11 )
Type:
ModuleTaylorSeries(Fraction(Integer),AlgebraGivenByStructuralConstants(Fraction(Integer),2,[A,B],[[[10,7],[3,8]],[[9,2],[5,1]]]),theMap(*1;my_pr;1;frame1)
which IIUC is what you want
--
Waldek Hebisch
--
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/20230427030219.a5h6fpvv3lletgqp%40fricas.math.uni.wroc.pl.
)abbrev domain MTSER ModuleTaylorSeries
ModuleTaylorSeries(R, M, prn) : Exports == Implementation where
R : CommutativeRing
M : Module(R)
prn : Integer -> OutputForm
Exports ==> with
series : Stream(M) -> %
coerce : % -> OutputForm
Implementation ==> add
Rep := Stream(M)
series(s : Stream(M)) : % == s::%
term_to_out(vi : M, n : Integer) : OutputForm ==
vio := vi::OutputForm
n = 0 => vio
vio * prn(n)
coerce(x : %) : OutputForm ==
xr : Rep := x::Rep
empty?(xr) => 0$M::OutputForm
n : NonNegativeInteger
count : NonNegativeInteger := _$streamCount$Lisp
l : List(OutputForm) := []
for n in 0..count while not empty?(xr) repeat
if (vi := frst(xr)) ~= 0 then
l := cons(term_to_out(vi, n), l)
xr := rst(xr)
l :=
explicitlyEmpty?(xr) => l
eq?(xr, rst(xr)) and frst(xr) = 0 => l
cons(prefix('O::OutputForm, [prn(n)]), l)
empty? l => (0$M)::OutputForm
reduce("+", reverse!(l))
pR := PAdicRational(11)
pI := PAdicInteger(11)
ll := [[[10, 7], [3, 8]], [[9, 2], [5, 1]]]
AP := ALGSC(pR, 2, ['A, 'B], ll)
qF := Fraction(Integer)
BP := ALGSC(qF, 2, ['A, 'B], ll)
V := basis()$AP
(A, B) := (V(1), V(2))
U := 9*A + 10*B
V := 8*A + 7*B
W := U*V
gen_digs2(d1 : Stream(Integer), d2 : Stream(Integer)) : Stream(BP) ==
(delay$Stream(BP))(
() : Stream(BP) +->
ed1 := empty?(d1)
ed2 := empty?(d2)
ed1 and ed2 => empty()$Stream(BP)
c1 : Integer
if ed2 then
c1 := 0
else
c1 := frst(d1)
d1 := rst(d1)
c2 : Integer
if ed2 then
c2 := 0
else
c2 := frst(d2)
d2 := rst(d2)
bv := represents(vector([c1::qF, c2::qF]))$BP
cons(bv, gen_digs2(d1, d2))
)
my_pr(n : Integer) : OutputForm == 11::OutputForm ^ (n::OutputForm)
mS := ModuleTaylorSeries(qF, BP, my_pr)
cW := coordinates(W)
dW(x) == digits(retract(x)@pI)
ss := series(gen_digs2(dW(cW(1)), dW(cW(2))))$mS