# Revision history [back]

### Integrating geodesics backwards in time

Is it possible to integrate a geodesic equation backwards in time in sagemath ? I'm using the following code in order to ray trace null geodesics.

    v0 = initial_vector(r0, b,al, ph0=0, inward=False)
geod = M.integrated_geodesic(g, (s, 50, 0), v0, across_charts=True)
sol = geod.solve_across_charts(step=0.1,parameters_values={a:0,q:0},
verbose=True)


Where 's' is my affine parameter.

From what i've understood, solve_across_charts does use scipy.odeint which supports backwards integration but when i try to run it i get the following error :

ValueError Traceback (most recent call last) <ipython-input-58-13e5246d5cee> in <module> 14 geod = M.integrated_geodesic(g, (s, Integer(50), Integer(0)), v0, across_charts=True) 15 sol = geod.solve_across_charts(step=RealNumber('0.1'),parameters_values={a:Integer(0),q:Integer(0)}, ---> 16 verbose=True) 17 18

/opt/sagemath-9.2/local/lib/python3.7/site-packages/sage/manifolds/differentiable/integrated_curve.py in solve_across_charts(self, charts, step, solution_key, parameters_values, verbose, **control_param) 1719 ics = initial_pt_coords + initial_tgt_vec_comps 1720 times = np.linspace(t_min, t_max, int((t_max - t_min) / step) + 1, -> 1721 endpoint=True) 1722 nt = len(times) 1723

<__array_function__ internals> in linspace(args, *kwargs)

/opt/sagemath-9.2/local/lib/python3.7/site-packages/numpy/core/function_base.py in linspace(start, stop, num, endpoint, retstep, dtype, axis) 113 num = operator.index(num) 114 if num < 0: --> 115 raise ValueError("Number of samples, %s, must be non-negative." % num) 116 div = (num - 1) if endpoint else num 117

ValueError: Number of samples, -499, must be non-negative.

Which does make sense. Any workaround ? I've been also trying to set my affine parameter as a negative but this also raises an error.

 2 None slelievre 14559 ●16 ●136 ●287 http://carva.org/samue...

### Integrating geodesics backwards in time

Is it possible to integrate a geodesic equation backwards in time in sagemath ? SageMath? I'm using the following code in order to ray trace null geodesics.geodesics:

 v0 = initial_vector(r0, b,al, b, al, ph0=0, inward=False)
geod = M.integrated_geodesic(g, (s, 50, 0), v0, across_charts=True)
sol = geod.solve_across_charts(step=0.1,parameters_values={a:0,q:0},
geod.solve_across_charts(step=0.1, parameters_values={a: 0, q: 0},
verbose=True)


Where where 's' is my affine parameter.

From what i've understood, solve_across_charts solve_across_charts does use scipy.odeint scipy.odeint which supports backwards integration but when i try to run it it i get the following error :error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-58-13e5246d5cee> in <module>
14         geod = M.integrated_geodesic(g, (s, Integer(50), Integer(0)), v0, across_charts=True)
15         sol = geod.solve_across_charts(step=RealNumber('0.1'),parameters_values={a:Integer(0),q:Integer(0)},
---> 16                                        verbose=True)
17
18   /opt/sagemath-9.2/local/lib/python3.7/site-packages/sage/manifolds/differentiable/integrated_curve.py in solve_across_charts(self, charts, step, solution_key, parameters_values, verbose, **control_param)
1719         ics = initial_pt_coords + initial_tgt_vec_comps
1720         times = np.linspace(t_min, t_max, int((t_max - t_min) / step) + 1,
-> 1721                             endpoint=True)
1722         nt = len(times)
1723   <__array_function__ internals> in linspace(args, *kwargs) linspace(*args, **kwargs)

/opt/sagemath-9.2/local/lib/python3.7/site-packages/numpy/core/function_base.py in linspace(start, stop, num, endpoint, retstep, dtype, axis)
113     num = operator.index(num)
114     if num < 0:
--> 115         raise ValueError("Number of samples, %s, must be non-negative." % num)
116     div = (num - 1) if endpoint else num
117   ValueError: Number of samples, -499, must be non-negative.non-negative.


Which does make sense. Any workaround ? workaround? I've been also trying to set set my affine parameter as a negative but this also raises an error.