# Solve an equation in $\mathbb{R}^+$

How can I solve this equation (both numerically and literally) only in the positive reals $\mathbb{R}^+$?

Solve[x == (v0 - (A CD t v0^2 ρ)/(4m)) Cos[θ] t, t]


And for example, is there a way to have an output like this :

52.0756


and not like this :

{{t -> -52.3918}, {t -> 52.0756}}


?

-
You can add a condition like sol=Solve[{...,t>0},t]; then you can do sol[[All,1,2]]. –  b.gatessucks Nov 6 '12 at 12:26
For the first leg of your question, there is a good tutorial in the documentation of Mathematica entitled "equations and inequalities over domains". Reduce is what you probably want to try out. As for the solutions being given as rules, the documentation of Solve has every possible way to extract those. –  gpap Nov 6 '12 at 12:33

You could use ReplaceAll (i.e. /.) and Select

Select[x /. Solve[x^2 - 1 == 0, x], Positive]


gives

{1}

It is a list (List) not a single number. You might not know how many positive solutions exist:

Select[x /. NSolve[(x - 1) (x + 3) (x - 3) == 0, x], Positive]


{1., 3.}

Edit:

Using Part or its short-hand notation [[]] you can select parts from the list:

Part[{1}, 1]


1

{1}[[1]]


1

Part[{1.,3.},2]

3.
-
Isn't possible remove from the output also the braces, right? –  FormlessCloud Nov 6 '12 at 17:09
@FormlessCloud Yes you can if you have one result, however how would you return 2 numbers without braces ? –  b.gatessucks Nov 6 '12 at 17:25
I have selected the positive reals appositely for have one result, but I don't know how to remove the braces from the output. I don't want the braces because I want use the result as a value for a command and if I keep the braces the result can't be taken as numerical value. –  FormlessCloud Nov 6 '12 at 21:36
@FormlessCloud I updated the answer to show how to get rid of the braces. –  Markus Roellig Nov 7 '12 at 7:37

The first items of More Information in the documentation of Solve says :

• The system expr in Solve[expr,vars] can be any logical combination of:

lhs == rhs               equations
lhs != rhs               inequations
lhs > rhs or lhs >= rhs  inequalities
expr ∈ dom               domain specifications
ForAll[x,cond,expr]      universal quantifiers
Exists[x,cond,expr]      existential quantifiers

• Solve[{ expr1, expr2,...},vars] is equivalent to Solve[ expr1 && expr2 &&...,vars].

Every expri can be an equation, inequality as well as an expression tests like e.g. Positive or Negative etc., thus we can do simply e.g. Solve[-36 + 49 x^2 - 14 x^4 + x^6 == 0 && x > 0, x], but to get only the list of solutions (without Rules ) there are at least two ways:

• using ReplaceAll (shorthand /.) (mentioned by Markus Roellig) with the condition x > 0 :

x/.Solve[-36 + 49 x^2 - 14 x^4 + x^6 == 0 && x > 0, x]

{1, 2, 3}

• using Part (shorthand [[]]) with e.g. x > 0 or with an expression test like Positive, NonNegative etc.:

Solve[-36 + 49 x^2 - 14 x^4 + x^6 == 0 && Positive[x], x][[All, 1, 2]]

 {1, 2, 3}


The above ways can be mixed, e.g. : x /. Solve[-36 + 49 x^2 - 14 x^4 + x^6 == 0 && x > 0, x][[3]]. We needn't point out the domain Reals since the condition x > 0 implies that x is a positive and real number. The same concerns Reduce, i.e. use it like e.g.

Reduce[-36 + 49 x^2 - 14 x^4 + x^6 == 0 && x > 0, x][[All, 2]]

-