Simplify square roots algebraically

I would like to simplify the square root of the whole algebraically, and not calculate it numerically, i.e. √800 should be 20√2 , not 28.2842712474619 .

I cannot find a way to solve this by programming :(

+6
source share
2 answers

Designate the number under the root, select the factors that come out in pairs, and leave the rest under the root.

√800 = √ (2 x 2 x 2 x 2 x 5 x 2 x 5) = √ (2 2 x 2 2 x 5 2 x 2) = (2 x 2 x 5) √2 = 20√2.

And for completeness, there is a simple code here:

outside_root = 1 inside_root = 800 d = 2 while (d * d <= inside_root): if (inside_root % (d * d) == 0): # inside_root evenly divisible by d * d inside_root = inside_root / (d * d) outside_root = outside_root * d else: d = d + 1 

when the algorithm completes, external_root and inside_root contain the answer.

Here's a run from 800:

  inside outside d 800 1 2 # values at beginning of 'while (...)' 200 2 2 50 4 2 50 4 3 50 4 4 50 4 5 2 20 5 # d*d > 2 so algorithm terminates == == 

The answer 20√2 is here on the last line.

+29
source
 #include<stdio.h> #include<conio.h> int main() { int i, n, n2, last, final; last = 0, final = 1; printf("Enter number to calculate root: "); scanf("%d", & n); n2 = n; for (i = 2; i <= n; ++i) { if (n % i == 0) { if (i == last) { final = final * last; last = 0; } else { last = i; } n /= i; i--; } } n = n2 / (final * final); printf("\nRoot: (%d)^2 * %d", final, n); getch(); return 0; } 
0
source

Source: https://habr.com/ru/post/915157/


All Articles