10

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?

Kasper
  • 12,594
  • 12
  • 41
  • 63

1 Answers1

6

Short answer to the question

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);

Some more functions for managing predicates

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();

Example of usage of assume with integrate function

Some 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)
Gael Lorieul
  • 3,006
  • 4
  • 25
  • 50