 Application Center - Maplesoft

# The VariationalCalculus Package

You can switch back to the summary page by clicking here.

The Calculus of Variations in Maple 8

Introduction

The new VariationalCalculus  package provides routines for solving problems in the calculus of variations, which studies nature's most "efficient" curves and surfaces.  Classical problems from the calculus of variations include:

• Find the shortest path between two points on a 3-D surface, such as a cone (a geodesic problem).
• Shape a ramp between two heights such that a ball rolling down it reaches the bottom in minimum time (the Brachistochrone problem).
• Find the shape of a soap film having minimum surface area spanning a given wire frame.

Such problems can often be solved with the Euler-Lagrange equation, which generalizes the Lagrange Multiplier Theorem for minimizing functions of real variables subject to constraints.  The Euler-Lagrange equation is easy to write down in general but notoriously difficult to write down and solve for most practical problems.  The VariationalCalculus  package automates the construction and analysis of the Euler-Lagrange equation.

 >

Example: The Brachistochrone Problem

The Brachistochrone problem can be stated as follows: Given two endpoints in the plane, find the curve y(x) between them such that a ball of unit mass rolls along the curve under the influence of gravity in minimum time.

 > restart;

 > with(VariationalCalculus); First we write down the falling time over an infintesimal distance dx in terms of y(x)  and yInit , assuming the gravitational constant is 1.  This is found in standard textbooks on classical mechanics.

 > fallTime := sqrt( (1+diff(y(x),x)^2)/(2*(yInit-y(x))) ); We then use the EulerLagrange  function to compute the Euler-Lagrange equations for this functional in terms of y(x)  and its derivatives.  This returns a set of ODEs.

 > EL := EulerLagrange( fallTime, x, y(x) ) ;   Extract the first ODE from the list

 > ODE1 := remove(has, EL, diff(y(x),x,x)); Compute y(x)  as a parametric curve (x(s), y(s)) using the dsolve  command with the parametric  option.

 > sol := dsolve(ODE1, parametric, y(x)); > sol := subs( {_T=s}, sol); > assign(sol);

Specify the endpoints of the curve: (0,1)  and (1, 1/2)

 > xInit := 0; yInit := 1; xEnd := 1; yEnd := 1/2;    The parameter s  is not equivalent to time t , so we must solve for the value of s  at which > solve(y(s)=yEnd, s); > sEnd := %; Use the endpoints to solve for the unknown constants K  and _C1

 > _C1 := solve(subs({s=sEnd}, x(s)) = xEnd, _C1); The finite-length curve (x(s), y(s))  is parametrized over , so > limit(x(s), s=-infinity); > K := fsolve( % = xInit, K); The path along which a ball would roll in minimum time under the influence of gravity.  The result is surprising because the curve actually dips below the right end point.

 > plot([x(s),y(s), s=-10..10], xInit..xEnd, 0..yInit); 