Loading [MathJax]/jax/output/HTML-CSS/jax.js
Ask Your Question
2

Potential from an exact differential form

asked 7 years ago

danielvolinski gravatar image

updated 7 years ago

eric_g gravatar image

I there any way to calculate the Potential from an exact differential form i.e. given ω exact, I want to calculate f such that ω=df

The same for a conservative vector field.

Daniel

Preview: (hide)

Comments

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

vdelecroix gravatar imagevdelecroix ( 7 years ago )

An example would be:

[\ensuremathω=(%ez+2yz+xy)dz+(z2+xz+x%ey+y3)dy+(yz+%ey+x2)dx]

which is exact

danielvolinski gravatar imagedanielvolinski ( 7 years ago )

the text is not rendered correctly, here is again:

[ω=(ez+2yz+xy)dz+(z2+xz+x%ey+y3)dy+(yz+%ey+x2)dx]

Which is exact

Daniel

danielvolinski gravatar imagedanielvolinski ( 7 years ago )

and again:

ω=(ez+2yz+xy)dz+(z2+xz+xey+y3)dy+(yz+ey+x2)dx

Daniel

danielvolinski gravatar imagedanielvolinski ( 7 years ago )

@danielvolinski you can edit your comments, no need to add new comments to fix typos.

slelievre gravatar imageslelievre ( 6 years ago )

2 Answers

Sort by » oldest newest most voted
4

answered 7 years ago

eric_g gravatar image

updated 7 years ago

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]))
Preview: (hide)
link

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 ( 7 years ago )

Thank you @dan_fulea and @eric_g for your responses.

Daniel

danielvolinski gravatar imagedanielvolinski ( 7 years ago )

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 ( 7 years ago )
2

answered 7 years ago

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.

Preview: (hide)
link

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 ( 7 years ago )

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 ( 7 years ago )

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: 7 years ago

Seen: 773 times

Last updated: Jan 06 '18