HP Forums
[Help: CAS Code] Comparing answers history view - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: [Help: CAS Code] Comparing answers history view (/thread-7155.html)



[Help: CAS Code] Comparing answers history view - compsystems - 11-02-2016 07:56 PM

Example #1:

Steps

Step 1:
root:=√(2.) [enter] 1.41421356237

Step 2:
exact(root) == approx(root) [enter] true

Where:
left(exact(root)) ->1607521/1136689
right(approx(root)) -> 1.41421356237
then
1607521/1136689 == 1.41421356237 -> true

now

Step 3:
approx(root) [enter] 1.41421356237
Step 4:
exact(root) [enter] 1607521/1136689
Step 5:
Ans == [up][up][up] -> (0) false
1607521/1136689 == 1.41421356237 -> 0 // expr 2

Why two different answers?

1607521/1136689 == 1.41421356237 // expr1
1607521/1136689 == 1.41421356237 // expr2

expr1 same expr2 yes


RE: Comparing expressions - Tim Wessman - 11-02-2016 08:01 PM

Because they are two different things.


RE: Comparing expressions - Carlos295pz - 11-02-2016 08:31 PM

Si quieres comparar 2 datos, puedes crear un función que identifique si es una 'expresión', en caso de serlo lo evaluas, y puedes realizar la comparación.


RE: - compsystems - 11-02-2016 11:23 PM

(11-02-2016 08:01 PM)Tim Wessman Wrote:  Because they are two different things.
Ok Ans Documentation
A value in Ans is stored internally with the full precision of the calculated result,

(11-02-2016 08:31 PM)Carlos295pz Wrote:  Si quieres comparar 2 datos, puedes crear un función que identifique si es una 'expresión', en caso de serlo lo evaluas, y puedes realizar la comparación.
ok
http://www.hpmuseum.org/forum/thread-7173.html


RE: [Help: CAS Code] Comparing math expressions - Carlos295pz - 11-03-2016 08:24 PM

Una modo simple en HOME
PHP Code:
Igual(Dat1,Dat2)
BEGIN
 IFTE
(TYPE(Dat1)=8,EVAL(Dat1)▶Dat1,0);
 
IFTE(TYPE(Dat2)=8,EVAL(Dat2)▶Dat2,0);
 
Dat1=Dat2
END

Funciona para CAS, falta asignarle un nivel de precisión en decimales.

Pruebas:
Igual(0.75, 3/4) -> true
Igual(2, 4/2) -> true