Post Reply 
[REQUEST] terminal view for CAS mode
11-26-2016, 09:30 PM (This post was last modified: 12-07-2016 03:52 PM by compsystems.)
Post: #1
[REQUEST] terminal view for CAS mode
Hello hp-prime community

The current terminal view was created for numerical mode (HOME MODE), for this reason the output expressions are not symbolic. The numerical results, do not need readable printing.

For those we program in CAS MODE we need or require PRETTY PRINT

A comparison of the view & a practical example

[Image: script_hp_prime_image02.png]


simplify flag: off
increasing flag: off
cas mode: on

Script on history view
PHP Code:
assume(a>0);
(
a*x^2+b*x+c) = 0;
Ans*4*a;         // ((a*x^2+b*x+c)*4*a) = 0
expand(Ans);     // (4*a^2*x^2+4*a*b*x+4*a*c) = 0
Ans+b^2;         // (4*a^2*x^2 +4*a*b*x + 4*a*c+b^2 ) = (b^2)
Ans-4*a*c;       // (4*a^2*x^2+4*a*b*x+4*a*c+b^2-4*a*c) = (b^2-4*a*c)
simplify(Ans);   // (4*a^2*x^2+4*a*b*x+b^2) = (-4*a*c+b^2)  
factor(Ans);     // (2*a*x+b)^2) = (-4*a*c+b^2)
(Ans);          // (abs(2*a*x+b)) = (√(-4*a*c+b^2))
assume(b>0);assume(c>0);
expr(replace(string(Ans),"abs","")); // (2*a*x+b) = (√(-4*a*c+b^2))
Ans-b;           // (2*a*x+b-b) = (√(-4*a*c+b^2)-b)
simplify(Ans);   // (2*a*x-b) = (√(-4*a*c+b^2)-2*b)
Ans/(2*a);       // (2*a*x/(2*a)) = (-b+√(-4*a*c+b^2))/(2*a)
simplify(Ans);   // x = (-b+√(-4*a*c+b^2))/(2*a)
part(Ans,1)=reorder(part(Ans,2),[b,a,c]);  // x = (-b+√[b^2-4*a*c])/(2*a)
expr(replace(string(Ans),"-b+","-b-")); // x = (-b-√[b^2-4*a*c])/(2*a) 

CAS prgm
PHP Code:
#cas
    
deductionQuadformula():=
    
begin
        local equation
;
        
assume(a>0);
        print; 
// Clear Terminal Window
        
print( "Use cursor keys ↑↓ to move the output screen" );
        print( 
"Another key to continue after PAUSE" );
        print( 
"" );
        print( 
"[PAUSE]" ); wait();

        print; 
// Clear Terminal Window again
        
print( "***** Deduction Quadratic Formula *****" ); // Title
        
print( "" );

        
equation:= (a*x^2+b*x+c) = 0
        print( 
stringequation ) );
        print( 
"" );

            print( 
"Ans*4*a" );
            
equ := equ 4*a;         // ((a*x^2+b*x+c)*4*a) = 0 
            
print( stringequ ) );
            print( 
"" );
            
            print( 
"expand(Ans)" );
            
equ := expandequ );     // (4*a^2*x^2+4*a*b*x+4*a*c) = 0
            
print( stringequ ) );
            print( 
"" );

            print( 
"Ans+b^2" );    
            
equ := equ b^2;         // (4*a^2*x^2 +4*a*b*x + 4*a*c+b^2 ) = (b^2)
            
print( stringequ ) );
            print( 
"" );

            print( 
"Ans-4*a*c" );    
            
equ := equ 4*a*c;       // (4*a^2*x^2+4*a*b*x+4*a*c+b^2-4*a*c) = (b^2-4*a*c)
            
print( stringequ ) );
            print( 
"" );

            print( 
"simplify(Ans)" );    
            
equ := simplifyequ );   // (4*a^2*x^2+4*a*b*x+b^2) = (-4*a*c+b^2)  
            
print( stringequ ) );
            print( 
"" );

            print( 
"factor(Ans)" );    
            
equ := factorequ );     // (2*a*x+b)^2) = (-4*a*c+b^2)
            
print( stringequ ) );
            print( 
"" );

            print( 
"√(Ans)" ); 
            
assumeb>); assumec>);
            
equ := equ );          // (abs(2*a*x+b)) = (√(-4*a*c+b^2)) // Should not show ABS
            
print( stringequ ) );
            print( 
"" );

            
// patch
            
equ := exprreplacestringequ ), "abs""" ) ); // (2*a*x+b) = (√(-4*a*c+b^2))
            
print( stringequ ) );
            print( 
"" );

            print( 
"Ans-b" );    
            
equ := equ b;           // (2*a*x+b-b) = (√(-4*a*c+b^2)-b)
            
print( stringequ ) );
            print( 
"" );

            print( 
"simplify(Ans)" );    
            
equ := simplifyequ );   // (2*a*x-b) = (√(-4*a*c+b^2)-2*b)
            
print( stringequ ) );
            print( 
"" );

            print( 
"Ans/(2*a)" );      
            
equ := equ / ( 2*);       // (2*a*x/(2*a)) = (-b+√(-4*a*c+b^2))/(2*a)
            
print( stringequ )  );
            print( 
""  );

            print( 
"simplify(Ans)"  );    
            
equ := simplifyequ );   // x1 = (-b+√(-4*a*c+b^2))/(2*a)
            
equ := exprreplacestringequ ), "x""x1" ) );
            print( 
stringequ )  );
            print( 
""  );

            print( 
"expr(replace(string(equ),"-b+","-b-"))" );
            
equ1 := exprreplacestringequ ), "-b+""-b-" ) ); // x2 = (-b-√[b^2-4*a*c])/(2*a) 
            
equ1 := exprreplacestringequ1 ), "x1""x2" ) );    
            print( 
stringequ1 )  ); 

            print( 
"[PAUSE]"  ); wait( );
        
        return 
"done";
    
end;
#end 

Survey:
Do you really need a new terminal view with pretty print?

Please vote, Thanks
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
[REQUEST] terminal view for CAS mode - compsystems - 11-26-2016 09:30 PM



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