Sign of symbolic algebraic expression

Is there any algorithm that can find the sign of an arbitrary symbolic algebraic expression specified in the "Tree-form"?

I know that a general algorithm does not exist, because the problem of recognizing zero is insoluble for an arbitrary expression, but how do I approach the problem of finding the sign of an expression? (how is this done in computer algebra?)

For example: sign(sqrt(2)-1) = ?

+4
source share
1 answer

Rate function value

( ), , +, - !!! :

  • (id, , , ), :

    +,-,*,/,sin,cos,....
    

    , . . (, ) (push,pop). , +,- 1 2 ( !!!).

    :

    - /:

    variables[](id,name,value)
    constants[](id,name,value)
    numbers  [](id,    ,value)
    

    , , . int. type ( ), - id ( ).

    :

    sign(sqrt(2)-1)
    

    :

    id type
    0  function
    1  number
    2  constant
    3  variable
    

    :

    id name   pointer
    0  '('    ???
    1  ')'    ???
    2  '+'    ???
    3  '-'    ???
    4  '*'    ???
    5  '/'    ???
    6  'sqrt' ???
    7  'sign' ???
    

    . :

    id value
    0  2  
    1  1
    

    :

    type id
    0    7   // sign(1 operand)
    0    6   // sqrt(1 operand)
    1    0   // 2
    0    3   // - (2 operands)
    1    1   // 1
    
  • .

    • init

      op1=0`,`op2=0, // set all operands to zero (number depends on supported functions usually 2)
      opn=0          // actual operands number
      fx=none        // actual function (for example none=-1)
      fxn=0          // actual function operands number
      
    • (, , ), op? opn++.

      fx,fxn

    • if opn == fxn

      , fx

      op1=fxtab[fx].pointer(op1,op2,...)
      fx=none,fxn=1
      opn=1  (some spec functions can return more operands, then set op1,op2,.. opn=...)
      
    • goto # 2,

    • op1

( ++):

double sign(double op1) 
 { 
 if (op1>0.0) return +1.0; 
 if (op1<0.0) return -1.0; 
 return 0.0; 
 }
double sqrt1(double op1) { return sqrt(op1); }
double plus1(double op1) { return op1; }
double minus1(double op1) { return -op1; }
double plus2(double op1,double op2) { return op1+op2; }
double minus2(double op1,double op2) { return op1-op2; }

[]

, function = "";. , , .

- , - . , .

(, , NaN, Inf...)

,

0

All Articles