As we continue to practice with functions in MATLAB, a really good example or good experience is
to go ahead and program a function 
for the quadratic formula.
As you probably remember,  the quadratic formula solves ax² +bx + c - B + or - , square root b² - 4ac Over 2a
As you start to think about how
you're gonna program this.
You want to think about how many inputs you, 
have how many outputs you have.
You also want to test your function.You don't want to just assume, oh I code it so it must work.
So think about something that you know the answer to.
So, if I have x² + 5x + 6 = 0. 
If I factor that. I have X + 2 and X + 3.
Which means that my solutions are,
x = -  2, - 3.
So that would mean A = 1.
I guess I could use the formula to do that, 
but that seems like more work than necessary.
B = 5 and C = 6. 
So try programming this. See if you can get it to work.
Plug in the numbers A, B, and C is 1, 5, and 6.
And see if you get outputs - 2 and - 3.
So give that a shot.
See if you can actually get it to work.
Alright, so assuming that happened,
then let's give it a shot. So, um.. 
When I think about how many inputs I have.
I have these inputs A, B and C.
Now I don't hard-code them as those, 
but these are going to be my inputs.
I'm gonna have two outputs, 
there's going to be an x from the positive part of this,
and an X from the negative part of this. So let's see what we can do with this.
Okay so whenever I start any function, 
I always want to start with the word function.
If you have anything but that, if you start with the CLC clear, if you start with like a comment,
If you start with anything you know, it's just all bad. 
Just start with function.
I think that I'm gonna have two outputs.
Well I know that I'm gonna have two outputs.
There's gonna be X1 and X2. So I define my two outputs as two outputs, and I put them into brackets.
And I'm going to call this
my quadratic or whatever.
Then I have three inputs A, B, and C.
So I'll do that, yay! Okay so, um..
The next thing I need to do:
So I'm going to assume that MATLAB, the user is going to provide to MATLAB the values A, B, and C.
Then I'm going to produce x1 and x2.
So I'm really excited, I'm like, 
okay well I can do this.
Hopefully at some point 
I'm gonna make this a little bit easier on myself.
I don't want to try to do this all in one formula, because 
I think I'm gonna get confused.
So I'm gonna do kind of like this part and 
if you remember that's called the discriminant.
Or at lease the part underneath.
So it doesn't matter what it's called, 
because I'm not going to do it that way.
The thing underneath is called the discriminant.
I'm going to do the whole thing 
including the square root.
So basically I'm gonna call this like big X
and then I'm gonna call this guy, big Y.
So then I can go like - B + X/Y and - B - X/Y.
There's no real rule that says I can't do that. 
So they can just deal.
Okay so, I'm gonna call big 
X =  square root of B² - 4* a * c
And big Y = 2 * a. So my first solution is going to be,
- B + X / Y. 
And X2= - b - X / Y.
You should instantly go, oh no this is terrible! 
Because it is.
It's intentionally terrible. Make sure that
you remember that this has to be in parentheses,
because the negative B plus X and the negative B minus X have to be done before the division by Y.
So that actually you should get me pretty far.
I'm gonna go ahead 
and suppress my intermediate output,
and nothing in my function should actually produce an output. I'm excited now because this little thing is green.
When this thing is green that means that the MATLAB gods are happy.
And if Matlab gods ain't happy,
ain't nobody happy.
So my quadratic, and I think I decided
that my inputs were going to be 1, 5, and 6.
I get output - 2, and 
you're like oh no what happened to the other output?
Like well, I never actually asked for it. 
Blah potato is going to be my quadratic.
1, 5, and 6. Now I've got my two outputs, -2 and -3.
You're like, well that's really awesome!
 Okay so, let's say that I've got a couple of things.
So, I'm just gonna open up a little tab right quick.
Say I've got.. actually a couple of A's.
I've got bah blah blah for A's, for B's I have blah blah blah,
and for C's.. I have, I don't know blah blah and blah.
I have these like no big deal. I'm gonna run 
and get my two outputs from my quadratic.
Calling for A, B, and C.
So I'm like alright, I'm gonna give this a shot
and see what my answers are from this.
And I get an error.
I'll start with the CLC clear, so we're exactly sure. Okay.
So I have an error with this,
it says blah blah blah blah compute element-wise power (phone ringing in background) use stop power instead.
So I'm like alright, I'll give that a shot. So - pashewww!
Alright, so amazing.
So basically what's going on is, that I've said B is actually
an array of three elements, and I can't square an array.
And that's what it's telling me, 
so I can't square an array, but I can dot square.
I have a feeling that 
I'm gonna have the same problem over here,
I can't multiply two matrices together
but I can dot multiply them together.
Now you can do this, it's not strictly necessary, 
but if it makes you feel better,
there's no reason that you can't.
You can actually just straight up multiply four times A.
Then do a dot matrix for C- or dot multiply for C, 
if you want to.
I'm gonna run into the same
problem here for a dot divide.
So I need to fix that as well. Hopefully with those fixes,
I will be able to run this.
Yay! I got my three solutions.
So these are my first pair of answers,  my second pair of answers, and my third pair of answers.
