#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( string( equation ) );
print( "" );
print( "Ans*4*a" );
equ := equ * 4*a; // ((a*x^2+b*x+c)*4*a) = 0
print( string( equ ) );
print( "" );
print( "expand(Ans)" );
equ := expand( equ ); // (4*a^2*x^2+4*a*b*x+4*a*c) = 0
print( string( equ ) );
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( string( equ ) );
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( string( equ ) );
print( "" );
print( "simplify(Ans)" );
equ := simplify( equ ); // (4*a^2*x^2+4*a*b*x+b^2) = (-4*a*c+b^2)
print( string( equ ) );
print( "" );
print( "factor(Ans)" );
equ := factor( equ ); // (2*a*x+b)^2) = (-4*a*c+b^2)
print( string( equ ) );
print( "" );
print( "√(Ans)" );
assume( b>0 ); assume( c>0 );
equ := √( equ ); // (abs(2*a*x+b)) = (√(-4*a*c+b^2)) // Should not show ABS
print( string( equ ) );
print( "" );
// patch
equ := expr( replace( string( equ ), "abs", "" ) ); // (2*a*x+b) = (√(-4*a*c+b^2))
print( string( equ ) );
print( "" );
print( "Ans-b" );
equ := equ - b; // (2*a*x+b-b) = (√(-4*a*c+b^2)-b)
print( string( equ ) );
print( "" );
print( "simplify(Ans)" );
equ := simplify( equ ); // (2*a*x-b) = (√(-4*a*c+b^2)-2*b)
print( string( equ ) );
print( "" );
print( "Ans/(2*a)" );
equ := equ / ( 2*a ); // (2*a*x/(2*a)) = (-b+√(-4*a*c+b^2))/(2*a)
print( string( equ ) );
print( "" );
print( "simplify(Ans)" );
equ := simplify( equ ); // x1 = (-b+√(-4*a*c+b^2))/(2*a)
equ := expr( replace( string( equ ), "x", "x1" ) );
print( string( equ ) );
print( "" );
print( "expr(replace(string(equ),"-b+","-b-"))" );
equ1 := expr( replace( string( equ ), "-b+", "-b-" ) ); // x2 = (-b-√[b^2-4*a*c])/(2*a)
equ1 := expr( replace( string( equ1 ), "x1", "x2" ) );
print( string( equ1 ) );
print( "[PAUSE]" ); wait( );
return "done";
end;
#end