Page 1 sur 1

problem with convert( array, list)

Publié : mar. nov. 11, 2025 6:00 pm
par compsystems
Hi, when converting an array to a list, the visual conversion looks fine, but when reading the list, it appears as a formatting instruction equal( , ). For this reason, I think Solve can't calculate it.

solve(convert([[(α1+α2-α3) = 1],[(α1-α2-α3) = 1],[(α1-α2+α3) = 2],[(α1+α2+α3) = 3]],list),{α1,α2,α3},'=') [Enter] []

convert([[(α1+α2-α3) = 1],[(α1-α2-α3) = 1],[(α1-α2+α3) = 2],[(α1+α2+α3) = 3]],list

[enter]
[[equal(α1+α2-α3,1)],[equal(α1-α2-α3,1)],[equal(α1-α2+α3,2)],[equal(α1+α2+α3,3)]]

=>
[(α1+α2-α3) = 1,(α1-α2-α3) = 1,(α1-α2+α3) = 2,(α1+α2+α3) = 3]

Re: problem with convert( array, list)

Publié : mer. nov. 12, 2025 11:13 am
par parisse
You have 4 equations for 3 unknowns, it's not really surprising that there is no solution...

Re: problem with convert( array, list)

Publié : mer. nov. 12, 2025 11:50 am
par compsystems
I copied the first independent term incorrectly =) and the list of variables enclosed in curly braces {}

solve( convert( [[(α1+α2-α3) = 2],[(α1-α2-α3) = 1],[(α1-α2+α3) = 2],[(α1+α2+α3) = 3]],list), [α1,α2,α3],'=')

=>

set[[equal(α1,2),equal(α2,1/2),equal(α3,1/2)]]

But when copying the output, it decodes it with the equal operator, and pasting it into a document doesn't produce a normal mathematical expression.

Re: problem with convert( array, list)

Publié : mer. nov. 12, 2025 1:13 pm
par parisse
Make sure you are running the "pure" Xcas interpreter, not the Python-compatible mode, to get = for = in text outputs.

Re: problem with convert( array, list)

Publié : mer. nov. 12, 2025 4:47 pm
par compsystems
Running in xcas mode, correct.

To avoid converting to a list, the solve cmd it should accept an array of equations that come from, for example, a linear combination.

solve(
[[(α1+α2-α3) = 2],
[(α1-α2-α3) = 1],
[(α1-α2+α3) = 2],
[(α1+α2+α3) = 3]],

[α1,α2,α3],'=')

---------------------------
([[1,1,-1],[1,-1,-1],[1,-1,1],[1,1,1]]*[[α1],[α2],[α3]]) = [[2],[1],[2],[3]]

[[(α1+α2-α3) = 2],
[(α1-α2-α3) = 1],
[(α1-α2+α3) = 2],
[(α1+α2+α3) = 3]]

solve( array, var )

Re: problem with convert( array, list)

Publié : jeu. nov. 13, 2025 7:21 am
par parisse
It already does :
solve([[1,1,-1],[1,-1,-1],[1,-1,1],[1,1,1]]*[[α1],[α2],[α3]] = [[2],[1],[2],[3]],[α1,α2,α3],'=')

Re: problem with convert( array, list)

Publié : sam. nov. 15, 2025 1:37 pm
par compsystems
Okay, it works correctly.

A situation where the evaluation operator appears to malfunction.

[[1,0],
[0,1]]
*
[[α1],
[α2]]
=
[[(-1/3)*x+(2/3)*y],
[(2/3)*x-(1/3)*y]]
=>
[[α1=(-x/3+2*y/3)],
[α2=(2*x/3-y/3)]]

simplify( α1*[[1],[2]]+ α2*[[2],[1]]=[[x],[y]] | [[α1=(-x/3+2*y/3)],[α2=(2*x/3-y/3)]]
=>
[[α1+2*α2],[2*α1+α2]]=[[x],[y]]
does not perform the evaluation.

now, converting to a list of equations
simplify( α1*[[1],[2]]+ α2*[[2],[1]]=[[x],[y]] | convert([[α1=(-x/3+2*y/3)],[α2=(2*x/3-y/3)]], list))
=>
"Invalid | Error: Bad Argument Value"

but doing the operation separately

convert(set[[α1=2,α2=(1/2),α3=(1/2)]],list)
=>
[α1=(-x/3+2*y/3),α2=(2*x/3-y/3)]

simplify( α1*[[1],[2]]+ α2*[[2],[1]]=[[x],[y]] | [α1=(-x/3+2*y/3),α2=(2*x/3-y/3)])
=>
[[x],
[y]]
=
[[x],
[y]] // ok

Re: problem with convert( array, list)

Publié : mar. nov. 18, 2025 6:56 am
par parisse
What about using subst?

Re: problem with convert( array, list)

Publié : mar. nov. 18, 2025 2:02 pm
par compsystems
subst works well, but the | operator is a more natural notation. I say this so that students use the encoding closest to what appears in the math books, so it would be a good idea to make the | operator accept special arguments as an operation.

Furthermore, using mathematical symbols instead of nested operations makes it easier to read. function( function( function() )

=)

Re: problem with convert( array, list)

Publié : mar. nov. 18, 2025 8:39 pm
par parisse
Unfortunately, | and subst do not follow the same evaluation rules. Modifying | to mimic subst would certainly break some code...