list2exp & exp2list CMDS

Messages in english

Modérateur : xcasadmin

Répondre
compsystems
Messages : 562
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

list2exp & exp2list CMDS

Message par compsystems » jeu. juil. 20, 2017 3:57 pm

Hi, how to make output of LIST2EXP not evaluated when stored on un id?

1:
exp2list( ((x=3) and (y=9)) or ((x=-1) and (y=1)) ) returns
[[3,9],[-1,1]]

2:
aa:=list2exp([[3,9],[-1,1]],[x,y]) returns
((x=3) and (y=9)) or ((x=-1) and (y=1))

3:
exp2list(aa) returns
false :cry:

4: ( evalb(x=3) and evalb(y=9) ) or ( evalb(x=-1) and evalb(y=1) ) returns
false

According to which I interpret AND, OR CMDS makes the following evaluation

((x=3) and (y=9)) or ((x=-1) and (y=1))
( evalb(x=3) and evalb(y=9) ) or ( evalb(x=-1) and evalb(y=1) )
(false and false) or (false and false)
false or false
false

5: ( eval(x=3) and eval(y=9) ) or ( eval(x=-1) and eval(y=1) ) returns
( eval(x=3) and eval(y=9) ) or ( eval(x=-1) and eval(y=1) )

parisse
Messages : 5739
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: list2exp & exp2list CMDS

Message par parisse » ven. juil. 21, 2017 4:53 pm

compsystems a écrit :Hi, how to make output of LIST2EXP not evaluated when stored on un id?
Instead of typing the ident. name, for example a, type eval(a,1). This will replace a by it's content but will not eval further.

compsystems
Messages : 562
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

Re: list2exp & exp2list CMDS

Message par compsystems » dim. juil. 23, 2017 1:30 am

ok

1:
aa:=list2exp([[3,9],[-1,1]],[x,y]) returns
((x=3) and (y=9)) or ((x=-1) and (y=1))

2:
exp2list(eval(aa,1)) returns
[[3,9],[-1,1]]

BP, can you please consider improving the exp2list cmd

3:
solve(abs(x) <= 3,x) returns
list[(x>=-3) and (x<=3)]

4:
list2exp( list[(x>=-3) and (x<=3)], x) returns
(x>=-3) and (3>=x) //ok

but
5:
exp2list((x>=-3) and (3>=x)) returns
3>=x :cry:

6:
slv0:=solve(abs(x-1)>=3,x)
list[x<=-2,x>=4]

7:
list2exp(slv0,x)
(-2>=x) or (x>=4)

8:
exp2list( (-2>=x) or (x>=4) )
[x,4] =(

9:
solve(abs(x-5)<=x-1,x)
list[x>=3]

10:
list2exp(list[x>=3],x)
x>=3

11:
exp2list(x>=3)
3 =(

12:
slv2:=solve(abs(1/x)<=2,x)
list[x<=(-1/2),x>=(1/2)]

13:
list2exp(slv2,x)
-1/2>=x or x>=1/2

14:
exp2list(-1/2>=x or x>=1/2)
[x,1/2] =(

15:
slv3=solve([6x+9y−3z = 8,3x−8y+9z = 7],[x,y,z])
[[ -19/25*z+127/75, 21/25*z-6/25, z]]

16:
slv3a:=list2exp( [[-19/25*z+127/75,21/25*z-6/25,z]],[x,y,z] )

x=-19*z/25+127/75 and y=21*z/25-6/25 and z=z :P

17:
exp2list(eval(slv3a,1))
[[ -19/25*z+127/75, 21/25*z-6/25, z]] =)

18:
slv11:=solve(abs(3+1/x)<=3,x)
list[x<=(-1/6)]

19:
list2exp(slv11,x)
(-1/6)>=x ok

20:
exp2list(-1/6>=x)
x =(

parisse
Messages : 5739
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: list2exp & exp2list CMDS

Message par parisse » dim. juil. 23, 2017 6:45 am

Inequations are not supported by these commands, sorry!

compsystems
Messages : 562
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

Re: list2exp & exp2list CMDS

Message par compsystems » dim. juil. 23, 2017 12:51 pm

for equations I think if there should be an optimization of the commands list2exp, exp2list

1:
slv20:=solve(x^4+4=0,x) returns
list[] // ok

2:
list2exp(slv20,x) returns
list[] -> Should return "false" It is a math expression synonymous of no solutions, the equation is not true

3:
exp2list(false) returns
false -> list[] The output must be a empty list

4:
solve(1/x-(x-1)/x^2=1/(x^2),x) returns
list[x]

5:
list2exp(list[x],x) returns
x=x

6:
exp2list(x=x) returns
x -> list[x] The output must be contained in a list

7:
slv12:=solve([d*x+(3*d+1)*y=e^t,-x+d*y-y=0],[x,y])
[ [(d*exp(t)-exp(t))/(d^2+2*d+1), exp(t)/(d^2+2*d+1)] ]

8:
slv12a:=list2exp(slv12,[x,y])
x=(d*exp(t)-exp(t))/(d^2+2*d+1) and y=(exp(t)/(d^2+2*d+1))

9:
exp2list(eval(slv12a,1))
[ [(d*exp(t)-exp(t))/(d^2+2*d+1), exp(t)/(d^2+2*d+1)] ]

compsystems
Messages : 562
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

Re: list2exp & exp2list CMDS

Message par compsystems » lun. juil. 24, 2017 9:28 pm

Hello, I propose as a synonym of no solution, the word FALSE or the empty set symbol


The next sentence does not return an expression, the pupils like to see the output as real as a textbook :mrgreen:

list2exp(solve([x+y=3, x+y=5],[x,y]),[x,y]) returns
[] -> FALSE or ∅

Image

parisse
Messages : 5739
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: list2exp & exp2list CMDS

Message par parisse » mar. juil. 25, 2017 6:11 am

false is better, I don't like symbols you can not type easily.

compsystems
Messages : 562
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

Re: list2exp & exp2list CMDS

Message par compsystems » mar. juil. 25, 2017 12:38 pm

parisse a écrit :false is better
ok

Why was the constant c_0 lost?

1:
desolve(y'+x*y=0);
c_0*exp(-x^2/2)

2:
exp2list(c_0*exp(-x^2/2))
exp(-x^2/2) lost c_0 -> [c_0*exp(-x^2/2)]

3:
desolve((y*y') = (2*x^2),y)
[√(-3*c_0+2*x^3)*√(6)/3,-√(-3*c_0+2*x^3)*√(6)/3]

4:
list2exp([sqrt(6)*sqrt(2*x^3-3*c_0)/3,-sqrt(6)*sqrt(2*x^3-3*c_0)/3],x)
((sqrt(6)*sqrt(2*x^3-3*c_0)/3) or (-sqrt(6)*sqrt(2*x^3-3*c_0)/3)) // ok

5:
exp2list(((sqrt(6)*sqrt(2*x^3-3*c_0)/3) or (-sqrt(6)*sqrt(2*x^3-3*c_0)/3)))
[(sqrt(2*x^3-3*c_0))/3,(sqrt(2*x^3-3*c_0))/3] lost sqrt(6)

parisse
Messages : 5739
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: list2exp & exp2list CMDS

Message par parisse » mar. juil. 25, 2017 2:13 pm

exp2list expects variable=something or combinations with or/and, from a solve result in TI mode. It does not check that and processes like if it was of that form, that's why the c_0 is lost. I don't plan to modify myself exp2list or list2exp anymore, they are here for compatibility only, inside Xcas you should use the native commands outputs of solve/desolve/whatever.

compsystems
Messages : 562
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

Re: list2exp & exp2list CMDS

Message par compsystems » lun. juil. 31, 2017 11:48 am

parisse a écrit :exp2list expects variable=something or combinations with or/and, from a solve result in TI mode.
Not always outputs from ti-mode, also exp2list results, exp2list, list2exp These two orders must be reversible

1:
exp2list(desolve(y'=x^2+exp(2*x),x),y))
(y=(sqrt(6)*sqrt(2*x^3-3*c_0)/3) or y=(-sqrt(6)*sqrt(2*x^3-3*c_0)/3))

2:
exp2list(ans(-1))
[(1/3)*√(6)*√(-3*G_0+2*x^3), (-1/3)*√(6)*√(-3*G_0+2*x^3)]

3: // There is a case where exp2list does not wait variable=something ...
list2exp(solve([x+y=3, x+y=5],[x,y])
[] -> The output should be false

4:
exp2list(false,x)
false -> []

5:
exp2list(true,x)
[ c_1 ] // all reals

or
[ x=x ] // all reals

Image

Répondre