Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
483 views

##Lab #4 More Algebra Commands

%md Here we look at some of the basic commands you normally have done by hand with polynomials. The first two are greatest common factor, GCF, and least common multiple, LCM, followed by the *factor* and *expand* commands. Finally, we'll do some calculation and simplification with fractions and radical expressions. Execute each of the blocks of commands. Make sure you look at the syntax of the command lines.

Here we look at some of the basic commands you normally have done by hand with polynomials. The first two are greatest common factor, GCF, and least common multiple, LCM. Execute each of the blocks of commands. Make sure you look at the syntax of the command lines.

x,y=var('x,y') show([6*x^2*y,8*x^3*y^2]) show(gcd(6*x^2*y,8*x^3*y^2))#asking for the greatest common factor of the two terms. f(x)=x^2-3*x+2; g(x)=x^2-4*x+3 #defined two polynomial functions show([f(x), g(x)]) show(gcd(f(x), g(x)))#gcd works with more than two polynomials ︠dcf0d374-fb4c-4c68-906d-cb7d4ae9aeb3︠ show(lcm(12,18))# asking for the least common multiple of 12 and 18 show([15*x^2*y^3,20*x*y^4]) show(lcm(15*x^2*y^3,20*x*y^4))#asking for the lcm of the two terms show([f(x), g(x)]) show((lcm(f(x), g(x))))#asking for the lcm of the two polynomials I created in the block above. ︠04c4c6af-888e-4861-868c-6e59b7238392i︠ %md Notice the output for the last one!! That's certainly not what I expected. SAGE sometimes has a mind of its own. I will try adding a *simplify* command first.

Notice the output for the last one!! That's certainly not what I expected. SAGE sometimes has a mind of its own. I will try adding a simplify command first.

show(simplify(((lcm(f(x), g(x)))))) ︠fb1fd34c-1495-4440-b18a-c0f48dc7ca4bi︠ %md Well, that didn't work! Now check out this special command. Take careful note of the syntax.

Well, that didn't work! Now check out this special command. Take careful note of the syntax.

show((lcm(f(x), g(x))).simplify_full()) ︠0a57260f-1d2e-4b19-9685-2d0f02bb79dci︠ %md That's more like it!!!!!!!!! Everyone loves to factor polynomials, right? SAGE does too. Check out these. . .

That's more like it!!!!!!!!! Everyone loves to factor polynomials, right? SAGE does too. Check out these. . .

show(x^2-7*x+12) show(factor(x^2-7*x+12)) ︠b7d3a005-16d4-4a95-94f3-f2128b969907︠ show(x^2+2*x+1) show(factor(x^2+2*x+1)) ︠5e9fe005-45fe-4ae3-b534-f9b62882ed16︠ show(x^2+3*x+5)#this is a prime polynomial! show(factor(x^2+3*x+5)) ︠b8fcf374-b5b8-470a-addd-5833844c286bi︠ %md higher degree polys are no problem for SAGE!!!

higher degree polys are no problem for SAGE!!!

show(x^4 + 2*x^3 - 12*x^2 - 40*x - 32) show(factor(x^4 + 2*x^3 - 12*x^2 - 40*x - 32)) ︠65a32cd0-bea9-4847-bfea-56b289ea9f5di︠ %md Finally, the *expand* command multiplies factors together.

Finally, the expand command multiplies factors together.

show((x-2)^2*(x+5)*(x-4)) show(expand((x-2)^2*(x+5)*(x-4))) ︠426dfb0d-86c5-499e-9de5-c15fc8b24b82i︠ %md We turn our attention to the arithmetic of fractions(rational expressions) and radicals. We'll look at how SAGE responds to addition, subtraction, multiplication and division. Note again that SAGE has a mind of its own when it comes to simplifying and sometimes it's impossible to override it.

We turn our attention to the arithmetic of fractions(rational expressions) and radicals. We'll look at how SAGE responds to addition, subtraction, multiplication and division. Note again that SAGE has a mind of its own when it comes to simplifying and sometimes it's impossible to override it.

show(2/3);show(5/6) show(2/3+5/6) show(3*x/(x-2));show(5*x/(x+1)) show(3*x/(x-2)-5*x/(x+1))#you will notice that SAGE won't add them together and create a single fraction! show((x-5)/(x^2-3*x+4));show((2*x^2-x-3)/(5*x-25))#we'll multiply these two fractions together show((x-5)/(x^2-3*x+4)*(2*x^2-x-3)/(5*x-25)) ︠0b0b7005-757b-4102-b2ba-7fd4704ffa5ai︠ %md Your turn!! 1. Find the LCM of $2abc^2$ and $3a^2b^2c$ 2. Find the LCM of $x^2-7x+12$ and $x^2-9x+20$(Make sure it's in simplest form) 3. Determine the GCF of $24a^3bc^2$ and $36ab^2c$ 4. Factor $2x^4-3x^3-9x^2+8x+12$ 5. Expand $(2x-3)^7$ (wouldn't want to do this by hand!!!!!!) 6. Find the product of $\frac{3}{4}$ and $\frac{5}{6}$ 7. Divide $\frac{2x^2}{3y^3}$ by the fraction, $\frac{2xy}{x+y}$ 8. See what SAGE produces for $\frac{2}{x-1}+\frac{3}{x-2}$

Your turn!!

  1. Find the LCM of 2abc22abc^2 and 3a2b2c3a^2b^2c

  2. Find the LCM of x27x+12x^2-7x+12 and x29x+20x^2-9x+20(Make sure it's in simplest form)

  3. Determine the GCF of 24a3bc224a^3bc^2 and 36ab2c36ab^2c

  4. Factor 2x43x39x2+8x+122x^4-3x^3-9x^2+8x+12

  5. Expand (2x3)7(2x-3)^7 (wouldn't want to do this by hand!!!!!!)

  6. Find the product of 34\frac{3}{4} and 56\frac{5}{6}

  7. Divide 2x23y3\frac{2x^2}{3y^3} by the fraction, 2xyx+y\frac{2xy}{x+y}

  8. See what SAGE produces for 2x1+3x2\frac{2}{x-1}+\frac{3}{x-2}

When it comes to radical expressions, again SAGE has a mind of its own. We know that when multiplying radicals together, we should just multiply the radicands and put the product under a single radical sign. SAGE doesn't seem to know this. For instance, let's try 23\sqrt{2}\sqrt{3}.

show(sqrt(2)*sqrt(3))
32\displaystyle \sqrt{3} \sqrt{2}

This is again another one of those times where you have to be smarter than the machine! We'll make SAGE do the dirty work with a little extra guidance. . .

show(sqrt(2*3))
6\displaystyle \sqrt{6}
︠d7e279b6-cc49-4197-8010-3667c0d7f9cbi︠ %md How about combining like or unlike radicals like $\sqrt{12}+\sqrt{27}$? Since $\sqrt{12}=2\sqrt{3}$ and $\sqrt{27}=3\sqrt{3}$, the solution should be $5\sqrt{3}$. What does SAGE think about this?

How about combining like or unlike radicals like 12+27\sqrt{12}+\sqrt{27}? Since 12=23\sqrt{12}=2\sqrt{3} and 27=33\sqrt{27}=3\sqrt{3}, the solution should be 535\sqrt{3}. What does SAGE think about this?

show(sqrt(12)+sqrt(27))
53\displaystyle 5 \, \sqrt{3}

Looks like SAGE behaved itself this time, but don't be surprised if you have to direct the show from time to time and sometimes, like with fraction addition, it might only do what it wants to do. YOU HAVE TO BE SMARTER THAN THE MACHINE!!!!!! Try your hand with these to see what SAGE returns.

  1. 3242123\sqrt{24}-2\sqrt{12}

  2. 2x3y2+5x2y32\sqrt{x^3y^2}+5\sqrt{x^2y^3}

  3. x26x+9\sqrt{x^2-6x+9}

  4. 543\sqrt[3]{54}

  5. 1285\sqrt[5]{128}

︠2f700423-9eda-4cc0-a99e-3c9763fb41a1︠ ︠8fccf7a0-77d7-45f8-85b9-fc6b3b8f686d︠ ︠4e378610-41a4-4f42-88de-a76cb71a306a︠