6
$\begingroup$

I'm VERY new to Mathematica and would like some help with minimizing a function.

$$f(x) = \frac{1}{2} \sqrt{\frac{\left(l^4+x^4\right)^2}{l^4 x^2}}$$

I want to find which $x-value$ (probably depending on $l$) yields the lowest function value, where $l > x > 0$.

Mathematica input for function:

1/2 Sqrt[(l^4 + x^4)^2/(l^4 x^2)]

What I tried:

Minimize[1/2 Sqrt[(l^4 + x^4)^2/(l^4 x^2)], {x}]

Manipulate[
 Plot[1/2 Sqrt[(l^4 + x^4)^2/(l^4 x^2)], {x, 0, l}], {l, 1, 10}]

Output:

Output

$\endgroup$
  • $\begingroup$ Please post the code you already tried $\endgroup$ – Dr. belisarius Dec 18 '14 at 23:43
  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$ – Dr. belisarius Dec 18 '14 at 23:43
  • $\begingroup$ Plot[1/2 Sqrt[(x (l + x)^2)/l] /. l -> 1, {x, 0, 1}] $\endgroup$ – Dr. belisarius Dec 18 '14 at 23:47
  • $\begingroup$ The output you're getting seems the right answer. What do you expect? $\endgroup$ – Dr. belisarius Dec 18 '14 at 23:51
  • 1
    $\begingroup$ @B.Lee plot instead from -0.9 to 0.9, you will see that your expression is symmetric under x->-x. So if there's a minimum at +0.759 there is also one at -0.759. You might also try Solve[D[1/2 Sqrt[(l^4 + x^4)^2/(l^4 x^2)], x] == 0, x]. $\endgroup$ – evanb Dec 19 '14 at 0:13
10
$\begingroup$

The output looks fine to me. It is, however, relatively complicated. Consider the following simpler example

Minimize[x (x - c), x]
(* Out: {-c^2/4, {x -> c/2}} *)

Thus, there is a minimum value of $y=-c^2/4$ at $x=c/2$, as expected. Now, let's complicate things slightly.

Minimize[c x (x - c), x] 

enter image description here

This is a piecewise expression, which is necessary since the result depends crucially on whether $c$ is positive, negative, or zero. Your problem has generated a piecewise expression for the same reason. You've also got a further complication since Mathematica has returned Root expressions. This is is often necessary. For example, the solutions of $x^5-x-1=0$ cannot be easily expressed in terms of radicals. That explains the following cryptic output:

Solve[x^5 - x - 1 == 0, x, Reals]
(* Out: {x -> Root[-1 - #1 + #1^5 &, 1]}} *)

Thus, the one real solution is the first root of $-1-x+x^5$. Doesn't seem very useful, but you can evaluate this numerically.

N[%]
(* Out: {{x -> 1.1673}} *)

Now, your solution is expressed in terms of the roots of a fourth degree polynomial, and we can get an alternative formulation which might be more to your liking. I'm not sure. Here goes, though:

minInfo = Minimize[1/2 Sqrt[(l^4 + x^4)^2/(l^4 x^2)], {x}] //. 
  r_Root :> Simplify[ToRadicals[r]]

enter image description here

A bit better, I guess. It's much better, if you plug in a specific value:

minInfo /. l -> 3
(* Out: {-2 3^(1/4), {x -> 3^(3/4)}} *)

I emphasize that you could have plugged numbers in anyway, as Beli showed in his answer.

$\endgroup$
  • $\begingroup$ WOW! You are.. You are the best! You have no idea how long it's taken me to understand this. I would give you +3 if I could! $\endgroup$ – B. Lee Dec 19 '14 at 0:20
  • 1
    $\begingroup$ @B.Lee An accept is ample and you're welcome. Maybe Beli could bounty it, as he has 64K these days. :) $\endgroup$ – Mark McClure Dec 19 '14 at 0:22
  • 3
    $\begingroup$ @MarkMcClure You've got my +1. My kids already took control of their inheritance. $\endgroup$ – Dr. belisarius Dec 19 '14 at 0:57
7
$\begingroup$
Manipulate[
 p = {x, s@x} /. Last@Minimize[{s@x, l > x > 0}, {x}];
 Plot[s@x, {x, 0, l}, Epilog -> {PointSize[Large], Point@p}, PlotLabel -> p], {l, 1, 10},
 Initialization :> {s@x_ := 1/2 Sqrt[(l^4 + x^4)^2/(l^4 x^2)]}]

Mathematica graphics

$\endgroup$
4
$\begingroup$

Since you give the constraint l > x > 0, you should make use of that constraint

f[x_] = 1/2 Sqrt[(l^4 + x^4)^2/(l^4 x^2)];

min = FullSimplify[
  Minimize[{f[x], l > x > 0}, x], l > x > 0]

enter image description here

min[[1]] == Simplify[f[x /. min[[2]]], l > 0]

True

f'[x] /. min[[2]]

0

Simplify[(f''[x] /. min[[2]]) > 0, l > 0]

True

$\endgroup$
  • $\begingroup$ Thank you. I discovered the equation you got, and figured it didn't print that one out from the start because I hadn't specified the constraints. This helped me see how to apply constraints. $\endgroup$ – B. Lee Dec 19 '14 at 15:27
2
$\begingroup$

here is another way to approach the problem...

enter image description here

$\endgroup$
  • 1
    $\begingroup$ Please post code, not images whenever possible. Thanks a lot! $\endgroup$ – Dr. belisarius Dec 19 '14 at 14:38

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.