t, x = var('t, x')
a = 1; b = 3
dt = (b-a)/20; dt = RDF(dt)
@interact
def arclengthfunc(f = input_box(default = x^2 - (1/8)*log(x), label = 'f', type = SR), xpoint = slider(a,b,dt,default=a)):
pretty_print(html('$f(x) = %s$'%latex(f)))
func = f.subs(x=t)
dydt = diff(func,t)
dsdt = sqrt(1+dydt^2); dsdt.simplify_full()
assume(x>a)
s = integral(dsdt,t,a,x)
pretty_print(html('$s(x) = %s$'%latex(s)))
L = s(x=xpoint); L=RDF(L)
pretty_print(html('$s(%s) = %s$'%(xpoint,L)))
p = plot(func,(t,0,1))+plot(func,(t,1,3), color='red', aspect_ratio=1)
p+= point((1,1), color='red', size=30) + point((xpoint,func(t=xpoint)), color='red', size=30)
p.show()
|
Click to the left again to hide and once more to show the dynamic interactive window
|