Package: calculus-of-variations
AboutMy bachelor project on solving theCalculus of variationsproblems using symbolic mathematics (2018).Iparticipatedwith this project at the IX International Scientific and Practical Conference named after A.I. Kitov "Information Technologies and Mathematical Methods in Economics and Management" (link).Mypresentationabout this project.What is Calculus of variationsAccording toWikipedia:Thecalculus of variationsis a field of mathematical analysis that uses variations, which are small changes in functions and functionals, to find maxima and minima of functionals: mappings from a set of functions to the real numbers. Functionals are often expressed as definite integrals involving functions and their derivatives. Functions that maximize or minimize functionals may be found using the Euler–Lagrange equation of the calculus of variations.Simplest problemThe definition above might seem quite difficult to understand, so let's consider the simplest problem:This is the task of finding an extrema in continuously differentiable functions space, where:- functional to maximize/minimize,- fixed closed line segment,- continuously differentiable function,- function derivative,- boundary conditions.ExampleEuler–Lagrange equationFunctions that maximize or minimize functionals may be found using theEuler–Lagrange equationof the calculus of variations:, where- partial derivative ofw.r.t.,- partial derivative ofw.r.t..Arbitrary constants arising when solving this differential equation, find them from the given boundary conditions.List of supported problemsSimplest problemBoltz problemIsoperimetric problemHigher derivatives problemMultidimensional problemMore about each task inproject wiki.UsageFirst, install the package:pip install calculus-of-variationsUsage for example above:importcalculus_of_variationssolver=calculus_of_variations.SimplestSolver(L="x_diff ** 2 + t * x",t0="0",t1="1",x0="0",x1="0",)solver.solve()# integral from 0 to 1 of (x_diff ** 2 + t * x)dt -> extr# x(0) = 0# x(1) = 0# general_solution: C1 + C2*t + t**3/12# coefficients: {C1: 0, C2: -1/12}# particular_solution: t**3/12 - t/12# extrema_value: -1/180Other cases:# Simplest problemsolver=calculus_of_variations.SimplestSolver(L="x_diff ** 2",t0="0",t1="1",x0="0",x1="1",)solver.solve()# Boltz problemsolver=calculus_of_variations.BoltzSolver(L="x_diff ** 2 + 2 * x",l="x_t0 ** 2",t0="0",t1="1",)solver.solve()# Isoperimetric problemsolver=calculus_of_variations.IsoperimetricSolver(f0="x_diff ** 2",t0="0",t1="1",x0="0",x1="1",f_list="x",alpha_list="0",)solver.solve()# Higher derivatives problemsolver=calculus_of_variations.HigherDerivativesSolver(n="2",L="x_diff_2 ** 2",t0="0",t1="1",x0="0",x1="0",x0_array="0",x1_array="1",)solver.solve()# Multidimensional problemsolver=calculus_of_variations.MultidimensionalSolver(L="x1_diff**2 + x2_diff**2",t0="0",t1="1",x1_0="0",x1_1="1",x2_0="0",x2_1="1",)solver.solve()For specific examples seeexamples.sh.List ofallowed functionsthat you can use as parameters:link.Web-interfaceThe project supports simple web-interface for solving problems.
You can specifyhost(--host) andport(--port) (default values:host: 127.0.0.1andport: 8050):# Simplest problem
python -m web_interface.simplest_problem_dash --host "127.0.0.1" --port 8050

# Boltz problem
python -m web_interface.boltz_problem_dash --host "127.0.0.1" --port 8050

# Isoperimetric problem
python -m web_interface.isoperimetric_problem_dash --host "127.0.0.1" --port 8050

# Higher derivatives problem
python -m web_interface.higher_derivatives_problem_dash --host "127.0.0.1" --port 8050

# Multidimensional problem
python -m web_interface.multidimensional_problem_dash --host "127.0.0.1" --port 8050You can also launch web-interface using docker.To build docker image run:docker image build -t calculus_of_variations .You can also pull image fromDocker Hub:docker pull dayyass/calculus_of_variationsTo start docker container run (example forsimplest_problem_dash):docker container run -d -p 8050:8050 --name calculus_of_variations calculus_of_variations python -m web_interface.simplest_problem_dash --host 0.0.0.0 --port 8050To access web-interface go tohttp://localhost:8050TestsTo launchtestsrun the following commands:python -m unittest discoverTo usepre-commithooks run:pre-commit installTo measurecode coveragerun the following commands:coverage run -m unittest discover && coverage report -mRequirementsPython >= 3.6CitationIf you usecalculus-of-variationsin a scientific publication, we would appreciate references to the following BibTex entry:@misc{dayyass2018variations,author={El-Ayyass, Dani},title={Calculus of Variations problems solving using symbolic mathematics},howpublished={\url{https://github.com/dayyass/calculus-of-variations}},year={2018}}