Home > Software engineering >  Finding square roots in surd form
Finding square roots in surd form

Time:06-23

I'm trying to build a program that let's you multiply two square roots and display the answer in surd form if the answer isn't an integer.

I've seen answers here and here, although I don't understand C and C#, so I don't have a clue on what to do. The first thing I've done is multiply the two numbers inside the square roots together, then I can display the answer if it is an integer, but if it isn't it completely messes up.

CodePudding user response:

I don't see a better way than by factoring the given numbers, summing the multiplicities of the prime factors, extracting the even parts of the multiplicities and forming the square root of the products.

E.g.

√(84.375)=√(2²3.7.3.5³)=√(2²3²5³7)=2.3.5√(5.7)=30√35

CodePudding user response:

Try using SymPy:

>>>import sympy
>>>sympy.sqrt(8)
2*sqrt(2)
  • Related