# Checks

If you have computed a gradient or differential and you are not sure, whether it is correct.

Manopt.check_differentialFunction
check_differential(M, F, dF, p=random_point(M), X=random_tangent(M,p))

Check numerivcally whether the differential dF(M,p,X) of F(M,p) is correct.

This implements the method described in Section 4.8 [Boumal2022].

Keyword arguments

• N (101) – number of points to check within the log_range default range $[10^{-8},10^{0}]$
• throw_error - (false) throw an error message if the gradient is wrong
• io – (nothing) provide an IO to print the check result to
• limits ((1e-8,1)) specify the limits in the log_range
• log_range (range(limits, limits; length=N)) - specify the range of points (in log scale) to sample the gradient line
• plot- (false) whether to plot the resulting check (if Plots.jl is loaded). The plot is in log-log-scale.
• retraction_method - (default_retraction_method(M)) retraction method to use for the check
• slope_tol – (0.1) tolerance for the slope (global) of the approximation
source
Manopt.find_best_slope_windowFunction
(a,b,i,j) = find_best_slope_window(X,Y,window=nothing; slope=2.0, slope_tol=0.1)

Check data X,Y for the largest contiguous interval (window) with a regression line fitting “best”. Among all intervals with a slope within slope_tol to slope the longest one is taken. If no such interval exists, the one with the slope closest to slope is taken.

If the window is set to nothing (default), all window sizes 2,...,length(X) are checked. You can also specify a window size or an array of window sizes.

For each window size , all its translates in the data are checked. For all these (shifted) windows the regression line is computed (i.e. a,b in a + t*b) and the best line is computed.

From the best line the following data is returned

• a, b specifying the regression line a + t*b
• i, j determining the window, i.e the regression line stems from data X[i], ..., X[j]
source

## Internal methods

Manopt.plot_slopeMethod

plotslope(x, y; slope=2, linebase=0, a=0, b=2.0, i=1,j=length(x))

plot the result from the check_gradient on data x,y with two comparison lines

1. line_base+ tslope as the goal the plot should have
2. a+ bton the interval [x[i],x[j]`] for some (best fitting) comparison slope
source