I'm trying to find the solution of the brachistochrone problem. I'm was wondering if there is a way to solve it directly using Mathematica. The problem is the following:

$$J[t]=\frac1{\sqrt 2 g}\int_{y_1}^{y_2}\frac{\sqrt{1+y^{\prime 2}}}{\sqrt y}\,dy$$

I have to find the equation $y(x)$ that minimizes the functional $J[t]$. This functional ($y(x)$) is the path of minimum time that a body will move from a point $y_1$ to a point $y_2$.

To achieve that, it is needed to use the Euler equation:



$$f=\frac{\sqrt{1+y^{\prime 2}}}{\sqrt y}$$

The code below is the solution of the Euler equation that I was trying to integrate without success.

Integrate[(-1 - y'[x]^2 - 2 y[x] y''[x])/(
 2 y[x]^(3/2) (1 + y'[x]^2)^(3/2)), {y[x], 0, 1}]

This code returns:

Integral of (-1-(y^\[Prime])[x]^2-2 Integrate`$$a$201005 (y^\[Prime]\[Prime])[x])/Integrate`$$a$201005^(3/2) does not converge on {0,1}. >>

  • 2
    $\begingroup$ It's unclear what you're trying to do here. Could you write up the integral you're actually trying to solve using LaTeX code and add it in to your question? $\endgroup$ Sep 1, 2016 at 13:09
  • $\begingroup$ I have edited the question. Thank you for trying to help. $\endgroup$
    – Stratus
    Sep 1, 2016 at 15:20
  • 2
    $\begingroup$ No, Mathematica can neither read your mind nor do miracles. The equation your are throwing at it is a differential equation that is not solvable via a simple Integrate. You would have to use DSolve for it, but I'm also not sure where it's coming from and don't feel like trying to figure out how you arrived at it. You might want to read up on the treatment of the brachistochrone problem, e.g., on Wolfram MathWorld, and then start with the Beltrami equation. As an aside, in your equations above the gravitational constant belongs underneath the square root. $\endgroup$
    – Pirx
    Sep 1, 2016 at 16:14
  • 3
    $\begingroup$ If you look under Applications in the documentation for EulerEquations, the problem is discussed there. A solution is also given, but it's not found using DSolve. $\endgroup$
    – Jens
    Sep 1, 2016 at 20:02
  • $\begingroup$ Also take a look at the VariationalMethods package: reference.wolfram.com/language/VariationalMethods/guide/… $\endgroup$ Jul 16, 2019 at 9:04

2 Answers 2


You are trying to minimize time, $T$, among all possible paths of a point moving from height $y$ to direction, $x$ from $x_1 = a$ to $x_2=b$.

We know that by definition $dx/dt = v$, were $v$ - velocity, so in general we have

$$ t = \int_{x_1=a}^{x_2=b} \frac{1}{v_x} dx$$

Using conservation law, $\frac{v^2}{2} = g y$, and after some manipulations with $cos(v, v_x)$, where $v_x$ is projection of $v$ to $x$ one comes up with the factorial:

$$ T = \frac{1}{\sqrt{2g}}\int_{a}^{b} \sqrt {\frac {(1+y_x^2)}{y}} dx.$$

Notice that in this statement we see $y$ as a function $y(x)$ of $x$ and from OP's we may guess that $a=0$ and $b=1$. Time here is the function of path, kind of $T(\{y(x)\}| x_1, x_2)$.

As @user42582 suggests, Euler equation is fine to apply here.

solut = DSolve[{D[#, y[x]] - D[D[#, y'[x]], x] == 0}, y[x], x] &@ Sqrt[(1 + y'[x]^2)/(y[x])]
slt = ((y[x] /. solut) /. {C[1] -> 0, C[2] -> 0})

We will get some ugly looking inverse function, comprised of two pieces. A closer look at those pieces let us see that one of them is inverse of:

ArcTan[Sqrt[y]/Sqrt[1 - y]] - Sqrt[1 - y] Sqrt[y]

We can plot those inverse functions taking -slt to keep physical sense.

Plot[-slt, {x, -1 , 1}, AxesLabel -> {"x", "y(x)"}, PerformanceGoal -> "Speed"]

enter image description here

Given our $x$ bounds $[0,1]$ we may conclude that the point will arrive from $(0,0)$ to $(1, -0.916193)$:

-slt[[2]] /. x -> 1



The LHS of what you call an Euler equation can be defined as follows:

f[y[x], y'[x]] := Sqrt[1 + y'[x]^2]/Sqrt[y[x]]

D[f[y[x], y'[x]], y[x]] - D[D[f[y[x], y'[x]], y'[x]], x]

Equating the above expression to zero amounts to a second order differential equation in y(x).

If you want to solve this differential equation you will need some boundary conditions (probably those $y_1$ and $y_2$ integral bounds). Also, you will probably need to check for the appropriate solution strategy for such a differential equation.

The one thing for sure is that a simple Integrate cannot provide the solution you are looking for because that function is not appropriate for your problem.


Your Answer

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

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