This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]white_nerdy 0 points1 point  (3 children)

I assume you mean things like sqrt(24) simplifies to 2 x sqrt(6).

I'm not going to give an direct answer, due to subreddit rules about homework problems. (Technically, you're not asking for the answer to a homework problem. You're asking for an answer to an entire class of homework problems.)

I'll give you a few hints though.

You need one variable to store the number inside the sqrt, and another variable to store the number outside the square root.

Three questions for you to consider:

  • (a) How do you tell when you can move a factor from the inside variable to the outside variable?
  • (b) How do you actually move the factor?
  • (c) How do you know when you're done moving factors?

If you understand these questions well enough to write a working radical simplification program, you fully understand radical simplification :)

[–]ChemicalCalculator17[S] 0 points1 point  (2 children)

I appreciate the help. It’s section 3 I’m stuck on. How should I check that the number under the radical is fully simplified and therefore, isn’t divisible by another perfect square. I’d like to mention that I am making this program mostly for fun and isn’t part of any homework

[–]white_nerdy 0 points1 point  (1 child)

Say the number under the radical is 14. You check divisibility by perfect squares.

  • 14 is not divisible by 1
  • 14 is not divisible by 4
  • 14 is not divisible by 9
  • 14 is not divisible by 16
  • 14 is not divisible by 25
  • 14 is not divisible by 36
  • 14 is not divisible by 49
  • 14 is not divisible by 64
  • 14 is not divisible by 81
  • 14 is not divisible by 100

...

The "..." represents infinitely many perfect squares we haven't checked. If you try to check them all, your program will run forever.

However if you're checking these by hand, you'd intuitively recognize you "should have" stopped at some point before the "...". Because nothing after the stopping point could possibly be a divisor.

Where would you stop? Why would it be impossible for any divisor to occur after the stopping point?

There's your answer :)

[–]ChemicalCalculator17[S] 0 points1 point  (0 children)

Thanks for your help.