# Minimization with cos()^2

1. Mar 13, 2015

### dirk_mec1

I'm trying to find a increasing postive function $\phi (x)$ that minimizes the following integral for x in [0, L]:

$$\int_0^L A \frac{ d ^2 \phi (x) } {dx^2}+ (B +C cos( \phi (x)) ^2 \mbox{d}x$$

with A and B real positve numbers and
$\phi (0) =0$
$\phi ' (L) =0$

When I use the the Lagrange equations I get:

$$\phi '' (x) + D sin(\phi (x) ) + E sin(\phi (x) ) cos( \phi (x) ) = 0$$

with D and E a constant.

Is this correct?

Can I find a numerical solution for this nonlinear ODE?

Last edited: Mar 13, 2015
2. Mar 13, 2015

### Alexandre

I think there are problems with the integral, first of all first term in the integral is not in the differential form, secondly shouldn't the action be an integral taken by time dt instead of coordinate dx? Otherwise I'm not sure you can use Lagrangian to minimize that integral, I might be wrong. And one more thing, Lagrangian should not be dependent on the second derivatives.

3. Mar 13, 2015

### dirk_mec1

Yes only the x-coordinate is applicable. The first term should be a square.

$$\int_0^L A \left( \frac{ d \phi (x) } {dx} \right) ^2 + (B +C cos( \phi (x)) ^2 \mbox{d}x$$

A, B and C are constants.

Can I use a numerical solver like Runge-Kutta for the solution (as I posted in the first post)?

Last edited: Mar 13, 2015
4. Mar 13, 2015

### Alexandre

Square of derivative is not same as second derivative and parentheses are missing:

$$\int_0^L ( A \left( \frac{ d \phi (x) } {dx} \right) ^2 + (B +C cos( \phi (x)) ^2 \mbox ) {d}x$$

Applying Euler-Lagrange equation which has a form:

$$\frac{d}{dx}\frac{\partial L}{\partial \frac{d\phi }{dx}}-\frac{\partial L}{\partial \phi }=0$$

What I get is

$$A\cdot \phi \:''+C\cdot cos\left(\phi \:\right)sin\left(\phi \:\right)=0$$

And sure, you can now apply numerical analysis to solve this.

5. Mar 16, 2015

### dirk_mec1

Yes I forgot brackets. I am pretty sure you forgot a term.

If you work out the second squared term you'll get this:

$$B^2 +2BCcos( \phi) + C^2 cos( \phi )$$

Which will lead to a sin() and a sin()*cos().

6. Mar 16, 2015

### Alexandre

Ups, sorry, I did. Did you figure out how to do the numerical approximation?

7. Mar 17, 2015

### dirk_mec1

Yes, I can use the bvp solver of Matlab. If I want to so this by hand I have to use finite elements, right?

8. Mar 17, 2015

### dirk_mec1

If D is some function of x is it still possbile to solve this numerically? Thus:

$$\phi '' (x) + D(x) sin(\phi (x) ) + E sin(\phi (x) ) cos( \phi (x) ) = 0$$

Or do I have to use finite elements?

Last edited: Mar 17, 2015
9. Mar 23, 2015

### Alexandre

If D is not constant you should have took care of it when writing Euler-Lagrange equation by applying derivative to it too.

10. Mar 24, 2015

### dirk_mec1

No, because it is only dependent on x and not of phi(x).

11. Mar 27, 2015

### Alexandre

Oh, you're right again.