 All right, it's time to learn how to do pro-mathematical formatting in graph with EQN That's what this video is going to be on now Many of you guys have been following my series on graph, which is quite excellent as it is a quite excellent tool But graph comes with a lot of little preprocessors that can work a lot of magic I did a video on refer already, which does bibliographies EQN or equine. I don't know how it's actually pronounced is Excellent because it does mathematical notation like stuff like this So in this video where we are going to learn how to do this kind of stuff. It's very simple We're gonna learn how to do it in graph So here is a graph document we can start off with I've already formatted it You'll see I am using the MS macros nice and simple And if we want to let's say we want to add some mathematical equations Because we need a minimum our document or maybe we just want to look smart And so let how do we go about doing that now? I'll go ahead and I mean it as we've talked about in other videos There are these preprocessors that you can that basically hone in on a particular part of a graph document and they perform special operations like you know again finding bibliographies or Putting in graphics or in this case formatting correct mathematical notation and so to Do something to let's say let's say we want to add a basic equation to our document. It's very simple what you do is eqn reads everything that's between the eq command and The en command everything between this will be Interpreted as an equation. So let's say we want the equation x equals 3 plus 5 Now to format this document. There are two main ways Which are sort of the same thing you can run eqn on your document Saying that you want to output to PDF and then push or pipe that into graph and Output it into a particular PDF. So you'll see here now. We have our little equation here. So x equals 3 plus 5 very nice Another way to do it a little simpler. Yes is you can actually get rid of the eqn command And if you just run graph with the e option, it will automatically Gotta give it the file name. It will automatically format that Doc or pre-process it with it pre-process it with eqn So that's what commands you run. I'm gonna be using a compile command in my vim So you're not gonna see me run it every time but just know that that's that's how it works But anyway, let me show you what eqn can do before you actually end up doing this yourself So let's talk about basic formatting. I'm gonna copy this line and paste it in again Actually, let's let's change a little. Let's say, you know x is greater than 3 Plus or minus 5 or something like that. I'm gonna compile that now first thing notice about eqn Is that all the stuff in the equation block is interpreted? It's gonna be formatted on one line by default So you'll see that even though we made a new line here It's not actually going to acknowledge that new line. In fact eqn does all of its new lining and all of its spacing by default Whether or not so I could for example get rid of these spaces or something like that And that's actually not going to make a difference in the output Now if you want something now, there's a reason for this and the reason for this we'll talk about a little later It basically amounts to it when you have really big equations It's then it's nice to be able to put things on multiple lines But if you want, you know multiple equations, you have to put them in different equation blocks Now I'll talk about doing in text math and stuff like that at the end of the video But we got to do the basic stuff first So so here we have our two equations. So note for the second one I have this greater than or equal to sign the or you know, literally just the open Bracket and the angle bracket whatever people call them. I don't know they're like different country to country and the equal sign That is automatically formatted to the greater than or equal to sign or plus and minus you put them together They make the plus and minus sign now very very nice very expectable or you know, you can have You know exclamation point for Not equals etc etc pretty much the kind of stuff you'd expect. So let's let's do something a little more So for example superscripts, so let's say we want to the the equation or not equation Let's say we want the discriminate or whatever, you know in like the quadratic formula So that is B squared minus 4 AC All right compile that now you'll see what I did here to get a superscript What you do is you say soup and then the next thing is going to be the thing that's going to be in the superscript now Let's say hypothetically you'll see that two is the only thing that is superscripted Let's say hypothetically we wanted to superscript 2 minus 4 AC now There are two ways to do it one is we could just physically put them all as one big thing That's a possibility Although you can't always do that. We'll talk about sometimes you need spacing in different places But the more robust way of doing it is actually treating it as one big thing with brackets Maybe these are angle brackets, you know the terms are just so annoying, but these kind of brackets, right? So you'll see that now these are all treated as one big thing if we delete the brackets You'll see that they go away or well too is going to be the thing that is superscripted You might also be able to guess the opposite of soup is sub for subscripts So we can have nice little subscripts here, but I'll keep this as the Discriminate because I think we'll use this later. We'll do something special with it later on so basic equations other things I pulled up I Pulled up a couple tabs here. Let's say we want to format the equation for the golden ratio So phi equals 1 plus the square root of 5 over 2. That's that's what we're going to pronounce Okay, so how are we going to do this? It's actually super easy. Don't worry about it Don't worry. You don't worry when you watch my videos, right? Because everything's nice and easy. So phi first off To format any kind of Greek letters be they pi or phi or anything else you can just write their name out So this is going to appear. I'll go ahead and compile this. It's gonna appear just as phi So phi is equal to Well, I'll write it the wrong way first. So again 1 plus the square root of 5 over 2. This is I'm writing it the wrong way squirt 5 Over 2 Compile this now over is a command that takes one argument before it That's going to be the numerator and one argument after it It's going to be didn't the denominator now. You'll see by default. We want one to be part of this numerator But it's only looking at the last element which is this square root of 5 This is treated as one element since it's square squirt running on 5 In order to get what we want. We are going to have to use nice little brackets here Angley brackets whatever you want to call them Format that and now we got what we want phi equals 1 plus square root of 5 over 2 very nice That's what we that's what we need. So you got to be careful with your angle brackets. Sometimes you need them You'll I mean it's just like plugging stuff into a calculator or something I mean you you guys do kids in school still use like Ti 48 whatever they are those Texas Instruments stuff sort of curious if you still use that who is calling me Kids this is why you don't go to college because once you graduate from college every school You get a degree from is just gonna call you every week and ask you for money Don't drop out of college. Anyway, what was I talking about? Okay? Yeah, so let's do let's do some more formatting. So we have Phi that's very nice. We know how to do Greek letters. We know how to do square root. We know how to do over Let's do something a little more complicated. I pulled up the tab for standard deviation And yeah this thing right here. So here is our sample standard deviation and let's let's try and format this This is a little more complicated. In fact, I'm gonna move it over here So we can see what we're working on so I don't embarrassingly forget what I'm doing in the middle of it. So You know, it's just the sum of squares over, you know in plus in minus one or whatever So let's go ahead and do this now. There are a couple scary things in here first Everything's in a square root and there's also a summation notation and there's this bar over the x But it's all actually really easy So for this we're going to want to probably use multiple lines as I mentioned before you're free to pretty much add You know add some extra new lines if you want and they're not going to show up in the finished project So first I'm going to do squirts And there's going to be square root that's going to be over the entire thing So I'm just going to go ahead and close that at the end and I'll do the numerator So the numerator is also out. Well, I'll put the brackets in for the numerator later Well, let's do the summation notation first because that's the scariest looking thing I mean if you want to look smart just use a bunch of summation notation now how to do that is Actually pretty much how you would describe it in English. So this is the sum From I equals 1 to capital N So how you do this in graph is literally just sum from I equals 1 To capital N and I'll go ahead and compile this just to show you that it works. Here it is I equals 1 capital and obviously graph is formatting it above and below while Wikipedia has this on you know Saving space with the you know on the same sort of line But it's the same thing and obviously if you have something bigger like to in plus five or something like that If you want that to be one element, you of course need some angle brackets in here Just hypothetically if you needed that So just be aware But so anyway, so we have the summation notation and then we're gonna need the well, it's the sum of squares So we're gonna have x subscript y subscript i excuse me then x bar and then To close the parenthesis a superscript to format that and you'll see oops. I messed that up There are so some of the keywords like soup and bar and stuff like that You should have spaces or new lines or on either side here I forgot to add a space between the parenthesis But so if you add the space in here, you will see that there is a nice little bar So that the numerator looks very good and the denominator let's say Well, we got to put the numerator in brackets because we want it to be all one big element And that is going to be over In minus one again the syntax is just the same that we had further up It's set for You know well so over I mean what where's our five? Yeah, here it is So it's the same thing as our phi equation Where the first argument over is before and the next one is after i'm just putting them on multiple lines for ease So here here we go And that's pretty much why did I say x should be s for standard deviation Silly silly me but there is our standard deviation equation nice sample standard deviation equation Actually very different in statistics, but so that's it a pretty complicated equation Pretty easy to do as well Another thing we can do I pulled up the little tab for pi here Here we have an integral and that can be done pretty much in the same way you do sums So let's do this little pi equation here just as an example So eq Again pi is a greek letter. You can just write it out pi equals the integral from negative one to one Exactly the same estimation notation here and then we have dx over Of squirt Why do I always say squirt? It just sounds right. It sounds It sounds like a good way to say it now. I'm going to compile this And so notice a couple things notice. I didn't we have over here, but I didn't put things in brackets Because squirt squirt is going to treat ever since all this stuff is already in squirt This is going to be treated as just one entity here Whereas dx is just one entity as well. So since we only have one thing we don't need brackets unifying everything But uh, anyway, here's what we're looking for pi equals integral yada yada yada I I never learned this in school. I had to look it up, but whatever. So there it is So aside from that speaking of things I we did learn in school I want to show off. There's another Very useful thing you can do where you can let's say the you're going to be writing some particular equation Over and over and over again or part of an equation So here we had the discriminant up here. So the discriminant is part of the quadratic formula But let's say, you know, we're writing a paper and we have to write it a million or the discriminant out We have to write it out a million times and we're just too lazy. We don't want to do that One nice thing you can do is you can actually I guess define macros or define variables And you can contain some mathematical stuff in it. So let's go up here And instead of just printing this stuff out, let's say define A disk for discriminant And then what you want that one So this is the variable name and all the stuff you want to define it as Is going to be between ticks between grav accents I'm going to output this you'll see that it disappears. That's because we're now no longer outputting something We're just defining something But now that we've done this every time we type in disk for discriminant Let's make a new little code block here Maybe I should zoom up for you guys Every time we write out disk it's going to print It's going to print out The discriminant the thing that we've defined it as So now let's say we want to write out the entire quadratic formula Which I hope I remember because I didn't pull it up If I forget I'm sorry miss axman that I forgot my quadratic formula. So I think it's um x is equal to Minus b Uh plus or minus the square root of the discriminant Take our discriminant put it in that And then all of this stuff is going to be in brackets I'm going to put these notice. I'm just putting them on different lines But same kind of stuff all of that is is going to be over to a I think that let me see if it looks right Does that look right? Yeah, I think that's it. I think I got it right. Maybe I should look it up But someone can complain in the comments if I got it wrong. So there's our quadratic formula And notice a couple things about I mean we have all the typical stuff the plus or minus squirt We have the over but we're also using the variable. We just defined disk Or another thing we could do. I mean, let's say Uh, we wanted to find we have to write the quadratic formula out a million times Let's actually put this all on one line. Uh, we can define quad As all of this. So now we've defined Uh, the quadratic formula. So whenever we say quad Type that out So quad Actually, let's let's have quad quads One two three four print that out and look at that. We have lots of quadratic formulas God, I hope I got this right miss axman would be so mad if I got this wrong There there's some song that like you can recite to remember the quadratic formula But I don't really remember the tune of it, but Anyway, so that that's how to do variables. Now, there's one other thing Now I'll go ahead and say look in the video description. I'm going to put a link to some eq and documentation I'm obviously not going over everything you can do in it. There's a whole lot of other stuff that you'll be interested in But I think most of the basics I have here But there's one other thing I want to talk about in the video and that is using inline code Because how we've been using it so far is we've just you know had paragraphs of text And then we have equations in the middle of nowhere, but sometimes you want to put Equations in a paragraph. So let's say we have hypothetically a paragraph here So this is a paragraph Here is another sentence Always forgetting to press escape So here Here's our new paragraph here, let's say we want to put some code in this paragraph now by default eq in doesn't have a way of eq in is only looking for eq and en that's all it's looking for it's not looking for anything else But you can do any of these code blocks. You can say you could set a delimiter I'm going to set my delimiter to Excuse me the dollar sign. Now what this means is Uh, eq eq win is going to search any paragraph text or anything else for dollar signs or things that terminate with a dollar sign and in with a dollar sign And it is going to interpret that as code that it should you know Print out as being mathematical So what we can do in this paragraph we can say Here is an equation So, you know something like put it in a dollar sign. So x equals five super script 10 or something like that Um, and if we output that you will see that oh, look at that now We have super scripts in our main text these dollar signs don't appear It's all formatted, you know, we could even have summation notation I mean let's replace the x with some from I don't know one two ten Doesn't really make any sense. Uh, that's not not a very true This is not a true statement But whatever you see we have our summation notation and all that stuff it formats all this stuff in line And we can still have you know here is more text something like that Okay, uh, no problem. Um, now one well one potential problem is since we've defined these dollar signs as being the delimiters Uh, graph might get a little confused if we use, you know, you know, let's say I bought this for a dollar or That's not what I meant to say for ten dollars or something like that If we run that you'll see that it's not gonna it's not gonna work It's it doesn't compile properly and the reason that is is because it's found this dollar sign here And it's interpreting that as eqn stuff and it's looking for the next dollar sign So what you actually have to do is explicitly say, okay, our delimiter forget about that Uh, turn that thing off We'll turn off our delimiter there and here we go. I bought this for ten dollars So that that's one kind of downside. I think I wonder if you can do this in text I wonder if I can say I'm not actually sure of this. I'm trying this real time. So what if I say the limb In here does that work I'm just curious Oh, I guess it does work So you can even include it in the if you don't want to have to space another paragraph You can include it in the in text or in paragraph formatting, but Anyway, so I think uh, I think this has been a good enough introduction I hope you have some ideas for the kind of stuff you can do with it I mean look at all these Smart-looking equations that we can make just with this video of 10 minutes or however long it's been I feel like it's been more than 10 minutes But anyway, so this is eqn as I said check the video description. I'll have some links to More extensive manuals that have more of the stuff than is just in the if you type in man eqn But yeah, again, this is a lot of fun. It's another preprocessor for graph I might do other graph preprocessors in the future I think We're about at the the point where i'm getting emails from people saying oh great now I'm doing this and this and this with graph. There's so many things I can do So that's the point. Glad you guys are looking at new content and stuff But hopefully this will inspire you to look into mathematical formatting and graph I actually prefer it to la tech by not by that much, but you know la tech There there are a lot of problems with the la tech, you know, but that's for another video But anyway, see you guys next time and I hope you learned something