0
$\begingroup$

I´d like to find the zeros of a function. I know I could find them by

Solve[f[x] == 0, x] 

but that gives me only the x-coordinates. I want to get both the value of the maximum and the x-coordinate at which it occurs in the same form as the output from

FindMaximum[f[x], {x, 1}]

which returns both; e.g.,

{2, {x->3}}

Is there such a command? I´d like to use it later on to connect the zero of a derivative with the maximum of its antiderivative. Like this

Plot[{f[x], f´[x]}, 
  Epilog->{Line[{{x /. FindZero[f´[x], {x, 1}][[2]],
                  FindZero[f´[x], {x, 1}][[1]]},
                 {x /. FindMaximum[f[x], {x, 1}][[2]],
                  FindMaximum[f[x], {x, 1}][[1]]}}]

Well, since it´s not valid code, it doesn´t work, and I'm not sure how to write something like it that could work. I just wondered if there´s a built-in function or easily-written function to do what I label with FindZero?

Currently, I'm using

Plot[{f[x], f´[x]}, 
  Epilog->{Line[{{x/.FindMaximum[f[x], {x, 1}][[2]], 0},
                 {x/.FindMaximum[f[x], {x, 1}][[2]],
                  FindMaximum[f[x], {x, 1}][[1]]}}]

but I would be happier using the zero of the derivative. (What I do right now seems like cheating because I want to show the maxima occur at the zeros.)

$\endgroup$
  • 2
    $\begingroup$ First element would be 0 so maybe just {0,{#}}&@@@Solve[...? $\endgroup$ – Kuba Jul 21 '13 at 14:12
  • $\begingroup$ Just to reiterate @Kuba's comment, can you clarify what you are looking for, since by definition, the y-value returned will always be 0? $\endgroup$ – bobthechemist Jul 21 '13 at 14:23
  • $\begingroup$ f'[x0]==0 does not imply that f[x] has maximum at x0. $\endgroup$ – Kuba Jul 21 '13 at 14:53
  • $\begingroup$ It doesn't look like cheating to me. $\endgroup$ – Michael E2 Jul 21 '13 at 15:09
  • 2
    $\begingroup$ Perhaps you are looking for FindRoot? Maybe something like Attributes[findZero] = {HoldAll}; findZero[expr_, x_] := {expr /. #, #} & @ FindRoot[expr, {x, 0}] then findZero[Sin[x] + Exp[x], x]? $\endgroup$ – Mr.Wizard Jul 21 '13 at 15:16
5
$\begingroup$

While this answer does not address the question in the current title or first part of the question, it does answer the ultimate goal explained in the latter part of the question.

The following uses MeshFunctions and Mesh to connect the points on the graphs of f[x] and f'[x] where f'[x] == 0. (The graphs are drawn as mesh lines on an invisible plot of the region connecting the two curves.)

f[x_] := Sin[x];
ParametricPlot[{x, (1 - t) f[x] + t f'[x]},
 {x, -6, 6}, {t, 0, 1},
 PlotPoints -> {25, 2}, PlotStyle -> None, BoundaryStyle -> None,
 MeshFunctions -> {Function[{x, y, x0, t}, f'[x]], #4 &, #4 &}, 
 Mesh -> {{0}, {0}, {1}}, MeshStyle -> {Orange, ColorData[1][1], ColorData[1][2]}]

Function and derivative

(As @Kuba pointed out in a comment, the zeros of the derivative are connected to more than just the maxima.)

$\endgroup$
  • $\begingroup$ I know (derivative=0 is not (just) a max.). I am doing this with min. and the "special point of inflection" (= has a special name in my language (=German): "Sattelpunkt"=sattlepoint (like a saddle of a horse)) in the same way. $\endgroup$ – Janesey Jul 21 '13 at 19:25
  • $\begingroup$ Thanks for the answer, i will work with it (tomorrow). $\endgroup$ – Janesey Jul 21 '13 at 19:26
  • $\begingroup$ @Janesey I guessed that you knew that -- I was concerned you might want only the max. pts. marked. We have "saddle point" in English, too, but only for two dim. and higher -- and it's not quite the same as a point of inflection. For example, no plane section of $z=xy$ has a pt. of infl., but $x=y=0$ is a saddle point. Hope the answer works for you. $\endgroup$ – Michael E2 Jul 21 '13 at 19:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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