Right now solver have some issue in solving system of equation having more sqrt
. So in below code first removing the sqrt
and then solving system of equation.Currently solver is not fast for these types of equations ,it is taking around 10 sec to execute.
P, Q, S, T, = symbols('P Q S T')
c, y_0, y_c, dy_0, dy_c = symbols('c y_0 y_c dy_0 dy_c')
eq_y = (P*x + Q - y(x))**2 + S*x + T
eq_dy = eq_y.diff(x)
equations = [
(eq_y).subs([(x, 0), (y(0), y_0), (y(x).diff(x).subs(x, 0), dy_0)]),
(eq_dy).subs([(x, 0), (y(0), y_0), (y(x).diff(x).subs(x, 0), dy_0)]),
(eq_y).subs([(x, c), (y(c), y_c), (y(x).diff(x).subs(x, c), dy_c)]),
(eq_dy).subs([(x, c), (y(c), y_c), (y(x).diff(x).subs(x, c), dy_c)])
]
solve(equations, P, Q, S, T)
Answer :
[(-(y_0 - y_c)/c, y_0, 0, 0), ((2*c*dy_0*dy_c + dy_0*y_0 - dy_0*y_c + dy_c*y_0 - dy_c*y_c)/(c*dy_0 + c*dy_c + 2*y_0 - 2*y_c), -(2*c**3*dy_0*dy_c**2 - c**2*dy_0**2*y_0 + 2*c**2*dy_0*dy_c*y_0 - 4*c**2*dy_0*dy_c*y_c + c**2*dy_c**2*y_0 - 2*c**2*dy_c**2*y_c - 2*c*dy_0*y_0**2 + 2*c*dy_0*y_c**2 - 4*c*dy_c*y_0*y_c + 4*c*dy_c*y_c**2 - 2*y_0**3 + 2*y_0**2*y_c + 2*y_0*y_c**2 - 2*y_c**3)/(c*dy_0 + c*dy_c + 2*y_0 - 2*y_c)**2, -4*(dy_0 - dy_c)*(c*dy_0 + y_0 - y_c)**2*(c*dy_c + y_0 - y_c)**2/(c*dy_0 + c*dy_c + 2*y_0 - 2*y_c)**3, -4*(c*dy_0 + y_0 - y_c)**2*(c*dy_c + y_0 - y_c)**4/(c*dy_0 + c*dy_c + 2*y_0 - 2*y_c)**4)]
please cross check the answer.