human
I am working on the file "ODEs/ODEsEx01.ipynb".
The first task is:
You are now going to solve the following differential equation:
$$
\frac{dy}{dx} = x + 2y
$$
which has the analytical solution:
$$
y(x) = 0.25 e^{2x} - 0.5 x - 0.25
$$
First, write a solve_exact function that compute the exact solution and follows the specification described in the docstring:
Can you write Python program for it?

=====
What is a Python program to compute the exact solution and follows the specification described in the docstring:?
assistant
#Here is Python program to compute the exact solution and follows the specification described in the docstring:
.

def solve_exact(x):
    """compute the exact solution to dy/dx = x + 2y.
    
    Parameters
    ----------
    x : np.ndarray
        Array of x values to compute the solution at.
    
    Returns
    -------
    y : np.ndarray
        Array of solutions at y[i] = y(x[i]).
    """
    def function(point):
        return .25*np.exp(2*point) - .5*point - .25
    y = np.array([function(i) for i in x])
    return y

assert np.allclose(solve_exact(np.array([0,1,2])),np.array([0., 1.09726402, 12.39953751]))