Parker Emmerson
Parker Emmerson

Reputation: 11

Solution to v - discrepencies between sympy and mathematica

I wrote a program:

import sympy as sp

# Define symbols
l, alpha, x, gamma, r, theta, beta, v = sp.symbols('l alpha x gamma r theta beta v')
c = 2.99792458 * 10**8

# Define the equation
lhs = l * sp.sin(beta)
rhs = sp.sqrt((l * alpha + x * gamma - r * theta) * sp.sqrt(1 - v**2 / c**2)) * \
      sp.sqrt((l * alpha - x * gamma + r * theta) / sp.sqrt(1 - v**2 / c**2)) / alpha

equation = sp.Eq(lhs, rhs)

# Solve the equation for v
solution = sp.solve(equation, v)

# Print the solution
print("Solutions for v:")
for sol in solution:
    print(sol)

It does not print any solutions to ( v ), whereas Mathematica does indicate that there are solutions to ( v ):

v -> (\[Sqrt](-8.98755*10^16 l^2 \[Alpha]^2 + 8.98755*10^16 x^2 \[Gamma]^2 - 1.79751*10^17 r x \[Gamma] \[Theta] + 8.98755*10^16 r^2 \[Theta]^2 + 
8.98755*10^16 l^2 \[Alpha]^2 Sin[\[Beta]]^2))/(Sqrt[-1. l^2 \[Alpha]^2 + x^2 \[Gamma]^2 - 2.r x \[Gamma] \[Theta] + r^2 \[Theta]^2 + l^2 \[Alpha]^2 Sin[\[Beta]]^2])

Should Mathematica be corrected, or should we update the SymPy library to account for this? The program runs well, but it does not output the same solution that Mathematica does.

Upvotes: 1

Views: 62

Answers (0)

Related Questions