Answer cmd

Messages in english

Modérateur : xcasadmin

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

Answer cmd

Message par compsystems » mer. févr. 15, 2017 2:56 am

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

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

Re: Answer cmd

Message par parisse » mer. févr. 15, 2017 12:58 pm

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.

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

Re: Answer cmd

Message par compsystems » lun. avr. 17, 2017 3:24 am

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

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

Re: Answer cmd

Message par parisse » lun. avr. 17, 2017 7:49 am

entry(1) and ans(2).

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

Re: Answer cmd

Message par compsystems » mar. avr. 18, 2017 2:28 am

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) ?
Dernière modification par compsystems le mar. avr. 18, 2017 12:25 pm, modifié 1 fois.

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

Re: Answer cmd

Message par parisse » mar. avr. 18, 2017 6:39 am

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.

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

Re: Answer cmd

Message par compsystems » mar. avr. 18, 2017 12:28 pm

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

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

Re: Answer cmd

Message par parisse » mar. avr. 18, 2017 4:14 pm

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).

Répondre