我有以下最大代码:
declare(p, real)$
declare(q, real)$
declare(m, real)$
is(-(4*p^2*q^2)/m^2-(4*p^4)/m^2 < 0);
这评估为未知。我可以声明p,q
和m
正实数吗?
答案 0 :(得分:1)
将@Michael O.的评论放入答案形式:
assume
函数可用于在变量上设置谓词,特别是告诉最大值一个正数(这对于使用integrate
计算某些积分也很有用)
assume(p>0,q>0,m>0);
is(-(4*p^2*q^2)/m^2-(4*p^4)/m^2 < 0);
可以使用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();
assume
与integrate
函数一起使用的示例一些数学结果取决于例如一些参数的符号。特别是某些积分的情况。
(%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)