Ask Your Question
1

Potential from an exact differential form

asked 2018-01-04 08:10:09 -0500

danielvolinski gravatar image

updated 2018-01-06 07:07:10 -0500

eric_g gravatar image

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 flag offensive close merge delete

Comments

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

vdelecroix gravatar imagevdelecroix ( 2018-01-05 04:56:22 -0500 )edit

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

danielvolinski gravatar imagedanielvolinski ( 2018-01-05 13:32:38 -0500 )edit

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

danielvolinski gravatar imagedanielvolinski ( 2018-01-05 13:34:37 -0500 )edit

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

danielvolinski gravatar imagedanielvolinski ( 2018-01-05 13:35:59 -0500 )edit

2 answers

Sort by ยป oldest newest most voted
0

answered 2018-01-05 20:51:37 -0500

dan_fulea gravatar image

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[0], f[1], f[2] = ( 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[0], vars[0] ) )
g  = g - G0.derivative()
G1 = DifferentialForm( A, 0, integral( g[1], vars[1] ) )
g  = g - G1.derivative()
G2 = DifferentialForm( A, 0, integral( g[2], vars[2] ) )

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.

edit flag offensive delete link more

Comments

Thank you for you answer.

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

danielvolinski gravatar imagedanielvolinski ( 2018-01-06 02:09:06 -0500 )edit

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

eric_g gravatar imageeric_g ( 2018-01-06 04:21:48 -0500 )edit
2

answered 2018-01-06 04:18:15 -0500

eric_g gravatar image

updated 2018-01-06 07:05:14 -0500

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[0].expr(), X[0]))
sage: g = g - G0.differential()
sage: G1 = U.scalar_field(integral(g[1].expr(), X[1]))
sage: g = g - G1.differential()
sage: G2 = U.scalar_field(integral(g[2].expr(), X[2]))
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[0].expr(), X[0])) by

sage: G0 = U.diff_form(0)
sage: G0.set_expr(integral(g[0].expr(), X[0]))
edit flag offensive delete link more

Comments

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!

dan_fulea gravatar imagedan_fulea ( 2018-01-06 08:18:21 -0500 )edit

Thank you @dan_fulea and @eric_g for your responses.

Daniel

danielvolinski gravatar imagedanielvolinski ( 2018-01-06 10:46:27 -0500 )edit

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()[0](t=1),y=Curve.expr()[1](t=1),z=Curve.expr()[2](t=1))
B = G.expr()(x=Curve.expr()[0](t=0),y=Curve.expr()[1](t=0),z=Curve.expr()[2](t=0))
A - B

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

Thanks,

Daniel

danielvolinski gravatar imagedanielvolinski ( 2018-03-10 18:04:56 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-01-04 08:10:09 -0500

Seen: 70 times

Last updated: Jan 06