要求最大值不要求正,负或零

时间:2013-01-12 07:04:26

标签: maxima

有没有办法告诉maxima表达总是正面的?下面是一个示例代码段,可让maxima向表达式sin(a)*x询问问题:

 declare([a,x,y],real);
 ca: cos(a) = (x / (sqrt(x*x + y*y)));
 a1: solve(ca,a)[1];
 solve(a1,y);

2 个答案:

答案 0 :(得分:13)

您可以使用assume。来自Maxima自己的文档:

    -- Function: assume (, ..., )
     Adds predicates , ...,  to the current context.
     If a predicate is inconsistent or redundant with the predicates in
     the current context, it is not added to the context.  The context
     accumulates predicates from each call to `assume'.

     `assume' returns a list whose elements are the predicates added to
     the context or the atoms `redundant' or `inconsistent' where
     applicable.

     The predicates , ...,  can only be expressions
     with the relational operators `=' and `>'.
     Predicates cannot be literal equality `=' or literal inequality
     `#' expressions, nor can they be predicate functions such as
     `integerp'.

     Compound predicates of the form ` and ... and '
     are recognized, but not ` or ... or '.  `not
     ' is recognized if  is a relational predicate.
     Expressions of the form `not ( and )' and `not
     ( or )' are not recognized.

     Maxima's deduction mechanism is not very strong; there are many
     obvious consequences which cannot be determined by `is'.  This is
     a known weakness.

     `assume' evaluates its arguments.

     See also `is', `facts', `forget', `context', and `declare'.
 Examples:

      (%i1) assume (xx > 0, yy < -1, zz >= 0);
      (%o1)              [xx > 0, yy < - 1, zz >= 0]
      (%i2) assume (aa < bb and bb < cc);
      (%o2)                  [bb > aa, cc > bb]
      (%i3) facts ();
      (%o3)     [xx > 0, - 1 > yy, zz >= 0, bb > aa, cc > bb]
      (%i4) is (xx > yy);
      (%o4)                         true
      (%i5) is (yy < -yy);
      (%o5)                         true
      (%i6) is (sinh (bb - aa) > 0);
      (%o6)                         true
      (%i7) forget (bb > aa);
      (%o7)                       [bb > aa]
      (%i8) prederror : false;
      (%o8)                         false
      (%i9) is (sinh (bb - aa) > 0);
      (%o9)                        unknown
      (%i10) is (bb^2 < cc^2);
      (%o10)                       unknown

答案 1 :(得分:0)

'assume' 在关系运算符两侧有空格时起作用。换句话说,在我的例子中:假设(L>0)不起作用,但假设(L> 0)起作用!