import matplotlib
if not hasattr(matplotlib.RcParams, "_get"):
matplotlib.RcParams._get = dict.get
Opgave 3#
Gegeven is de volgende constructie:
Fig. 225 #
Vind de rotatie op in \(x=0\).
Opgave
Maak de opdracht in WebLab. Heb je nog geen toegang? Schrijf je dan eerst hier in voor dit vak op WebLab.
Je kan je antwoord op de vragen in de volgende opgaves invoeren. Maar om je code te checken klik je op ‘Check’ in WebLab.
Opgave
Wat is het rotatie in \(\rm{A} \) in \(\rm{rad}\)?
Uitwerking
import sympy as sym
sym.init_printing(use_latex='mathjax')
import numpy as np
import matplotlib.pyplot as plt
from IPython.display import display as ipy_display, Math
%config InlineBackend.figure_formats = ['svg']
def display(*objs):
for obj in objs:
if isinstance(obj, dict):
lines = [f"{sym.latex(k)} &= {sym.latex(obj[k])}" for k in sorted(obj, key=lambda s: str(s))]
ipy_display(Math(r"\begin{aligned}" + r"\\ ".join(lines) + r"\end{aligned}"))
else:
ipy_display(obj)
def plot(w_list, x_range_list,ylabel):
fig = plt.figure(facecolor='none')
for i, w in enumerate(w_list):
# check if x is the only symbol in the expression
if len(w.free_symbols) > 1:
raise ValueError('The expression must be a function of x only.')
w_numpy = sym.lambdify(x, w)
x_vals = np.linspace(x_range_list[i][0], x_range_list[i][1], 100)
# if the expression is a constant, we need to make sure that it is broadcasted correctly
if isinstance(w_numpy(x_vals),float) or isinstance(w_numpy(x_vals),int):
w_numpy = np.vectorize(w_numpy)
plt.plot(x_vals,w_numpy(x_vals))
plt.xlabel('$x$')
plt.ylabel(ylabel)
ax = plt.gca()
ax.set_facecolor('none')
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
ax.spines['bottom'].set_position('zero')
ax.spines['left'].set_position('zero')
ax.invert_yaxis()
import sympy as sym
sym.var('x')
sym.var('C1, C2, C3, C4');
q1 = x * -12
V1 = sym.integrate(-q1,x)+C1
M1 = sym.integrate(V1,x)+C2
kappa1 = M1 / 6400
phi1 = sym.integrate(kappa1,x)+C3
w1 = sym.integrate(-phi1,x)+C4
Eq1 = sym.Eq( w1.subs(x, 0), 0)
Eq2 = sym.Eq( M1.subs(x, 0), 0)
Eq3 = sym.Eq( w1.subs(x, 8), 0)
Eq4 = sym.Eq(phi1.subs(x, 8), 0)
sol = sym.solve((Eq1, Eq2, Eq3, Eq4), (C1, C2, C3, C4))
display(sol)
\[\begin{split}\displaystyle \begin{aligned}C_{1} &= - \frac{384}{5}\\ C_{2} &= 0\\ C_{3} &= \frac{8}{125}\\ C_{4} &= 0\end{aligned}\end{split}\]
w1_oplossing = w1.subs(sol)
phi1_oplossing = phi1.subs(sol)
plot([w1_oplossing], [(0, 8)], 'w(x)')
plot([phi1_oplossing], [(0, 8)], 'phi(x)')
phi_0 = phi1_oplossing.subs(x, 0) # rad
display(phi_0)
display(phi_0.evalf())
\[\displaystyle \frac{8}{125}\]
\[\displaystyle 0.064\]