Post Reply 
= to ==, why? [SOLVED]
12-09-2016, 07:58 PM (This post was last modified: 02-12-2017 07:32 AM by Han.)
Post: #2
RE: = to ==, why?
From a programming point of view, there must be a way of distinguishing the operation that tests whether two things are equal in value (==) and the operation that equates two objects (=) in a symbolic manner. So setting the variables x equal to y (i.e. making the two variables interchangeable) is different from testing if the quantity represented by x is equal to the quantity represented by y. This is really only meaningful in the CAS view. In Home view (non-CAS), there is generally no symbolic manipulation so that "=" and "==" are treated the same (i.e. both stand for testing if two values are equal).

Your CAS program uses non-CAS commands which forces "translation" since non-CAS commands generally do not know how to handle symbolic input; hence the translation to the more common programmatic representation for testing equality (i.e. ==). You also declared equ from the non-CAS side when you really wanted equ to be a CAS variable.

Why not just (within the CAS program) do

eq1:= a*x^2+b*x+c = 0;
eq1:= eq1*4*a;
print(eq1)

rather than passing things back and forth between your main CAS program and non-CAS subroutines? Here's a partially edited program which you can modify to fit your needs (and also to complete based on what is already there).

PHP Code:
export lineByLineFlag := 0;
export equ;
#cas
    
deductionQuadFormula5():=
    
begin
    local ansStr
;

    print; 
// Clear Terminal Window 
    
print( "***** Deduction Quadratic Formula *****" ); // Title
    
freeze;
    
wait();
    
    
choose_cas(); 
        
freeze;
    
    
assume(a>0); 
    print( 
"Quadratic Equation" );
    
eq1:= a*x^2+b*x+c=0;
    print( 
">"+eq );     
    
pause();
    
eq1 := eq1 4*a;
    print(
eq1); pause(); 
    
eq1 := expand(eq1);
    print(
eq1); pause();
    
eq1 := eq1 b^4*a*c
    eq1 
:= simplify(eq1);
    print(
eq1); pause();
    
eq1 := factor(eq1);
    print(
eq1); pause();
    
eq1 := sqrt(eq1);
    
eq1 := subst(eq1abs(2*a*x+b)=2*a*x+b);
    print(
eq1); pause();
end;
#end 

#cas
    
str2exprstr ):=
    
begin
      local step1
;
      print( 
">"+str );    
      
step1:= replacestr"answer",  "(" equ ")" );
      print( 
">"+step1 ) ;
      
equ := exprstep1 );
      print( 
"" ); 
      print( 
""equ );
    
end;
#end 

export pause()
begin
  
if lineByLineFlag == 1 then         
    
print( "                                                                [PAUSE]"  ); wait( );
    else 
      print( 
"" );
  
end;    
end;

export choose_cas()
begin
  local keyPressedOnMenu 
:= 0;
  
local currentPos := 2;
  
keyPressedOnMenu := choose(currentPos,"Pause every step", { "No""Yes" });
  if 
keyPressedOnMenu then
    
if currentPos == 2 then
      
print( "Any key to continue after [PAUSE]" );
      
lineByLineFlag := 1;
    else 
      print( 
"Use cursor keys ↑↓ to move the output screen" );
      
lineByLineFlag:= 0;
    
end;
    print( 
"" ); 
  else
    
kill;
  
end;    
end

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
= to ==, why? [SOLVED] - compsystems - 12-09-2016, 05:53 PM
RE: = to ==, why? - Han - 12-09-2016 07:58 PM
RE: = to ==, why? - compsystems - 12-09-2016, 10:15 PM
RE: = to ==, why? - Han - 12-10-2016, 05:46 AM
RE: = to ==, why? - compsystems - 12-10-2016, 07:07 PM
RE: = to ==, why? - Han - 12-10-2016, 09:39 PM
RE: = to ==, why? - compsystems - 12-11-2016, 03:08 PM



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