# Univariate equivalent implementation in Python

Hi!
I’m trying to implement the findLatitudeCrossing function from Pahsing.java into a python function.

throws MathRuntimeException {

``````    // function evaluating to 0 at latitude crossings
final UnivariateFunction latitudeFunction = new UnivariateFunction() {
/** {@inheritDoc} */
public double value(final double x) {
try {
final SpacecraftState state = propagator.propagate(guessDate.shiftedBy(x));
final Vector3D position = state.getPVCoordinates(earth.getBodyFrame()).getPosition();
final GeodeticPoint point = earth.transform(position, earth.getBodyFrame(), state.getDate());
return point.getLatitude() - latitude;
} catch (OrekitException oe) {
throw new RuntimeException(oe);
}
}
};

// try to bracket the encounter
double span;
if (guessDate.shiftedBy(shift).compareTo(endDate) > 0) {
// Take a 1e-3 security margin
span = endDate.durationFrom(guessDate) - 1e-3;
} else {
span = shift;
}

while (!UnivariateSolverUtils.isBracketing(latitudeFunction, -span, span)) {

if (2 * span > maxShift) {
// let the Hipparchus exception be thrown
UnivariateSolverUtils.verifyBracketing(latitudeFunction, -span, span);
} else if (guessDate.shiftedBy(2 * span).compareTo(endDate) > 0) {
// Out of range :
return null;
}

// expand the search interval
span *= 2;

}

// find the encounter in the bracketed interval
final BaseUnivariateSolver<UnivariateFunction> solver =
new BracketingNthOrderBrentSolver(0.1, 5);
final double dt = solver.solve(1000, latitudeFunction, -span, span);
return propagator.propagate(guessDate.shiftedBy(dt));
``````

Could you guide me on how to implement this in Python? Should I keep the UnvariateFunction approach or use another library in python?
Thank you