# Revision history [back]

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.