2
$\begingroup$

I have some functions like the below one:

(1/2)(-1+(3 + Abs[3 - 4 p] + Abs[3 - 2 p])/(Abs[3 + 2p]))

and I need to find the minimum value of p for which f(p)=0. When I use "Solve" command:

Solve[f==0,-p]

I get no answer. In fact there is an interval for p in which f(p)=0, but I need the minimum value of p on in other words I need to find the first place in which f(p)=0.

$\endgroup$
6
  • 2
    $\begingroup$ For such functions making use of Abs, where have whole ranges that are zero (as can be seen by Plot[f, {p, -1, 4}]), you will have better luck using FindRoot (FindRoot[f, {p, 1.}]) $\endgroup$ Commented Nov 22, 2016 at 19:56
  • $\begingroup$ $\LaTeX$ is supported on this site, but with the use of \$ or $$. For code, you can use the backticks or a four-space indentation. $\endgroup$
    – corey979
    Commented Nov 22, 2016 at 19:58
  • $\begingroup$ Dear Manuel --Moe-- G , Thank you so much for your helpful guidance. $\endgroup$
    – Najmeh
    Commented Nov 22, 2016 at 20:04
  • $\begingroup$ Dear corey979, Thank you so much for your guidance. $\endgroup$
    – Najmeh
    Commented Nov 22, 2016 at 20:12
  • 2
    $\begingroup$ Plotting the function will help you decide and when one can either change Abs[x] to x or -x: Plot[f, {p, -0, 2}]. And then use Solve. $\endgroup$
    – JimB
    Commented Nov 22, 2016 at 20:13

2 Answers 2

5
$\begingroup$

Reduce can be useful for this kind of thing:

f[p_] := (1/2) (-1 + (3 + Abs[3 - 4 p] + Abs[3 - 2 p])/(Abs[3 + 2 p]));
Reduce[f[p] == 0, p, Reals]

3/4 <= p <= 3/2

Hence the smallest is 3/4.

$\endgroup$
1
  • $\begingroup$ Thank you so much for your kind help. $\endgroup$
    – Najmeh
    Commented Nov 23, 2016 at 17:47
3
$\begingroup$

You can also use Minimize

f[p_] = (1/2) (-1 + (3 + Abs[3 - 4 p] + Abs[3 - 2 p])/(Abs[3 + 2 p]));

Minimize[{p, f[p] == 0}, p]

(*  {3/4, {p -> 3/4}}  *)
$\endgroup$
1
  • $\begingroup$ Thank you so much for your kind help. $\endgroup$
    – Najmeh
    Commented Nov 23, 2016 at 17:47

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