# Set left endpoint
# Essentially, this is translating X = x - a, Y = y - y_a
a = 0
y_a = 0
@interact
def Brachistochrone(b = slider(0, 10, 0.1, 1), y_b = slider(-10, 0, 0.1, -1)):
# Find t value at left endpoint
t_b = find_root((b - a) * (1 - cos(t)) + (y_b - y_a) * (t - sin(t)), 0.001, 2 * pi)
# Find C value
S = solve(x(t_b, a = a) == b, C, solution_dict = True)
CVal = S[0][C]
show('$t_b = %g, \quad C = %g$' % (t_b, CVal))
p1 = plot((x(t, a = a, C = CVal), y(t, y_a = y_a, C = CVal)), (t, 0, t_b), parametric = True)
p2 = points([[a, y_a], [b, y_b]], color = 'red', size = 30)
show(p1 + p2, axes_labels = ['$x$', '$y$'])
|
Click to the left again to hide and once more to show the dynamic interactive window
|