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

When it comes to solving equations, we run into two types in higher math: those that can be solved for EXACT solutions and those that can be solved for only APPROXIMATE solutions. I will show you how to solve for exact answers as it's the easier of the two(not saying the second is much more difficult to master). I am going to perform three different problems. When you want exact solutions(or at least hope for one) we use the solve function which takes two arguments: (1)the equation or left side of an equation that has zero on the other side and (2)the variable(s) to be solved for. Notice again that I have to declare m,  b,m,\; b, and yy as variables!

  1. Solve 3x4=53x-4=5 for xx

  2. Solve y=mx+by=mx+b for mm

  3. Solve the system of two equations, {2x3y=4,  5x+3y=10}\{2x-3y=4,\; 5x+3y=10\} for both xx and yy.

eqn1=3*x-4==5 sols1=solve(eqn1,x) show(sols1)
y,m,b=var('y,m,b') eqn2=y==m*x+b sols2=solve(eqn2,m) show(sols2)
y=var('y') system=[2*x-3*y==4,5*x+3*y==10] sols3=solve(system,x,y) show(sols3)

Now we have a minor problem that will rear its head in the future. When you executed the code above, did you notice that the answers are written as parts of little equations? That's OK if we just want to write the numbers down on paper, but we will often want to use these answers in more code down the road. For this we need to use a function called rhs.() which stands for righthand side. The parentheses will always be blank! I will do two examples using what's been done above. I will extract the xx-value from sols1 which has a single equation solution. The second example takes more work. I will extract the ordered pair equations list from sols3. Then I can extract the yy-value from the second equation in this list.

eqn1=3*x-5==5 sols1=solve(eqn1,x) show(sols1) ans=sols1[0].rhs() show(ans)
y=var('y') system=[2*x-3*y==4,5*x+3*y==10] sols3=solve(system,x,y) show(sols3) ans2=sols3[0] show(ans2) y_value=ans2[1].rhs() show(y_value)

The second type of equation does not have any method to find exact solutions. But that's OK. In most applications, we don't need(or even want) fancy exact values. The procedure is fairly simple.

  1. Move everything to one side, getting 0 on the other side and call what you have a function(usually of x).

  2. Find a pair of bounds, left and right, that sandwich a zero of the function you now have. This usually requires looking at a graph of the thing.

  3. We then use the find_root function which takes three arguments: the function, left(lower) bound and right(upper) bound.

My example will use a function from precalculus 1. You may not know this one right now, but you will later.

The equation is x2+2=exx^2+2=e^x. Because I already looked at a graph, I know that there's an xx-value that works somewhere between 0 and 10. So here goes. . .

eqn(x)=x^2+2-e^x #notice I got zero on the right side and 'eqn' is a function of x sol=find_root(eqn(x),0,10) show(sol)
1.31907367686\displaystyle 1.31907367686