Plotting

In order to plot a function, you need both points, and the function values at those points.

xs = linspace(0,1,200)
# if the function f to plot accepts vectors:
ys = f(xs)
# otherwise:
ys = [f(x) for x in xs] # this always works!
 
# plot:
plot(xs,ys)

Testing

You may test that two floats are almost equal using

allclose(x,y)

Examples

Test that two matrices A and B are equal

allclose(A,B)

Test that a matrix Q is orthogonal:

allclose(dot(Q,Q.T),identity(len(Q)))

Test that a matrix R is upper triangular (i.e., that all the elements below the diagonal are zero):

allclose(tril(R,-1),0)
2011-03-18, Olivier Philippe Paul Verdier