3.2 Inhomogene vergelijkingen#

3.2.1 \(f(x) = ax^2 + bx + c \)#

3.2.2 \(f(x) = ae^{bx}\)#

3.2.3 \(f(x) = a\sin(x) + b\cos(x)\)#

3.2.4 Combinaties#

Hide code cell outputs
Requirement already satisfied: plotly in /home/runner/work/Boek/Boek/.venv/lib/python3.11/site-packages (6.0.0)
Requirement already satisfied: narwhals>=1.15.1 in /home/runner/work/Boek/Boek/.venv/lib/python3.11/site-packages (from plotly) (1.29.0)
Requirement already satisfied: packaging in /home/runner/work/Boek/Boek/.venv/lib/python3.11/site-packages (from plotly) (24.2)
[notice] A new release of pip is available: 24.0 -> 25.0.1
[notice] To update, run: pip install --upgrade pip
Note: you may need to restart the kernel to use updated packages.
Hide code cell source
import numpy as np
from scipy.integrate import odeint

import plotly.figure_factory as ff
import plotly.graph_objs as go
import plotly.io as pio
pio.renderers.default = 'notebook'

def dy_dx(y,x):
  return (-5/2)*y

y0 = 2

def odeint_oplossing(ode_func, y0, t):
  y = odeint(ode_func, y0, t)
  return y

x_current = np.linspace(0,10,100)
y_an = odeint_oplossing(dy_dx, y0, x_current)

y_an2=y_an.reshape(-1)

# Generate a grid of x,y values
x = np.linspace(-6, 6, 60)
y = np.linspace(-6, 6, 60)

X, Y = np.meshgrid(x, y)
U = 1  # Constant unit vector for slope field
V = dy_dx(Y, X)

# Normalize the arrow length
N = np.sqrt(U**2 + V**2)
U = U / N
V = V / N

fig = ff.create_quiver(X, Y, U, V, scale=0.15, arrow_scale=.4)

fig.add_trace(go.Scatter(
                    x=x_current,
                    y=y_an2,
                    mode='lines',
                    )
)

fig.update_layout(height=800,
                  width=800,
                  yaxis_range=[-3,3],
                  yaxis_title='y-as',
                  xaxis_range=[-3,3],
                  xaxis_title='x-as',
                  title = 'Richtingsveld'
)
fig
Hide code cell output
../_images/ca15086201a636e1fdedd6f345f019854ed59460be0b338801870e9f64b15c41.png