I want to write a function that takes the derivative of f
wrt y1
and then find the root of this derivative when y1
equals y2
. The function f
contains several integrals, y1
, y2
and x
also appear as limits of the integrals. Eventually I would like to be able to vary x
and see how the root changes.
Below is the closest I've gotten, but doesn't work.
fd[x_?NumericQ, y1_?NumericQ, y2_?NumericQ] := D[f[x, y1, y2], y1]
fr[x_?NumericQ, y10_?NumericQ] :=
y1 /. FindRoot[fd[x, y1, y1]==0, {y1, y10}]
Am I missing a HoldAll condition for y2
in fd
?
FindRoot
works with equations. So, you have to addEqual
to your code. 2. ThatFindRoot
is a completely numerical procedure. Therefore, all your parameters must be assigned to some number. Are you going to assignx
to something? $\endgroup$fd
should be equal to 0. And yes,x
will be assigned a number to evaluatefr
. $\endgroup$D[f[x, y1, y2], y1]
won't work ify1
is a number. Search the site; there are many solutions presented. Depending onf
,fd[x_?NumericQ, y1_?NumericQ, y2_?NumericQ] = D[f[x, y1, y2], y1]
might work. So mightfd[x_?NumericQ, y1_?NumericQ, y2_?NumericQ] := Derivative[0,1,0][f][x, y1, y2]
, but it's probably better to compute the derivative once and use the result (again, depends onf
). $\endgroup$FindRoot[x^2 - 2, {x, 1}]
works without an explicitEqual
. (See the first paradigm in the docs forFindRoot
.) $\endgroup$