{"id":30117240,"url":"https://github.com/pabrod/potential","last_synced_at":"2026-02-26T19:33:53.901Z","repository":{"id":90018682,"uuid":"84551539","full_name":"PabRod/Potential","owner":"PabRod","description":"A couple of functions for computing path integrals and scalar potentials","archived":false,"fork":false,"pushed_at":"2017-05-17T10:10:25.000Z","size":105,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-10T10:41:40.219Z","etag":null,"topics":["analysis","calculus","mathematics","mechanics","physics"],"latest_commit_sha":null,"homepage":"","language":"Matlab","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PabRod.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-03-10T11:05:51.000Z","updated_at":"2017-03-10T14:29:47.000Z","dependencies_parsed_at":"2023-03-17T19:00:21.533Z","dependency_job_id":null,"html_url":"https://github.com/PabRod/Potential","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/PabRod/Potential","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PabRod%2FPotential","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PabRod%2FPotential/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PabRod%2FPotential/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PabRod%2FPotential/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PabRod","download_url":"https://codeload.github.com/PabRod/Potential/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PabRod%2FPotential/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281870557,"owners_count":26576245,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-30T02:00:06.501Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["analysis","calculus","mathematics","mechanics","physics"],"created_at":"2025-08-10T10:38:30.264Z","updated_at":"2025-10-30T19:39:25.121Z","avatar_url":"https://github.com/PabRod.png","language":"Matlab","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Potential\nA couple of functions for computing path integrals and scalar potentials in an arbitrary number of dimensions.\n\nRequires Matlab R2012a or newer.\n\n## Background\nThe main purpose of this piece of code is computing the scalar potential function associated to a given vector field. In order to do so, we'll introduce the tool of path integral.\n\n### Path integrals\nA path integral, also known as line or curve integral, is an integral where the integrand is evaluated along a curve:\n\n![GeneralPathIntegral](https://github.com/PabRod/Potential/blob/master/figs/path_general.png \"General path integral\")\n\nThe usual way of evaluating a path integral requires the specification of a parameterization of the curve:\n\n![GeneralParametric](https://github.com/PabRod/Potential/blob/master/figs/parameter_curve.png \"General parametric curve\")\n\nSo our path integral becomes the classical integral:\n\n![PathIntegralEvaluation](https://github.com/PabRod/Potential/blob/master/figs/path_parametric.png \"Path integral evaluation\")\n\n### Gradient fields\nA gradient field is a vector field that can be derived as the gradient of a scalar field. For historical reasons, a minus sign is introduced\n\n![GradientField](https://github.com/PabRod/Potential/blob/master/figs/gradient_field.png \"Gradient field\")\n\nPath integrals over gradient fields depend only on the beginning and finishing points of the integration, being independent of the particular curve chosen to integrate between them. So, provided f is a gradient field, we can make non-ambiguous sense of an expression like:\n\n![PathOverGradient](https://github.com/PabRod/Potential/blob/master/figs/path_gradient.png \"Path integral over a gradient field\")\n\nOne straightforward consequence of this is that any path integral over a gradient field and along a closed curve (which starts and ends at the same point) should equal zero.\n\n![PathOverClosedPath](https://github.com/PabRod/Potential/blob/master/figs/closed_path.png \"Path integral over a gradient field and a closed path\")\n\n### Scalar potentials\n\nProvided a gradient field, we can compute the associated scalar potential using:\n\n![Potential](https://github.com/PabRod/Potential/blob/master/figs/general_potential.png \"Computation of a scalar potential\")\n\nWhere the value of the potential at x_0 is an arbitrary integration constant.\n\n## Examples of usage\n### Path integral along a parametric curve\n```[Matlab]\n% Underlying field\nfield = @(x) [-x(2), -x(1)];\n\n% Parametric curve specification\ncurve = @(t) [t, t];\ndcurve = @(t) [1, 1];\ntmin = -2;\ntmax = 1;\n\n% Path integral\ns = PathIntegral(field, curve, dcurve, tmin, tmax);\n```\n### Path integral over a gradient field\nIn the case of gradient fields the integral only depends in the initial and final points of the integration path. Thus, we can specify only those points regardless of the integration curve\n```[Matlab]\n% Underlying field\nfield = @(x) [-2.*x(1).*x(2), -x(1).^2];\n\n% Initial and final points\nx0 = [1 2];\nx = [3 4];\n\n% Path integral\ns = PathIntegral(field, x0, x);\n```\n\n### Path integral using symbolic functions\nFor those used to work with the symbolic toolbox of Matlab\n```[Matlab]\n% Define symbolic variables\nsyms x y t;\n\n% Underlying field\nfield(x,y) [-y, -x];\n\n% Parametric curve specification\ncurve(t) = [t, t];\ntmin = -2;\ntmax = 1;\n\n% Path integral\ns = PathIntegral(field, curve, tmin, tmax);\n```\n\n### One-dimensional potential\nGiven a gradient field, we can compute the associated potential\n```[Matlab]\n% Underlying field\nfield = @(x) -4*x.^3 + 3*x.^2 + 10*x - 1;\n\n% Grid characteristics\nx = -2:0.05:3;\n\n% Setting the reference potential\nx0 = -2;\nV0 = 0;\n\n% Compute the potential\nV = Potential(field, V0, x0, x);\n\n% Plot results\nplot(x, V);\n```\n\n![Potential1D](https://github.com/PabRod/Potential/blob/master/figs/potential_1D.png \"Computation of a scalar potential\")\n\n### Two-dimensional potential\n```[Matlab]\n% Underlying field\nfield = @(x) [ -x(1).^3 + x(1), -x(2).^3 + x(2)];\n\n% Grid characteristics\nx = -1.5:0.1:1.5;\ny = -1.5:0.1:1.5;\n[xm, ym] = meshgrid(x,y);\n\n% Setting the reference potential\nx0 = zeros(1, 2);\nV0 = 0;\n\n% Compute the potential\nV = Potential(field, V0, x0, xm, ym);\n\n% Plot results\nfigure; surf(xm, ym, V);\n```\n\n![Potential2D](https://github.com/PabRod/Potential/blob/master/figs/potential_2D.png \"Computation of a scalar potential\")\n\nBy [Pablo Rodríguez-Sánchez](https://sites.google.com/site/pablorodriguezsanchez/ \"Contact\"), March 2017.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpabrod%2Fpotential","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpabrod%2Fpotential","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpabrod%2Fpotential/lists"}