# Potential from an exact differential form I there any way to calculate the Potential from an exact differential form i.e. given $\omega$ exact, I want to calculate f such that $\omega = \mathrm{d} f$

The same for a conservative vector field.

Daniel

edit retag close merge delete

Please give a concrete example (= Sage code sample) of such omega.

An example would be:

$[\mathit{\ensuremath{\omega}}=\left( {{\%{}e}^{z}}+2yz+xy\right) \,\mathit{dz}+\left( {{z}^{2}}+xz+x\,{{\%{}e}^{y}}+{{y}^{3}}\right) \,\mathit{dy}+\left( yz+{{\%{}e}^{y}}+{{x}^{2}}\right) \,\mathit{dx}]$

which is exact

the text is not rendered correctly, here is again:

$[\mathit{\omega}=\left( {{e}^{z}}+2yz+xy\right) \,\mathit{dz}+\left( {{z}^{2}}+xz+x\,{{\%{}e}^{y}}+{{y}^{3}}\right) \,\mathit{dy}+\left( yz+{{\%{}e}^{y}}+{{x}^{2}}\right) \,\mathit{dx}]$

Which is exact

Daniel

and again:

$\mathit{\omega}=\left( {{e}^{z}}+2yz+xy\right) \,\mathit{dz}+\left( {{z}^{2}}+xz+x\,{{e}^{y}}+{{y}^{3}}\right) \,\mathit{dy}+\left( yz+{{e}^{y}}+{{x}^{2}}\right) \,\mathit{dx}$

Daniel

Sort by » oldest newest most voted

Here is the answer of @dan_fulea adapted to the manifold version of differential forms:

sage: U = Manifold(3, 'U')
sage: X.<x,y,z> = U.chart()
sage: f = U.diff_form(1)   # a shortcut is f = U.one_form()
sage: f[:] = (y*z + exp(y) + x^2,
....:         z^2 + x*z + x*exp(y) + y^3,
....:         exp(z) +2*y*z + x*y)
sage: f.display()
(x^2 + y*z + e^y) dx + (y^3 + x*z + z^2 + x*e^y) dy + (x*y + 2*y*z + e^z) dz
sage: f.exterior_derivative()
2-form on the 3-dimensional differentiable manifold U
sage: f.exterior_derivative() == 0  # checking that f is exact
True
sage: g = f
sage: G0 = U.scalar_field(integral(g.expr(), X))
sage: g = g - G0.differential()
sage: G1 = U.scalar_field(integral(g.expr(), X))
sage: g = g - G1.differential()
sage: G2 = U.scalar_field(integral(g.expr(), X))
sage: G = G0 + G1 + G2
sage: G.display()
U --> R
(x, y, z) |--> 1/4*y^4 + 1/3*x^3 + x*y*z + y*z^2 + x*e^y + e^z
sage: dG = G.differential(); dG
1-form on the 3-dimensional differentiable manifold U
sage: dG.display()
(x^2 + y*z + e^y) dx + (y^3 + x*z + z^2 + x*e^y) dy + (x*y + 2*y*z + e^z) dz
sage: dG == f
True


Note that you may equivalently declare the scalar fields G0, G1 and G2 as differential forms of degree 0, but then you have to set their values in a second stage, by means of the method set_expr. In other words, you can replaceG0 = U.scalar_field(integral(g.expr(), X)) by

sage: G0 = U.diff_form(0)
sage: G0.set_expr(integral(g.expr(), X))

more

This is indeed a better class to place the problem, thanks for answer! It is wonderful in this community,

The problem was "time", so i took the first found (and related) Differential+[TAB]-class i saw in the sage interpreter... It should be also deprecated.

This answer should be found first, +1 from me!

Now that we have the potential, I would like to calculate the work done along a curve in 0<=t<=1.

R1 = Manifold(1, 'R1', start_index=1, latex_name=r'\mathbb{R}')
Y.<t> = R1.chart()
Curve = R1.diff_map(U, [e^(t^3), t^3-t^2+sin(2*pi*t^5), t^2-1])


I have to calculate

G(Curve(1)) - G(Curve(0))


I came up with the following code

A = G.expr()(x=Curve.expr()(t=1),y=Curve.expr()(t=1),z=Curve.expr()(t=1))
B = G.expr()(x=Curve.expr()(t=0),y=Curve.expr()(t=0),z=Curve.expr()(t=0))
A - B


I consider this code brute-force, and extremely cumbersome. Is there a more elegant way?

Thanks,

Daniel

Since i could not find an already implemented method, i had to implement it with bare hands. The following solution is written so that it can be generalized for more or less variables.

Code:

x, y, z = var('x, y, z')
vars = (x,y,z)

U = CoordinatePatch(vars)
A = DifferentialForms(U)
f = DifferentialForm(A, 1)

f, f, f = ( y*z + exp(y) + x^2
, z^2 + x*z + x*exp(y) + y^3
, exp(z) +2*y*z + x*y )

print "f  = %s" % f
print "df = %s" % f.diff()
print "Is f exact? %s" % f.diff().is_zero()

g  = f
G0 = DifferentialForm( A, 0, integral( g, vars ) )
g  = g - G0.derivative()
G1 = DifferentialForm( A, 0, integral( g, vars ) )
g  = g - G1.derivative()
G2 = DifferentialForm( A, 0, integral( g, vars ) )

G  = G0 + G1 + G2
print "G  = %s" % G
print "dG = %s" % G.diff()
print "Is dG == f? %s" % bool( G.diff() == f )


This gives:

f  = (x*y + 2*y*z + e^z)*dz + (x^2 + y*z + e^y)*dx + (y^3 + x*z + z^2 + x*e^y)*dy
df = 0
Is f exact? True
G  = (1/4*y^4 + 1/3*x^3 + x*y*z + y*z^2 + x*e^y + e^z)
dG = (x*y + 2*y*z + e^z)*dz + (x^2 + y*z + e^y)*dx + (y^3 + x*z + z^2 + x*e^y)*dy
Is dG == f? True


So G is a valid potential for the given $1$-form f.

more

Except that eric_g recommended, in my question to this site "Differential forms best package", using the manifold package and not the CoordinatePatch package with a thorough explanation. He even opened a request to deprecate the CoordinatePatch package.

Daniel

Indeed, I recommend to use the manifold version of differential forms, see the ticket #24444, which is now ready for review.