I have the following maxima code:
declare(p, real)$
declare(q, real)$
declare(m, real)$
is(-(4*p^2*q^2)/m^2-(4*p^4)/m^2 < 0);
This evaluates to unknown. Can I declare that p,q
and m
are positive real numbers?
To define a function in Maxima you use the := operator. E.g. would return a list with 1 added to each term. f(x) := (expr1, expr2, ...., exprn);
An expression is considered a constant expression if its arguments are numbers (including rational numbers, as displayed with /R/ ), symbolic constants such as %pi , %e , and %i , variables bound to a constant or declared constant by declare , or functions whose arguments are constant.
If you want to refer to the immediately preceding result computed by Maxima, you can either use its o label, or you can use the special symbol percent (%). The standard quantities e (natural log base), i (square root of −1) and π (3.14159…) are respectively referred to as %e, %i, and %pi.
Putting @Michael O.'s comment into the form of an answer:
The assume
function can be used to set predicates on variables, in particular to tell maxima that a number is positive (this is also useful for calculating some integrals with integrate
)
assume(p>0,q>0,m>0);
is(-(4*p^2*q^2)/m^2-(4*p^4)/m^2 < 0);
The list of predicates can be displayed using the facts
function and removed using the forget
function
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
with integrate
functionSome mathematical results depends on e.g. the sign of some parameters. In particular, it is the case of some integrals.
(%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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With