Apologies if this is obvious -- I'm very new to Mathematica.
I'm trying to minimize the solution to an ODE with respect to a variable. The following code generates the solution to the ODE,
sol=DSolve[
{(1/2) * σ^2 * k''[q] + μ*k'[q] - λ*k[q] == 0,
k'[0] == -mc, k'[b] == me}, k, q]
but when I try minimizing using the Minimize
(with respect to only q) command,
Minimize[k[q] /.First@sol, q]
I'm coming up empty -- it should return the minimum value of k(q)* in terms of $b, \lambda, \mu, \sigma$, $me$ and $mc$ as well as q* in terms of $b, \lambda, \mu, \sigma$, $me$ and $mc$.
* Update *
The following code works (thank you @bbgodfrey):
s = Simplify[k[q] /. DSolve[{(1/2)*σ^2*k''[q] + μ*k'[q] - λ*k[q] == 0,k'[0] == -mc, k'[b] == me}, k[q], q][[1, 1]]]
sq=q /. Solve[D[s, q] == 0, q][[2, 1]]
kq = Simplify[s /. q -> sq]
But a second minimization with respect to b of the function
Gq = kq + b*\[Gamma]
I start to run into trouble again. I try:
Minimize[Gq,b]
returns unevaluated. This also doesn't work:
sb=b/. Solve[D[Gq, b] == 0, b]
Any help would be very much appreciated!
Minimize
? I am also not sure that I understand your double-minimization requirements. Could you expand on that? Also, considersol = DSolve[...]; k[q] /. First@sol
: that should give you the function you want to minimize. $\endgroup$