16
$\begingroup$

I am trying to solve an equation by assuming that all the variables are real and strictly positive. I can use the keyword Reals for the argument dom in the Solve function Solve[expr,vars,dom]. Is there an equivalent for strictly positive Reals? Something like PosReals

$\endgroup$

4 Answers 4

11
$\begingroup$

There's a misunderstanding here. The third "dom" argument is not simply a set over which we solve the equation. There are only a few choices that can be used for the domain argument, and they have very specific effects on how Solve works. An example from the documentation:

If dom is Reals, or a subset such as Integers or Rationals, then all constants and function values are also restricted to be real.

So you can't use e.g.

Solve[x^2 == 1, x, Interval[{0, Infinity}]]

The proper way to do this, as @belisarius said, is to append the constraint to the system of equations:

Solve[x^2 == 1 && x > 0, x]

In version 10 we can also do

Solve[x^2 == 1 && x ∈ Interval[{0, Infinity}], x]

or even

Solve[x^2 == 1, x ∈ Interval[{0, Infinity}]]
$\endgroup$
1
  • $\begingroup$ That totally makes sense now +1. Thanks a lot! $\endgroup$
    – Remi.b
    Mar 27, 2015 at 0:45
7
$\begingroup$

New in Mathematica 12 is PositiveReals (and others like NonNegativeIntegers, etc):

Solve[x^2 == 1, x, PositiveReals]

{{x -> 1}}

$\endgroup$
4
$\begingroup$
{Solve [ x^2 == 1, {x}], Solve [ x^2 == 1 && x > 0, {x}]}
(* {{{x -> -1}, {x -> 1}}, {{x -> 1}}}*)
$\endgroup$
2
$\begingroup$

If you are dealing with multiple variables, I suggest you to use Assumptions under function Refine, like below

Refine[Reduce[{52*n^2 + 19*n*nb - 42*n*nf > 0, 52*n^2 - 61*n*nb - 42*n*nf > 0}, {n, nb, nf}], Assumptions -> n > 0 && nb > 0 && nf > 0]

This feature can be used for most type operations. For reference, please see Assumptions.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.