3
$\begingroup$

I am trying to find a minimum of a function depending on a parameter, but I cannot get it to work. For example, I try to find the minima of $\sin(ax)$ where $a$ is a parameter. For example, trying the following doesn't return anything:

Minimize[Sin[a*x], x]

Trying something like

Assuming[a > 0, Minimize[Sin[a*x], x]]

Also doesn't work. What's wrong with my code?

Thanks!

$\endgroup$
2
  • 1
    $\begingroup$ You may try using Reduce like this: Reduce[D[Sin[a x], x] == 0 && D[Sin[a x], {x, 2}] > 0, x]. And the output reads: C[1] \[Element] Integers && a \[Element] Reals && a != 0 && x == -((\[Pi] - 4 \[Pi] C[1])/(2 a)). The idea is to solve for first and second derivatives to find min or max. $\endgroup$
    – Alx
    Jan 16, 2017 at 2:47
  • $\begingroup$ 1. Please have a look at FindMinimum[]. 2. You may use D[] to find your solution applying the rules of calculus. $\endgroup$ Jan 17, 2017 at 15:39

2 Answers 2

3
$\begingroup$
f[a_, x_] = Sin[a*x];

To find all minimums

Assuming[Element[a, Reals],
 Solve[{D[f[a, x], x] == 0, D[f[a, x], {x, 2}] > 0}, x] // Simplify]

(* {{x -> ConditionalExpression[(Pi*(-1 + 4*C[1] - 4*C[2]))/(2*a), 
           (Element[C[1] | C[2], Integers] || Element[C[1] | C[1] - C[2] | C[2], 
                Integers]) && C[1] >= 0 && C[2] >= 0]}} *)

One example,

% /. {C[1] -> 2, C[2] -> 1}

{{x -> (3*Pi)/(2*a)}}

To find the minimum in a single specified cycle

Assuming[a > 0, 
 Solve[{D[f[a, x], x] == 0, D[f[a, x], {x, 2}] > 0, a > 0, 0 <= x < 2 Pi/a}, 
   x] // Simplify]

{{x -> (3*Pi)/(2*a)}}
$\endgroup$
1
$\begingroup$

I don't think Mathematica can analytically minimize a function with infinite amount of minima. How would you reasonable express the result? Anyways, Minimize works well for sufficiently simple functions:

Simplify[Minimize[(a*x)^2 + x, x], Assumptions -> a > 0]
(* {-(1/(4 a^2)), {x -> -(1/(2 a^2))}} *)

Note that you can give constraints on x but not on a within the body of Minimize. Therefore, Simplify is needed to obtain the desired result.

For most more sophisticated functions, numerical methods like NMinimize or (my favorite because of much better computational speed) FindRoot on the derivative. In the end, minimization is not trivial and requires some code that is somewhat optimized for your particular problem.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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