Sorry google translator
The HP-Prime have 2 new constants, true and false =)
you can try
EVAL(true) => 1
EVAL(false) => 0
Request 0: Evaluate first to TRUE or FALSE all CAS commands than return 1/0, including comparisons ==, >, < etc, Return TRUE or FALSE is more didactic
Example1:
type(3+4*i) == DOM_COMPLEX [Enter] 1 // Current
type(3+4*i) == DOM_COMPLEX [Enter] TRUE // best
eval(ans) => 1
Example2:
x+4=6 | x=2 [Enter] return 6=6
EVAL(x+4=6 | x=2) [Enter] 1 // Current
EVAL(x+4=6 | x=2) [Enter] TRUE // best
Example3:
x+4=6 | x=2.0001 [Enter] return 6.0001=6
EVAL(x+4=6 | x=2.0001) [Enter] FALSE
...
5 > 4 => true
The following program evaluates the accuracy of the answer given by the SOLVE command
errors, why?
prg version 0.2
Quote:
Export Prg1Begin
Local eq, eq1, eq2, eq3, var, var1, var2 sol, sol1, sol2, test1, test2;
eq1 := x+4=6; // x = 2
eq2 := 2^(2*x+1) = -1+ 32*2^x; // x = -4.99... OR x = 3.99...
eq3 := x^4=4; // x = v¬2 or x -v¬2
eq4 := { 4*x+3*y=10, 5*x-2*y=1 } // x = 1 AND x = 2
eq : eq1
var1 := x;
var2 : y;
var : var1
//purge( rcl(var1), rcl(var2) ); => purge ( x, y ) ?
sol := solve( eq, var ); // for eq1/2/3
//sol := solve( eq, {var1, var2} ); // for eq4
sol1:= ( var = sol(1) ) // for eq1...4
//sol2:= ( var = sol(2) ) // only for eq2, eq3, eq4
// sol12:= ( { var1, var2 } = sol ); // for eq2/3/4: [ sol ] => [ vars = sol ]
test1 := ( eq | sol1 );
//test2 := ( eq | sol2 );
If ( EVAL(test1) == true ) // Accuracy Solve Command
Then
msgBox( "case true => " + sol1 + " " + test1 );
Else
msgBox( "case false => " + sol1 + " " + test1 );
EndIf;
If ( EVAL(test1) == true ) // Accuracy Solve Command
Then
msgBox( "case true => " + sol2 + " " + test2 );
Else
msgBox( "case false => " + sol2 + " " + test2 );
EndIf;
End;
Edited: 4 Aug 2013, 11:02 a.m. after one or more responses were posted