Page 1 sur 1

Answer cmd

Publié : mer. févr. 15, 2017 2:56 am
par compsystems
Hello, Mr. Bernard,

The following sequence sentences in the hp-prime

ENTRY

Code : Tout sélectionner

(2*x^2-3*x+4) > (3*x^2-2*x-2);
Ans + -2*x^2; 
simplify(Ans);
Ans + 3*x; 
simplify(Ans); 
Ans + -4;
simplify(Ans); 
returns

Code : Tout sélectionner

(2*x^2-3*x+4) > (3*x^2-2*x-2)
(2*x^2-3*x+4-2*x^2) > (3*x^2-2*x-2-2*x^2)
(-3*x+4) > (x^2-2*x-2)
(-3*x+4+3*x) > (x^2-2*x-2+3*x)
4 > (x^2+x-2)
0 > (x^2+x-2-4)
0 > (x^2+x-6) 
I can not see the same results in xCAS,
What am I doing wrong with the ANSWER command?

Thanks

Re: Answer cmd

Publié : mer. févr. 15, 2017 12:58 pm
par parisse
Ans does not behave the same on the Prime and in Xcas. I do not recommend using Ans because you can move from one level to another and reeval. It is much safer to give a name to a result if you want to reuse it later.

Re: Answer cmd

Publié : lun. avr. 17, 2017 3:24 am
par compsystems
Hi, if I have the following entry

#1: a
a

#2:b
b

#3:c
c

#4:d
d

#5:

Please someone please explain me how to call for example the entry line# 2 and output line# 3 from line #5 with ANS() y ENTRY() CMDS

thanks

Re: Answer cmd

Publié : lun. avr. 17, 2017 7:49 am
par parisse
entry(1) and ans(2).

Re: Answer cmd

Publié : mar. avr. 18, 2017 2:28 am
par compsystems
ok ^

The next 4 steps work perfectly
ans(-1) = ans(previous)

entry#1: x^2 = 2*x + 3 [enter] answer#1 x^2=(2*x+3)
entry#2: ans(-1) - (2*x + 3) [enter] answer#2 x^2-2*x-3=0
entry#3: factor(ans(-1)) [enter] answer#3 (x-3)*(x+1)=0
entry#4: left(ans(-1)) [enter] answer#4 (x+1)*(x-3)
entry#5:

But if I give more than one enter on the same line changes the output, why this happens?

entry#4: left(ans(-1)) [enter][enter] 4: (x+1) ?

Re: Answer cmd

Publié : mar. avr. 18, 2017 6:39 am
par parisse
because left((x+1)*(x-3)) is x+1.
ans and entry are designed to be used in a terminal-like interface where you can not modify an entry/answer, not in a GUI.

Re: Answer cmd

Publié : mar. avr. 18, 2017 12:28 pm
par compsystems
But on line#4 left(ans(-1)) [enter] [enter] should call to the line previous line#3 (x-3)*(x+1)=0 and not on your own answer, because the input must be recalculated when modified, for example the expression is badly written or you want to change it

Re: Answer cmd

Publié : mar. avr. 18, 2017 4:14 pm
par parisse
ans(-1) refers to the last command sent to the computation kernel, that's not necessarily the last Xcas level (unlike in a terminal where you can not re-evaluate an existing command).