Simplifies a radical into a multiple of the square root of a prime number. Based on the popular SIMPRAD for TI-BASIC of unknown author. Supports negative numbers and arbitrary roots.
When the input is a nonnegative number, the output will be a Tuple of two
real numbersߞthe coefficient and the radicand.
When the input is a negative number, the output will be a Tuple of a complex coefficient and a real radicand.
Use simprad as a module:
from simprad import simprad print(simprad(50)) # (5, 2) print(simprad(36)) # (6, 1) print(simprad(-50)) # (5j, 2) print(simprad(8, 3)) # (2, 1)
Use simprad as a command line utility:
$ python -m simprad Radical to simplify: √50 Root : 2 5 × √2
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.