# Solver Simplifying Square Roots (whole numbers only)

Algebra ->  Algebra  -> Radicals -> Solver Simplifying Square Roots (whole numbers only)      Log On

 Ad: Algebrator™ solves your algebra problems and provides step-by-step explanations! Ad: Algebra Solved!™: algebra software solves algebra homework problems with step-by-step help!

 Algebra: Radicals -- complicated equations involving roots Solvers Lessons Answers archive Quiz In Depth

### Source code of 'Simplifying Square Roots (whole numbers only)'

This Solver (Simplifying Square Roots (whole numbers only)) was created by by jim_thompson5910(28595)  : View Source, Show, Put on YOUR site
About jim_thompson5910: I charge \$2 a problem (for steps shown) or \$1 a problem for answers only. Email: jim_thompson5910@hotmail.com Website: http://www.freewebs.com/jimthompson5910/home.html

 ==section input Enter whole numbers only for the radicand. For instance, if you want to simplify {{{sqrt(75)}}}, enter 75 into the box: *[input input=75] ==section solution perl if((\$input=~m/\D/)&&(\$input!~m/\-/)) {print "Error: Enter whole numbers only"; return undef;} #if(\$input<0) #{print "Error: Enter positive values only # #Simply factor out a negative 1 to make the value positive. # #So change {{{sqrt(\$input)}}} to {{{i*sqrt(",abs(\$input),")}}} where {{{i=sqrt(-1)}}}"; #return undef;} if(\$input<0) { \$in_negative_check=1; print " {{{sqrt(\$input)}}} Start with the given expression "; \$input=abs(\$input); print " {{{sqrt(-1*\$input)}}} Factor out a negative 1 {{{sqrt(-1)*sqrt(\$input)}}} Break up the square roots using the identity {{{sqrt(x*y)=sqrt(x)*sqrt(y)}}} {{{i*sqrt(\$input)}}} Replace {{{sqrt(-1)}}} with {{{i}}} (remember {{{i=sqrt(-1)}}}) Now lets simplify {{{sqrt(\$input)}}}: ";} \$sq=sqrt(\$input); \$value=\$input; \$input="sqrt(\$input)"; \$square_root_value=sqrt(\$value); #\$input="sqrt(75)"; if(\$input=~ m/(\d+)/) {\$num=\$1;} if(\$in_negative_check!=1) {print "{{{\$input}}} Start with the given expression";} if(\$sq!~/\./) {print " Since \$value is a perfect square, we can take the square root of \$value to get a clean number {{{\$input=\$sq}}}"; if(\$in_negative_check==1) {print " So {{{sqrt(-\$value)}}} simplifies to {{{\$sq*i}}} (just reintroduce {{{i}}} back in)";} return;} \$tick=0; for(\$count=2;\$count<\$num;\$count++) { if(\$num%\$count==0) {\$gcf[\$tick]=\$count; \$tick++;} } print " The goal of simplifying expressions with square roots is to factor the radicand into a product of two numbers. One of these two numbers must be a perfect square. When you take the square root of this perfect square, you will get a rational number."; if(\$tick==0) {print " However, since \$num is prime, we cannot factor \$num any further. So the expression {{{\$input}}} cannot be reduced any further"; if(\$in_negative_check==1) {print " So {{{sqrt(-\$value)}}} can only be simplified to {{{i*sqrt(\$value)}}}";} return;} print " So let's list the factors of \$num"; print " Factors: 1,"; for(\$count=0;\$count<(\$size=@gcf);\$count++) { \$sq=sqrt(\$gcf[\$count]); print " \$gcf[\$count],"; if(\$sq!~/\./) {#print "\n \$gcf[\$count] is a perfect square \n"; \$num1=\$gcf[\$count]} } if(\$num1==0) {print "\$num Since none of these factors are perfect squares, we cannot simplify {{{\$input}}} "; if(\$in_negative_check==1) {print " So {{{sqrt(-\$value)}}} can only be simplified to {{{i*sqrt(\$value)}}}";} } if(\$num1!=0) {\$num2=\$num/\$num1; \$sq1=sqrt(\$num2); print " \$num Notice how \$num1 is the largest perfect square, so lets factor \$num into \$num1*\$num2 "; print " {{{sqrt(\$num1*\$num2)}}} Factor \$num into \$num1*\$num2 "; print " {{{sqrt(\$num1)*sqrt(\$num2)}}} Break up the square roots using the identity {{{sqrt(x*y)=sqrt(x)*sqrt(y)}}} "; \$sq=sqrt(\$num1); print " {{{\$sq*sqrt(\$num2)}}} Take the square root of the perfect square \$num1 to get \$sq "; if(\$sq1!~/\./) { \$temp=\$sq*\$sq1; print "{{{\$sq*\$sq1}}} Take the square root of the perfect square \$num2 to get \$sq1 {{{\$temp}}} Multiply "; print " So the expression {{{\$input}}} simplifies to {{{\$temp}}}";} if(\$sq1=~/\./) {\$temp="\$sq*sqrt(\$num2)"; print " So the expression {{{\$input}}} simplifies to {{{\$sq*sqrt(\$num2)}}} ";} if(\$in_negative_check==1) {\$temp=~s/(\d+)\*sqrt/\1\*i\*sqrt/; print " --------------------- Answer: So the expression {{{sqrt(-\$value)}}} simplifies to {{{\$temp}}} (just reintroduce {{{i}}} back in) "; return;} print " ---------------------------- Check: Notice if we evaluate the square root of \$value with a calculator we get {{{\$input=\$square_root_value}}} and if we evaluate {{{\$temp}}} we get {{{\$temp=\$square_root_value}}} This shows that {{{\$input=\$temp}}}. So this verifies our answer "; } ==section output ==section check angle=40 angle1=50