LaTeX-Old-Version/C2/Equations/English-timed

From Script | Spoken-Tutorial
Revision as of 21:14, 20 November 2018 by Sandhya.np14 (Talk | contribs)

Jump to: navigation, search
Time Narration
00:00 Welcome to this tutorial on creating equations through Latex.
00:06 You see three windows as usual.
00:10 I have created a 12pt size, article class document. And using AMSmath package and also using the 'ccliscences' package for creative commons copyright statement as here.
00:30 make title creates the title page. new page command takes the rest of the document to a new page.
00:43 There are many ways to create equations, I will use the command align star to create equations.
00:51 Let us begin with a matrix differential equation consisting of four components.
01:03 Align star, Frac d by dt of begin b-matrix, x_1, next line x_2, end b-matrix.
01:27 Let me close this. Let us compile it.
01:37 So we have created ‘d by dt of x1 x2’.
01:42 Let us now augment the vector with two more components.
01:48 You do it as follows. Next line x3, next line x4. Save it. Compile it. So I have four components.
02:03 Let me now say that this is equal to the right hand side matrix begin b-matrix.
02:20 Zero, zero, one, zero.
02:29 Next line: zero, zero, zero, one.
02:37 And then, let's close this matrix. Save.
02:47 So I have this. So I have written the first two rows.
02:53 It is always a good idea to compile after every few small additions so that we have not made a mistake.
03:00 Note that the align star environment takes the role of the dollar signs.
03:06 For example, we did not enter the dollar sign at all. As a matter of fact, we should not enter the dollar sign within the align star environment.
03:14 Let us add a third line to the matrix on the right hand side and illustrate this idea.
03:25 Zero, dollar minus gamma, zero, zero. So there are four entries. Compile it. It comes and says, missing dollar inserted.
03:50 What we will do is, let's come here, get rid of these dollar signs. Save it.
03:59 Exit compilation by this x. recompile it and note that minus gamma has come. So we need one more line here, we put that. Zero, alpha without dollar sign, zero, zero. Alright, now this is the way to do that.
04:28 Let's complete this equation. I have a few more terms here.
04:34 Let me just see if it is here, yes, it is here.
04:39 Let’s cut this. Put this here.
04:46 Let’s see what happens when I compile this.
04:52 This is a model of an inverted pendulum.
04:59 What do you do when you have more than one equation?
05:04 Let us add one more align statement. And I have written this equation here.
05:13 Let me bring it from there.
05:17 Here is the equation, so let me say begin align star.
05:26 Let’s cut this. Copy this. Close this align. We compile it.
05:39 When I compile it, I get the second equation appearing.
05:44 There are two problems with this. There is a large gap between the two equations, also we may want to align the equations.
05:52 In view of these observations, we put both of these equations into a single align star environment.
06:01 So we will do this as follows. Delete this.
06:08 Save this. Compile it.
06:14 Now what has happened is that both the equations have come on the same line.
06:20 We will take care of that by telling latex to split this by the reverse slash. Two of them.
06:33 When I compile it, now these have gone to second equation.
06:40 But the equations are not aligned. Suppose that we want to align the 'equal to' sign, suppose we want to align these two signs, we put an ampersand symbol in front of the 'equal to' signs here. Let's put it.
07:00 And then we will put it here also. Ampersand. Let’s compile this. Now notice that both of them are aligned.
07:18 Suppose that we want to introduce some text in between the equations without upsetting the alignment.
07:24 This can be achieved using the inter-text command.
07:29 So we remove... we made a mistake here, the 'delta mu' has come here. So, what we should do is, let us first put this properly, compile this.
07:48 Now 'delta mu' has come there. 'U of t' is here.
07:51 Now we want to introduce some text between these two. So the line separator slash slash is removed and in that place we introduce this text that we want to include.
08:07 Let’s take this text and put it there. Whatever text we want to put, appears in braces with an inter-text command.
08:24 Note that the opening brace has to be closed, not closing the brace is a common mistake made by the beginners.
08:37 Let's compile this. So here is the text and you also have the equations aligned.
08:50 Note also the use of the dollar sign within the inter-text command.
08:54 Inter-text is like running text, so this is not really a part of the align environment. You need to include dollars here.
09:03 These equations don’t have numbers. In fact, the star in the align star command has told latex not to put the equation numbers.
09:14 Let us remove the star and see what the align environment does. Let’s remove the star here. Also remove the star here. Let’s see what happens.
09:30 So equation numbers have appeared automatically.
09:36 We want to refer to them, so for example, let’s say we want to refer to them, so I have this here.
09:49 Suppose, this is the second equation I want to discretize, so I write this statement.
09:55 Let me take this here, below this, put it.
10:04 Let me compile it. So it says "we will now discretize the PID controller given in equation 2".
10:13 The equation numbers unfortunately may change while insertion or deletion of equations.
10:20 To demonstrate this, let us suppose, we include an equation here.
10:32 Slash, slash, a equals b.
10:40 And then we will delete these lines. Let’s compile this.
10:47 Now I have 'a equals b' as the second equation. Now this has become the third equation.
10:53 Here we have hard-coded that equation 2 has to be discretized but this is no longer the second equation.
11:04 Hard-coding of equation numbers in referencing always has this problem. This is solved by the label command.
11:12 So, let us come here and here at the end of the equation we introduce ‘label equation PID’ and then here I write in equation ‘ref’, ref is the command and whatever that comes here label, should appear here also, again within the braces, 'equation PID’.
11:39 Let's see what happens when I compile it.
11:47 On compiling it, we see question marks here.
11:52 On second compilation, see what has happened here – now it has become three. On second compilation the numbers become correct.
12:03 This is similar to what we saw in table of contents.
12:08 Let us now delete the 'a equals b' equation.
12:15 Let us get rid of this also.
12:22 Let’s compile it. This equation 2 is gone but you still have this three.
12:30 On first compilation the reference gives the previous number, on second compilation the numbers become correct.
12:40 The labels are case sensitive. For example, here I have called it equation PID, PID is in capitals. Let’s change this to small pid.
12:54 What happens now, here it says that it doesn’t know that.
13:02 It's only that these have to be identical, these need not be characters. For example, suppose I want to give numbers here, let me just put hundred, let me put 100. Save it. Compile it.
13:21 Okay, it doesn’t know it yet in the first compilation but if I compile it second time it will know. Numbers are the same.
13:30 In a similar way we can create labels for sections, sub-sections and so on.
13:35 So let us do that, let us demonstrate this with section. Let us do it here.
13:45 Section, this is first section. Label, sec 100.
13:56 Then we go to the end of the document here.
14:00 And say: section ref sec-100, shows how to write equations. Save it here.
14:23 ‘Section, question marks shows how to write equations’.
14:26 On next compilation, this is taken care of.
14:30 So section 1, this number is the same as this number.
14:34 So this works for sections, sub-sections and so on. In fact, with any environment that has a number associated with it.
14:42 Alright, let’s delete these.
14:56 Let's compile these once again. Alright.
15:04 We will now see how to accommodate long equations.
15:09 So, I have already written it here. Let me just go there at the end of the document, okay here it is.
15:23 Okay. So let me add this.
15:29 Put it here. Let's see what happens when I compile it.
15:40 So I have a third equation that I have added here, it’s a long equation. It’s a long equation so it doesn’t fit into one line.
15:49 So let us break it into two. The way to do that is, let us break it here, slash slash and come here and I’m putting an align with this ampersand.
16:11 Let me save it, compile it. See that this equation has been broken into two parts and I am aligning it with the plus sign.
16:26 All these equal signs and plus signs are aligned now.
16:30 Unfortunately we have equation numbers in both parts.
16:35 Supposing we don’t want the number in the first line, suppose we don’t want this number. Include the command ‘no number’ before this slash, slash symbol. Do this as follows.
16:51 Save this. Compile this. See that this equation number is gone and this has become three automatically.
17:02 We see that the braces we wanted in some terms are missing. For example, here I have said e n, e n minus 1. Here it appears without these braces. This is because, braces are delimiters in latex.
17:16 We now want to tell latex to not interpret these braces. This is done by putting a reverse slash before the braces.
17:24 Let me put a reverse slash here. Let me also put a reverse slash here.
17:36 See that now we have the braces here; similarly let's put it here also.
17:46 Here and here. Let'sSave this, now we have got that.
17:58 We will now show how to create large brackets in equations. For example, here, these brackets are very small.
18:08 The way to do that is using – what are known as left and right commands.
18:15 So let's come here – so the equation is here.
18:21 The way to do this is – K slash left and on this side I have this, so here I put slash right.
18:38 Let’s compile this. See this, it has become bigger.
18:45 We can do this also with square brackets.
18:58 I got square brackets. I can also put braces, only thing is that I have to tell latex not to interpret. So I put a slash brace.
19:12 Let’s compile this.
19:17 See this braces.
19:22 When we have one equation split into multiple lines, we will have to put only the left on the first. For example, here, we have a bracket here, we have a bracket here, I want to make this slightly bigger. So let me do that here.
19:35 Suppose for example, I want to put a left bracket here and here I want to put a right bracket. Compile it.
19:57 It comes and complains ‘forgotten right’, because I opened it here but I didn’t close it in the same equation.
20:04 The way to do that is to use what is known as slash right dot, that means don’t worry about the right hand side.
20:15 Similarly , here we have to say slash left dot, don’t worry about the left here. Let me exit here. Let me re-compile it. So this is taken care of.
20:30 Now suppose I want to push this a little inside. I can always say slash h-space 1cm.
20:45 Let me just do that shift.
20:51 So, this has been shifted, this has been aligned.
20:54 If you don’t want this, you want the plus sign to come inside,
20:59 let’s do this here, put the plus sign here.
21:08 Okay, this plus is inside. Now this is nicely done.
21:17 All commands that work in between the dollar signs also work between the aligned environment but for the ampersand symbol that is used for the aligning of multiple equations.
21:27 All commands that work in the aligned environment also work within the dollar symbols.
21:32 Nevertheless, there is a small difference in the way some outputs appear in the aligned environment and in the running mode obtained with the dollar.
21:41 This can be illustrated with the integral mode.
21:46 So let's come here.
21:50 Let me delete these.
21:53 So I have this statement here. Let me take this,
22:10 let me put it here.
22:15 "The integral mode includes the term" this integral.
22:21 Let me close this, otherwise alignment will complain.
22:28 So what I have done is: The integral mode includes the term" this integral.
22:33 Note the size of this integral and size of this integral. This is a lot bigger and this is smaller.
22:47 Such changes also occur in the case of fractions, sum and product to cite a few.
22:52 There is one other thing that I want to tell before completing this tutorial.
22:58 Aligned environment does not like blank lines in between. Suppose for example, I create a blank line here.
23:11 It comes and says that paragraph ended before alignment was complete. If you really want a space, leave a percentage which tells latex that it is a comment.
23:24 Re-compiling. It goes through and you get all the text as before.
23:32 This brings us to the end of this tutorial. Thanks for listening.
23:37 This is Kannan Moudgalya, signing off. Good-bye.

Contributors and Content Editors

Minal, Nancyvarkey, PoojaMoolya, Pratik kamble, Sandhya.np14