 Now that you've seen me take pencil to paper and solve quadratic equations, even develop a quadratic formula, let's use Python and make our lives a lot easier. So we've opened our new notebook, you see it's pre-populated, again I don't want you to watch me type on the screen, that'll take a really long time. So we see solving quadratic equations, we do remember quadratic equations, that second order polynomials, so the highest power of our variable x would be 2x to the power 2. Again I'm only going to import the functionality from the SimPy package that I would require in this notebook. Now the first function that we're going to call, as always is the init underscore printing function, we do want that beautiful mathematical type setting when we execute our SimPy code. Let's look at our first problem, it's a polynomial, the highest power is 2 and that leading coefficient is 1. So we have x squared plus 5x plus 6 equals 0 and I want to solve that for x. Now I've got to use SimPy to create a mathematical variable x and I do that with a symbols function as we've done many times before and I'm going to set that to be any real number. So I'm going to assign that with the equal symbol, the assignment operator, I'm going to assign that to the computer variable named x. And so let's use the eq function, so it takes two arguments, remember there's my left hand side of my equation comma the right hand side of my equation, let's execute that just to make sure that we have the problem correctly printed and it's x squared plus 5x plus 6 equals 0, that's fine. I'm going to now pass all of that to the solve function as first argument, my second argument is going to be x because I want this solution to be in terms of x and we see two solutions, negative 3 or negative 2. Now what I want to do is just to substitute this into x and just make sure that I do get 0 on the left hand side. So everywhere where there's an x, I'm just going to pass negative 3 inside of a set of parentheses. Let's do that. And indeed we see the solution 0 as we would expect, let's substitute the other solution negative 2 and remember this is the simple arithmetic, there's no SimPy involved, I'm just using Python to do some simple mathematics and indeed we see the solution is 0, we verified that those two solutions negative 3 or negative 2, they're absolutely correct. Let's solve the following polynomial, a quadratic a second order polynomial 4x squared plus 5x negative 6 or minus 6 equals 0, let's print that to the screen, it seems we've got everything right there when we typed, let's pass that to the solve function and we see two solutions negative 2 and 3 quarters. Once again I want to verify these results, just simple mathematics, I'm going to substitute negative 2 and I see the result is 0, quite correct and I'm just going to say 3 divided by 4, I'm not going to use the rational function because I just want simple arithmetic and indeed the result is 0, it's going to be a floating point number, 0.0 because 3 divided by 4 is going to give me 0.75 so SimPy is going to say or at least Python is going to say that this is a floating point value and it's going to do 0.0 instead of just the integer 0. Let's do the following problem, x squared plus 6x plus 7 equals 0, I'm going to print that to the screen, make sure that what I've typed there is correct, it does seem to be, let's pass that as first argument to the solve function, the second argument being x and look at that with a pencil and paper exercise, without that quadratic formula we would not have been able to get to the solution and look how easy this is with SimPy. So let's substitute there, I've got negative 3 minus the square root of 2, the sqrt function, I imported that from SimPy, so let's run this and we see well unfortunately the arithmetic has not been completed for us and the way that you would solve that little problem is to take your substitution that you had right there, put it inside of a set of parentheses so that becomes a single object and then on that object I'm calling this simplify method, we've discussed this many times before and now you see the arithmetic has been completed and I get the solution 0. I'm going to verify the second solution that's negative 3 plus the square root of 2, once again that arithmetic will not be completed, it looks very nice but let's pass all of that inside of a single set of parentheses, I'm creating a single object as you can see me highlighting there and then I'm going to call the simplify method on that object and we see the result is indeed 0. Next problem, x squared plus 4x plus 5 equals 0, let's print that to the screen, make sure that our typing was correct, that seems fine, I'm going to pass that to the solve function and look at that, no solution whatsoever. Now I said x to be any real number and there seems to be no real solution, so let's recreate the symbol x but this time we set it to be a complex number, now remember all real numbers are complex numbers so I would still get the real solutions but if there are no real solutions I will also get the complex solutions, I'm going to reassign that, I'm going to overwrite the little piece of memory in my computer, call that little piece of memory x again but this is now a new symbol x, let's execute that and now let's solve this equation and now I can see I do get some solutions, it's negative 2 minus i, negative 2 plus i, my two solutions, those are both complex numbers, now I imported uppercase i that's the symbol i that means the imaginary unit i, so I can verify my result by substituting my solutions and we see the solution there, it looks beautiful but the arithmetic is not being completed so once again I'm going to pass that into set of parentheses and I'm going to call the simplify method and we see the arithmetic has been completed the solution is 0, when I want to verify the second solution once again I will have to pass all of that to a set of parentheses and then call the simplify method and I get the solution 0 again. Lastly let's look at that quadratic equation you know the solution that we found so let's just do ax squared plus bx plus c equals 0, I want to solve for x a not being 0 so I'm going to create these symbols a b and c, remember to put the commas on the left hand side those are the computer variables I want to separate them the symbols that I'm actually creating I don't need to put commas in between there inside of that string object, let's create the equation printed to the screen that's fantastic and now let's look at what happens when we do the solve function, there we get our solutions that we work so hard for in the pencil and paper exercise just beautifully rendered to the screen. SimPy is great at working with quadratic equations and solving for x.