将变量声明为最大值中的正实数?

问题描述 投票:4回答:1

我有以下最大代码:

declare(p, real)$
declare(q, real)$
declare(m, real)$
is(-(4*p^2*q^2)/m^2-(4*p^4)/m^2  < 0);

这评估为未知。我可以声明p,qm是正实数吗?

maxima
1个回答
1
投票

Short answer to the question

将@Michael O.的评论放入答案的形式:

assume函数可用于设置变量的谓词,特别是告诉maxima数字是正数(这对于使用integrate计算一些积分也很有用)

assume(p>0,q>0,m>0);
is(-(4*p^2*q^2)/m^2-(4*p^4)/m^2  < 0);

Some more functions for managing predicates

可以使用facts函数显示谓词列表,并使用forget函数删除

kill(all); /*Clears many things, including facts*/
assume(a>0,b>0,c>0)$ /*Learn facts*/
facts();
forget(b>0)$ /*Forget one fact*/
facts();
forget(facts())$ /*Forget all known facts*/
facts();

Example of usage of assume with integrate function

一些数学结果取决于例如一些参数的标志。特别是一些积分的情况。

(%i0) print("Without predicates: Maxima prompts the user")$
      kill(all)$
      L : sqrt(1 - 1/(R^2))$
      facts();
      integrate(x,x,0,L);

      print("With predicates: Maxima does not need to prompt the user because it already knows the answer")$
      kill(all)$
      assume(R>0)$
      L : sqrt(1 - 1/(R^2))$
      facts();
      integrate(x,x,0,L);

Without predicates: Maxima prompts the user
(%o0) []
Is "R" positive or negative? positive;
(%o1) (R^2-1)/(2*R^2)
With predicates: Maxima does not need to prompt the user because it already knows the answer
(%o2) [R>0]
(%o3) (R^2-1)/(2*R^2)
© www.soinside.com 2019 - 2024. All rights reserved.