def line_integrate(field, curve, vars):
 from sympy.geometry import Curve
 F = sympify(field)
 if (not F):
  raise ValueError('Expecting function specifying field as first argument.')
 if (not isinstance(curve, Curve)):
  raise ValueError('Expecting Curve entity as second argument.')
 if (not is_sequence(vars)):
  raise ValueError('Expecting ordered iterable for variables.')
 if (len(curve.functions) != len(vars)):
  raise ValueError('Field variable size does not match curve dimension.')
 if (curve.parameter in vars):
  raise ValueError('Curve parameter clashes with field parameters.')
 Ft = F
 dldt = 0
 for (i, var) in enumerate(vars):
  _f = curve.functions[i]
  _dn = diff(_f, curve.parameter)
  dldt = (dldt + (_dn * _dn))
  Ft = Ft.subs(var, _f)
 Ft = (Ft * sqrt(dldt))
 integral = Integral(Ft, curve.limits).doit(deep=False)
 return integral

def line_integrate ( field , curve , vars ) : from sympy . geometry import Curve F = sympify ( field ) if ( not F ) : raise ValueError ( 'Expecting function specifying field as first argument.' ) if ( not isinstance ( curve , Curve ) ) : raise ValueError ( 'Expecting Curve entity as second argument.' ) if ( not is_sequence ( vars ) ) : raise ValueError ( 'Expecting ordered iterable for variables.' ) if ( len ( curve . functions ) != len ( vars ) ) : raise ValueError ( 'Field variable size does not match curve dimension.' ) if ( curve . parameter in vars ) : raise ValueError ( 'Curve parameter clashes with field parameters.' ) Ft = F dldt = 0 for ( i , var ) in enumerate ( vars ) : _f = curve . functions [ i ] _dn = diff ( _f , curve . parameter ) dldt = ( dldt + ( _dn * _dn ) ) Ft = Ft . subs ( var , _f ) Ft = ( Ft * sqrt ( dldt ) ) integral = Integral ( Ft , curve . limits ) . doit ( deep = False ) return integral
line_integrate compute the line integral .