Post Reply 
Step-by-step programs in CAS
01-10-2017, 05:43 PM (This post was last modified: 01-10-2017 08:48 PM by compsystems.)
Post: #1
Step-by-step programs in CAS
Hello, I'm trying the following code (Step-by-step), but I see something strange in the output, please run the following program

PHP Code:
#cas
    
testInequality1():=
    
begin
     local expr0
;
     print;

     print(
"step1:");
     
expr0 := '(3*x^2-2*x-2) < (2*x^2-3*x+4)';
     
//expr0 :=  (3*x^2-2*x-2) < (2*x^2-3*x+4);
     
print(string(expr0)); 
     print(
"");

     print(
"step2: +(-2*x^2)");
     
expr0 := expr0 + -2*x^2;
     print(
string(expr0)); 
     
expr0 := simplify(expr0); // Requires a sentence more, of simplification.
     
print("simplify → " +expr0);
     print(
"");

     print(
"step3: +(3*x)");
     
expr0 := expr0 3*x;
     print(
string(expr0)); 
     
expr0 := simplify(expr0); 
     print(
"simplify → "+expr0);
     print(
"");

     print(
"step4: +(-4)");
     
expr0 := expr0 + -4;
     print(
string(expr0)); 
     
expr0 := simplify(expr0); 
     print(
"simplify → "+expr0);
     print(
"");
#end 


testInequality();

[
expr0: (--­4+4)>(x^2+x--­4-2)
left: --­4+4
right: x^2+x--­4-2
]

This is expected
[0>(x^2+x-6), 0, x^2+x-6]
Find all posts by this user
Quote this message in a reply
01-10-2017, 05:56 PM
Post: #2
RE: Step-by-step programs in CAS
(01-10-2017 05:43 PM)compsystems Wrote:  Hello, I'm trying the following code (Step-by-step), but I see something strange in the output, please run the following program

PHP Code:
#cas
    
testInequality():=
    
begin
     local expr0
;
     print(
"");
     
expr0 := '(3*x^2-2*x-2) < (2*x^2-3*x+4)';
     
//expr0 := (3*x^2-2*x-2) < (2*x^2-3*x+4);
     
print("step1: " expr0);

     
expr0 := expr0  -2*x^2
     print(
"step2: " expr0); expr0 := simplify(expr0); print("simplify ⇨ "+expr0);

     
expr0 := expr0 3*x;
     print(
"step3: " expr0); expr0 := simplify(expr0); print("simplify ⇨ "+expr0);

     
expr0 := expr0  -­4;
     print(
"step4: " expr0); expr0 := simplify(expr0); print("simplify ⇨ "+expr0);
     
//return expr0;
     
return [ expr0left(expr0), right(expr0) ];
    
end;
#end 


testInequality();

[
expr0: (--­4+4)>(x^2+x--­4-2) ?
left: --­4+4 ?
right: x^2+x--­4-2 ?
]

This is expected
[0>(x^2+x-6), 0, x^2+x-6]

When I copied your code, the "-" symbol in front of the 4 (in "step 4") was translated to two dashes: --4. Perhaps your editor is not using the correct symbol for subtraction.

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
01-10-2017, 06:57 PM (This post was last modified: 01-10-2017 08:34 PM by compsystems.)
Post: #3
RE: Step-by-step programs in CAS
Thanks Han, (Updated above code), The problem was that when porting a code from ti68k, which uses the character #173 (-) as a change of sign, That is not the change of sign in the hp-prime

PHP Code:
// ti68k
inequali()
Prgm
 Local expr0
 ClrIO
 Disp 
"step1: "
 
3*x^2-2*x-2*x^2-3*x+4 → expr0
 Disp expr0

 Disp 
"step2: +(-­2*x^2)"
 
expr0 ­2*x^2 → expr0
 Disp expr0

 Disp 
"step3: +3*x"
 
expr0 3*x → expr0
 Disp expr0

 Disp 
"step4: +(-­4)"Pause
 expr0 
+ -­4 → expr0
 Disp expr0
EndPrgm 
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)