Sharedfirst_steps / InClass / Tangent and Velocity Problems.sagewsOpen in CoCalc

Create an animation showing the tangent line being approached from left.

@interact
def _(n=slider(int(3),int(20),1,default=int(3),label='The number of the corners $=$')):
n=int(n)
p1=circle((0,0),1,color='black')
corner=[[cos(2*i*pi/n),sin(2*i*pi/n)] for i in range(n)]
p2=polygon2d(corner,fill=False)
show(p1+p2,axes=False)
%md
Create an animation showing the tangent line being approached from right.


Create an animation showing the tangent line being approached from right.


x=var('x')
u=var('u')
w=var('w')
Background=plot(x^2,0,4)
Times=[1+1/t for t in range(20,1,-1)]
for i in range(20): Times.append(2+2*i/20)
Times=Times[::-1]
Films=[plot(((w^2-1)/(w-1))*(u-1)+1,0,4,aspect_ratio=1/4,ymax=16,ymin=-1)+Background for w in Times]
a=animate(Films)
a.show()


Create an animation to show the tangent line of circle

Background=circle((0,0),1)
Angles=[(pi/6+(pi/100)*n,(3*pi)/2-(pi*n)/60) for n in range(50)]
Films=[Background+plot(((sin(Angles[n][0])-sin(Angles[n][1]))/(cos(Angles[n][0])-cos(Angles[n][1])))*(x-cos(Angles[n][0]))+sin(Angles[n][0]),-1.5,1.5,ymax=1.5,ymin=-1.5,aspect_ratio=1)+point([(cos(Angles[n][0]),sin(Angles[n][0])),(cos(Angles[n][1]),sin(Angles[n][1]))],rgbcolor='red',size=20) for n in range(50)]
Films=Films+[Background+plot(-cot(2*pi/3)*(x-cos(2*pi/3))+sin(2*pi/3),-1.5,1.5,ymax=1.5,ymin=-1.5,aspect_ratio=1)+point((cos(2*pi/3),sin(2*pi/3)),rgbcolor='red',size=20)]
a=animate(Films,aspect_ratio=1)
a.show()


Showing the numerical data of the slopes $m_x$ for $x$ approaching $1$ from left.

Showing the numerical data of the slopes $m_x$ for $x$ approaching $1$ from right.

Compute the average speed over a period of time.

@interact
def _(t=range_slider(0,20,default=(0,20),label='Find the average speed on the time interval$=$')):
tt=var('tt')
x= lambda tt: 4.9*tt^2
average_speed=n((x(t[0])-x(t[1]))/(t[0]-t[1]),digits=10)
print('The average speed over the time interval ({},{}) is {}').format(t[0],t[1],average_speed)