Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168699
Image: ubuntu2004
var('a b c d e f v_1 v_2 Delta_v s r x')
(a, b, c, d, e, f, v_1, v_2, Delta_v, s, r, x)
v_1 = vector([a, b]) * x v_2 = vector([c, d]) Delta_v = v_2 - v_1 s = vector([e, f])
discriminant = Delta_v.dot_product(s)^2 - Delta_v.dot_product(Delta_v) * (s.dot_product(s) - r^2)
solve(discriminant < 0, x)[0][0].lhs().collect(x)
c^2*f^2 - c^2*r^2 - 2*c*d*e*f + d^2*e^2 - d^2*r^2 + (a^2*f^2 - a^2*r^2 - 2*a*b*e*f + b^2*e^2 - b^2*r^2)*x^2 - 2*(a*c*f^2 - a*c*r^2 - a*d*e*f - b*c*e*f + b*d*e^2 - b*d*r^2)*x
solve(discriminant == 0, x)
[x == (a*c*f^2 + b*d*e^2 - (a*d + b*c)*e*f - (a*c + b*d)*r^2 - (a*d - b*c)*sqrt(e^2 + f^2 - r^2)*r)/(a^2*f^2 - 2*a*b*e*f + b^2*e^2 - (a^2 + b^2)*r^2)]
sgn(diff(discriminant, x))
sgn(2*(a*e + b*f)*((b*x - d)*f + (a*x - c)*e) - 2*((b*x - d)*b + (a*x - c)*a)*(e^2 + f^2 - r^2))
var('theta')
theta
assume(-pi/2 < theta < pi/2) rot = Matrix([[cos(theta), -sin(theta)], [sin(theta), cos(theta)]]) v_1 = vector([a, b]) * rot Delta_v = v_2 - v_1 discriminant = Delta_v.dot_product(s)^2 - Delta_v.dot_product(Delta_v) * (s.dot_product(s) - r^2)
discriminant == 0
((a*cos(theta) + b*sin(theta) - c)*e - (a*sin(theta) - b*cos(theta) + d)*f)^2 - ((a*cos(theta) + b*sin(theta) - c)^2 + (a*sin(theta) - b*cos(theta) + d)^2)*(e^2 + f^2 - r^2) == 0
solve(discriminant < 0, theta)[0][0].lhs().collect(sin(theta)).collect(cos(theta))
c^2*f^2 - c^2*r^2 - 2*c*d*e*f + d^2*e^2 - d^2*r^2 + (a^2*f^2 - a^2*r^2 - 2*a*b*e*f + b^2*e^2 - b^2*r^2)*cos(theta)^2 + (a^2*e^2 - a^2*r^2 + 2*a*b*e*f + b^2*f^2 - b^2*r^2)*sin(theta)^2 - 2*(a*c*e*f - a*d*e^2 + a*d*r^2 + b*c*f^2 - b*c*r^2 - b*d*e*f)*sin(theta) - 2*(a*c*f^2 - a*c*r^2 - a*d*e*f - b*c*e*f + b*d*e^2 - b*d*r^2 - (a^2*e*f - a*b*e^2 + a*b*f^2 - b^2*e*f)*sin(theta))*cos(theta)
solve(discriminant == 0, theta)
[sin(theta) == -(a*d*e^2 - b*c*f^2 - (a*d - b*c)*r^2 - (a*c - b*d)*e*f - (a*b*e^2 - a*b*f^2 - (a^2 - b^2)*e*f)*cos(theta) + ((a^2 + b^2)*r*cos(theta) - (a*c + b*d)*r)*sqrt(e^2 + f^2 - r^2))/(a^2*e^2 + 2*a*b*e*f + b^2*f^2 - (a^2 + b^2)*r^2), sin(theta) == -(a*d*e^2 - b*c*f^2 - (a*d - b*c)*r^2 - (a*c - b*d)*e*f - (a*b*e^2 - a*b*f^2 - (a^2 - b^2)*e*f)*cos(theta) - ((a^2 + b^2)*r*cos(theta) - (a*c + b*d)*r)*sqrt(e^2 + f^2 - r^2))/(a^2*e^2 + 2*a*b*e*f + b^2*f^2 - (a^2 + b^2)*r^2)]
diff(discriminant, theta)
-2*((a*cos(theta) + b*sin(theta) - c)*e - (a*sin(theta) - b*cos(theta) + d)*f)*((a*cos(theta) + b*sin(theta))*f + (a*sin(theta) - b*cos(theta))*e) - 2*((a*cos(theta) + b*sin(theta))*(a*sin(theta) - b*cos(theta) + d) - (a*sin(theta) - b*cos(theta))*(a*cos(theta) + b*sin(theta) - c))*(e^2 + f^2 - r^2)
diff(diff(discriminant, theta), theta)
-2*((a*cos(theta) + b*sin(theta) - c)*e - (a*sin(theta) - b*cos(theta) + d)*f)*((a*cos(theta) + b*sin(theta))*e - (a*sin(theta) - b*cos(theta))*f) + 2*((a*cos(theta) + b*sin(theta))*f + (a*sin(theta) - b*cos(theta))*e)^2 - 2*(e^2 + f^2 - r^2)*((a*cos(theta) + b*sin(theta))^2 - (a*cos(theta) + b*sin(theta))*(a*cos(theta) + b*sin(theta) - c) + (a*sin(theta) - b*cos(theta))^2 - (a*sin(theta) - b*cos(theta))*(a*sin(theta) - b*cos(theta) + d))
solve(discriminant == 0, cos(theta))
[cos(theta) == (a*c*f^2 + b*d*e^2 - (a*d + b*c)*e*f - (a*c + b*d)*r^2 + (a*b*e^2 - a*b*f^2 - (a^2 - b^2)*e*f)*sin(theta) - ((a^2 + b^2)*r*sin(theta) + (a*d - b*c)*r)*sqrt(e^2 + f^2 - r^2))/(a^2*f^2 - 2*a*b*e*f + b^2*e^2 - (a^2 + b^2)*r^2), cos(theta) == (a*c*f^2 + b*d*e^2 - (a*d + b*c)*e*f - (a*c + b*d)*r^2 + (a*b*e^2 - a*b*f^2 - (a^2 - b^2)*e*f)*sin(theta) + ((a^2 + b^2)*r*sin(theta) + (a*d - b*c)*r)*sqrt(e^2 + f^2 - r^2))/(a^2*f^2 - 2*a*b*e*f + b^2*e^2 - (a^2 + b^2)*r^2)]
solve(discriminant == 0, cos(theta))[0].subs(solve(discriminant == 0, sin(theta))[0])
cos(theta) == (a*c*f^2 + b*d*e^2 - (a*d + b*c)*e*f - (a*c + b*d)*r^2 - ((a*d - b*c)*r - (a^2 + b^2)*(a*d*e^2 - b*c*f^2 - (a*d - b*c)*r^2 - (a*c - b*d)*e*f - (a*b*e^2 - a*b*f^2 - (a^2 - b^2)*e*f)*cos(theta) + ((a^2 + b^2)*r*cos(theta) - (a*c + b*d)*r)*sqrt(e^2 + f^2 - r^2))*r/(a^2*e^2 + 2*a*b*e*f + b^2*f^2 - (a^2 + b^2)*r^2))*sqrt(e^2 + f^2 - r^2) - (a*b*e^2 - a*b*f^2 - (a^2 - b^2)*e*f)*(a*d*e^2 - b*c*f^2 - (a*d - b*c)*r^2 - (a*c - b*d)*e*f - (a*b*e^2 - a*b*f^2 - (a^2 - b^2)*e*f)*cos(theta) + ((a^2 + b^2)*r*cos(theta) - (a*c + b*d)*r)*sqrt(e^2 + f^2 - r^2))/(a^2*e^2 + 2*a*b*e*f + b^2*f^2 - (a^2 + b^2)*r^2))/(a^2*f^2 - 2*a*b*e*f + b^2*e^2 - (a^2 + b^2)*r^2)
solve(cos(theta) == sin(theta), theta)
[sin(theta) == cos(theta)]