Blog

Make Tournament Winning DFS Lineups by Applying Optimization Problems (MLB) – Calculus in the Real World

As a math tutor, people have always asked me: how is calculus used in real life? There are many examples of calculus in the real world, and statistics in the real world too. These applications can be found in all kinds of industries, and overlapping with other sciences. However, there is one field that has always interested me most: sports.

I have always been fascinated by people using statistics and math to predict the outcome of sporting events. Or even to evaluate the performance of players, their impact on the outcome of the game, and their value to their team. However, I do not work in the sports world. I do not need to inform decisions about what players Billy Bean wanted to sign, or how big of a contract the Atlanta Braves should offer their 1st baseman with a career .859 OPS and a .234 strike out rate.

But what I can do is play fantasy sports. I can investigate how to construct the best possible lineup in a Daily Fantasy Sports (DFS) slate on FanDuel, and actually use the knowledge I gain from that investigation. So that’s what I have decided to do.

We will build the best FanDuel MLB lineup optimizer. Since we will be building it from scratch, we should have the best free DFS lineup optimizer on the internet by the time we’re done with this. I invite you to join me on this journey, and we’ll see what we can learn together. Let’s get started!

Keep in mind, I will be showing you investigative techniques that you could apply to DraftKings as well. Due to slight scoring or lineup differences between FanDuel and DraftKings, you may need to adjust our model a bit. However, the overall ideas should be the same.

Disclaimer: Nothing in this article, or any other content on this site or my YouTube channel should be interpreted as financial or gambling advise. This content is all created for educational and entertainment purposes. We will be investigating how to evaluate DFS MLB lineups mathematically in order to maximize the chances of winning a large tournament on FanDuel. If you decide to use these methods to create your own lineups and enter them in paid contests, please be smart, be safe, and only play with money you can afford to lose. There are no guarantees here.

Want to Play Along?

If you want to play along and enter some FanDuel lineups of your own as we conduct this investigation, you can use my FanDuel referral link here to get a deposit bonus. You should just need to deposit at least $15 within 30 days of signing up, and you’ll get a$15 bonus added to your account if you use that link. Can’t complain about some free money, right?

Background Research

Let’s start with the basic strategy we will investigate, and hopefully build on. Perhaps the most popular strategy in large tournaments on DFS is lineup stacking. This is a popular strategy in MLB DFS, but also in other sports. The idea is that we select multiple players from the same team to put in our lineup. If, for example, the New York Yankees blow out the Chicago Cubs by a final score of 8-1, there were likely a few Yankees with exceptional fantasy performances that day. Even better than that, many point producing events throughout the game would have most likely been double counted in your lineup, if you had multiple Yankees.

Sticking with the prior example, let’s say you have Aaron Judge and Giancarlo Stanton batting 3rd and 4th respectively, for the Yankees. You put both of them in your lineup. In the 3rd inning, Aaron Judge hits a double, getting you some points. Then Giancarlo Stanton comes up and hits a 2-run homer. You would get the points for 1 run for Judge scoring, and the HR, 1 run, and 2 RBI for Stanton’s swing of the bat. As you could imagine, this effect is compounded even more if you have 3 or 4 players lined up from the same team. If they start stringing hits together, that’s a lot of double counted points.

What players should you stack? What teams should you pick to stack from?

I found an article that addresses a few of these questions. I’ll summarize the main points I decided to start testing out, but if you want to see the full explanation of these strategies, you can see that article here.

There are 3 main ideas shown in that article that I decided to start building lineups around:

1. We should target batters matching up against the pitchers with the lowest salaries on FanDuel. Lower salary implies it’s a worse pitcher, and will likely give up more fantasy points to opposing batters.
2. We should target players batting as close to the top of the lineup as possible. Also when we stack players from the same team, they should be as close to each other in the lineup as possible.
3. It is common for multiple players on the same team to be in the top 20 of all players in any given slate, and not uncommon at all for multiple teammates to be top 10, or top 5.

You can check out the article linked above for more details, but point #3 essentially just validates that stacking 2-4 players from the same team is a valid strategy. This is especially true when you enter a large tournament where you need your lineup to be in about the top 25th percentile just to finish in the money.

Points #1 and #2 though, tell us a bit about which teams to stack players from, and which players in the lineup we want.

Turning Our Strategy into an Optimization Problem

This is where the calculus comes into play. We won’t be solving any optimization problems here, or doing calculus. However, I do think it helps in the setup if you have at least a basic understanding of how to set up and solve a calculus based optimization problem. If you want a lesson on those, you can find that here.

Otherwise, let’s get into what I started with. When we sit down to set our lineup, we have something like this.

We need to fill our lineup (on the right) with the 9 players we think will score as many points as possible, from the available players shown (on the left). Each of them has a salary associated with them, and the sum of the 9 players’ salaries we choose needs to be below $35,000. Don’t worry, you don’t have to actually spend 35,000 real dollars to fill your lineup. Think of that as game money. It’s just a way for the players we choose to have some limitation on it. It prevents us from just choosing the best player in each position across the board. All an optimization problem is, is one equation that we are trying to maximize (or minimize), and one or more restriction equations that limit our variables somehow. Well, it just so happens that’s all a FanDuel lineup is. Think about it. We have one thing that we are trying to make as big as possible: fantasy points scored. And we have several restrictions addressing what our lineup is allowed to be: • We need 9 exactly players in total. • Total team salary less than or equal to$35,000.
• Exactly 1 Pitcher (P).
• At least 1 Catcher or 1st Baseman (C/1B).
• At least 1 2nd Baseman (2B).
• At least 1 3rd Baseman (3B).
• At least 1 Short Stop (SS).
• At least 3 Outfielders (OF).

This means, we need a lineup consisting of: P, C/1B, 2B, 3B, SS, OF, OF, OF, and UTIL. “UTIL” stands for utility and this position can be a C, 1B, 2B, 3B, SS, or OF. Basically, anything except a second Pitcher.

If we create a several variable optimization problem from this, using the one equation to optimize (sum of projected fantasy points), and the several restriction equations, we would at least be able to create legal lineups that we expect to do as well as possible.

However, we want to do better than that. Keep in mind there is always going to be variations in how many points players actually get. And sometimes, it’s not very close to their projected points. So, we want to use some of the stacking strategies I mentioned earlier to take advantage of those variations and give us a decent chance at having our lineup in the top 25th percentile. And it’s even better if we can be in the top 10%, 5%, 1%, or even the top lineup in our contest.

If we don’t take advantage of the stacking strategies, it’s less likely for many players in our lineup to do really well, or really poorly, on the same day. We want to create a boom or bust situation. This is because one big “boom” lineup can cover the cost of several “bust” lineups. Plus, a “middle of the road” lineup is just as useful as a bust.

It’s not…

They’re both worth $0.00. Here Is Why I’m sure by now, you are wondering why I have assumed that a “boom or bust” strategy is our best option. Let me elaborate. Below is an image showing the results of a large tournament style contest. The gray and green bar represents all 3,217 lineups that were entered into the tournament. The green section shows the lineups that finished “in the money” and the gray is all the people that lost their$2.22 buy in. The blue figure shows where this lineup finished in there, 1,776th place of the 3,217 entries.

This lineup actually finished in the top half of this tournament, slightly better than “middle of the road.” But not high enough. The $2.22 entry fee was lost because we needed a bit more “boom” in the lineup. Might as well have been a “bust.” This is what we need to shoot for when only the top 23.3% of lineups win anything. I know it’s not shown in the image, but the top 750 lineups got money back in this tournament, and the 750th place finish got$5 from their $2.22 entry fee. The top 10 lineups collectively won$1,295 of the total $6,000 in prizes for the whole contest. And the top 1 lineup won$500.

Who is this book not helpful for?

Although this casual approach can be great for someone learning the basic concepts on which calculus is built, this could be a negative for a math major who will need to go more in depth or someone trying to develop a deeper understanding of the theory or thought behind the math.  If you are interested in proofs and understanding how calculus was derived, this probably is not the book for you.

Another downside of this book is that it does not contain collections of problems at the end of each chapter.  It is not packed full of practice problems for you to practice the concepts discussed in the chapters.  There are certainly problems that are solved by Banner throughout the book, but there is not a ton of problems that you would be able to do on your own.  It is more of an explanation of the concepts you need to know as well as an explanation of how to apply them.  Then you would be left on your own to find problems that you can get some practice with.  It does fantastic job at breaking down all the tools you need to know to excel at calculus and how to apply them, then sends you on your way to go get the repletion you need elsewhere.

Fortunately, there are other options out there to get the list of practice problems.  One option could be to look in the required textbook for your course if you are enrolled in one.  If you are not taking a calculus class though, there are other books that you can get that are just books of practice problems.  If you pair one of those with The Calculus Lifesaver, you should be set to make sure you know the concepts you need and get the practice to really get it down solid.

Who is this book perfect for?

Like I mentioned before, Banner takes a very casual approach in this text.  He does not focus on the technical mathematical terminology that most textbooks focus on much more.  This fact is certainly a positive for someone learning calculus for the first time.  If math is not your major and you are taking a calculus class for general requirements this could be the perfect book for you.  It’s the perfect bridge to get you from being new to calculus to understanding the complex explanations in the textbook you may have already had to buy.

For example, at one point in this book, Banner writes, “perhaps you’d like to say that f(2)=1, but that would be a load of bull since 2 isn’t even in the domain of f.”  This is just one example that illustrates the casual approach Banner takes in The Calculus Lifesaver.  And there are many more.

And I am not trying to say that the technical terminology in math is not important.  I think it certainly is.  But it is usually helpful to understand the concepts before trying to build on that with a more in depth understanding of the language and terminology.  When you are learning about a brand-new topic in math, it can be easy to get distracted with the terms.  And this can prevent you from putting more focus on the general concepts that you are trying to understand.  This may make you feel like you don’t understand the concepts you are trying to learn, when in reality you would understand the concepts it they were explained in terms you already understand.

This pickle is completely avoided thanks to the casual approach in The Calculus Lifesaver.  Banner ensures that the language is simple and straight forward so you can easily understand the thinking behind the actual math.  It is done brilliantly.

What topics are covered in The Calculus Lifesaver by Adrian Banner?

The Calculus Lifesaver covers topics that you need to know in calculus 1, 2, and 3.  You know you will really be able to get some longevity out of this book if you need to take multiple calculus classes.  It’s always great when you can buy one book that can be used to help you through multiple courses.  This is not a comprehensive list, but some of the main important topics covered by Banner in this book are:

• Functions and review of prerequisite material
• Limits and techniques for evaluating them
• Continuity
• Derivatives and different methods to find them
• Optimization and linear approximation
• Implicit differentiation and related rates problems
• Definite and indefinite integrals and how to find them
• The Fundamental Theorem of Calculus (FTC)
• Improper integrals
• Basic concepts of sequences and series
• Taylor Polynomials, Taylor Series, and Power Series
• Polar coordinates and how they relate to topics of calculus
• Volumes, arc length, and surface area
• Differential equations

Final Recommendations

I strongly recommend this book for anyone that is a non-math major taking calculus classes because they need to for their major.  I would also recommend this book for any high school students taking AP Calculus AB or BC or taking IB Math SL or HL.  It may be more applicable for an IB Math HL student than SL, but it would certainly be helpful for both.  I think this book would also be immensely helpful for someone who is trying to learn calculus without having enrolled in a high school or college calculus class.  The casual approach is perfect for anyone that is trying to get a grip on the basic concepts taught in calculus and how to apply them.  Click here to go get yourself a copy of The Calculus Lifesaver.

However, if you are a math major or are interested in learning more about the ideas behind calculus or proving the concepts that make up calculus, this may not be the book for you.  This is certainly not a proof-based resource and does not contain a ton of practice problems.  So if you are looking to really dive deep into calculus, you may want to consider Calculus by Michael Spivak, which would be my personal recommendation for a proof-based approach to calculus.

Some links contained in this post are affiliate links, meaning I would get a small commission for your purchase at no additional cost to you.

How to Find the Integral of e^x+x^e

$$\int e^x + x^e \ dx$$

Finding the integral of $$\mathbf{f(x)=e^x+x^e}$$ can be tricky at first glance. I’m sure you’re probably familiar with how to take the integral of the $$\mathbf{e^x}$$ part of it. In general, you’ll just want to remember that $$\int e^x \ dx = e^x$$

However, the $$\mathbf{x^e}$$ piece looks a little weird. At first glance it may even look completely foreign. What have you seen that looks like this piece of the function?

Let’s think about what’s going on here

If we look back at our original integral, you’ll want to notice the dx at the end of it. Remember we had $$\int e^x + x^e \ dx$$

The dx is important because it indicates what letter is our variable that we will be integrating with respect to. Since it’s dx, that means we will be integrating with respect to x. Therefore, e will need to be treated as a constant.

In fact, e is a known constant with a specific value. It’s kind of like $$\mathbf{\pi}$$. We know that $$\mathbf{e \approx 2.71}$$. So when we are trying to integrate the $$\mathbf{x^e}$$ part of this function, what we are integrating just comes down to “a variable raised up to a constant power.”

When you are trying to integrate x raised up to some constant power, you would want to use the power rule. The power rule for integrating tells us that if n is some constant other than n = -1, then $$\int{x^n} \ dx \ = \ \frac{x^{n+1}}{n+1} \ = \ \frac{1}{n+1} \cdot x^{n+1}$$

So since e is a constant, we can basically just replace the n in the above formula with e to find the integral of $$\mathbf{x^e}$$. Using this, we can see that $$\int{x^e} \ dx \ = \ \frac{x^{e+1}}{e+1} \ = \ \frac{1}{e+1} \cdot x^{e+1}$$

Putting these integrals together

Now that we have figured out how to integrate the $$\mathbf{x^e}$$ part of our function, let’s go back to the original integral. As we do this, let’s also think about one of the basic integral properties. Specifically, the one that tells us what to do about integrating a function that is a sum of two simpler functions. $$\int f(x)+g(x) \ dx \ = \int f(x) \ dx + \int g(x) \ dx$$

So as a result of this, we can break down our problem into two simpler integrals that we already know. $$\int e^x + x^e \ dx \ = \int e^x \ dx + \int x^e \ dx$$

And since we already found both of these integrals earlier, we know $$\int e^x + x^e \ dx \ = \ e^x + \frac{x^{e+1}}{e+1} + C$$

Linear Approximation (Linearization) and Differentials

Linear approximation, sometimes called linearization, is one of the more useful applications of tangent line equations. We can use linear approximations to estimate the value of more complex functions. Coming up with a linear function that closely approximates another function at a certain point gives you something that is a lot easier to work with than the original function.

How to find a linear approximation at a point

To find the linear approximation of a function at a point, you can simply use the formula for the linearization of a function. Let’s say you are given a function $$f(x)=x^3+2x$$ and you want to find its liner approximation at the point $$\mathbf{a=-2}$$. You can do this by applying the formula

$$L(x)=f(a)+f'(a)(x-a).$$

The first step is to find the derivative of f(x). In this case we can find f'(x) by using the power rule.

$$f'(x)=3x^2+2$$

Now that you know f(x), f'(x), and the value of a, you can plug all of this into the linearization formula above to find the linear approximation of f(x) near x=a.

$$L(x)=f(a)+f'(a)(x-a)$$ $$L(x)=\big( (-2)^3+2(-2) \big)+ \big( 3(-2)^2+2 \big) \big( x-(-2) \big)$$ $$L(x)=\big( -12 \big)+ \big( 14 \big) \big( x+2 \big)$$ $$L(x)=-12 + 14x+28$$ $$L(x)=14x+16$$

Useful Applications of Linear Approximation

At this point you’re probably thinking, “this is just finding tangent line equations, who cares?”

But this does have some useful applications. One such application is using linear approximation to estimate the value of numbers that would be difficult or impossible to find without a calculator.

Let me show you what I mean by that.

Example

Find the linearization of $$\mathbf{f(x)=\sqrt{x+1}}$$ at a=0 and use it to approximate $$\mathbf{f(x)=\sqrt{0.9}}$$.

Finding $$\mathbf{f(x)=\sqrt{0.9}}$$ would be difficult without a calculator, right? But with linear approximation we can get pretty close by applying the process above and taking it a step further pretty easily.

We already have been given f(x) and the a value we need, so you just need to find f'(x) to apply our linearization formula.

$$f(x)=\sqrt{x+1}$$ $$f(x)=(x+1)^{\frac{1}{2}}$$

Writing f(x) in this form, we can simply apply the power rule and chain rule to find f'(x).

$$f'(x)=\frac{1}{2}(x+1)^{-\frac{1}{2}}$$ $$f'(x)=\frac{1}{2\sqrt{x+1}}$$

Now that we know f'(x), let’s first use that and f(x) to calculate f(a) and f'(a) before applying all of this to the linearization formula. Remember we were given a=0.

$$f(x) = \sqrt{x+1}$$ $$f(0)=\sqrt{0+1}$$ $$f(0)=\sqrt{1}$$ $$f(0)=1$$

And now you can find f'(a), or f'(0).

$$f'(x)=\frac{1}{2\sqrt{x+1}}$$ $$f'(0)=\frac{1}{2\sqrt{0+1}}$$ $$f'(0)=\frac{1}{2\sqrt{1}}$$ $$f'(0)=\frac{1}{2}$$

Now we can plug all of this into our linearization formula.

$$L(x)=f(0)+f'(0)(x-0)$$ $$L(x)=1+\frac{1}{2}x$$

How do you use this to estimate a number?

So we know that the function $$L(x)=1+\frac{1}{2}x$$ is a good estimate of $$f(x)=\sqrt{x+1}$$ when we plug in numbers close to a=0 for x. And if we plug x=0 into f(x), that would give us $$f(0)=\sqrt{0+1}=\sqrt{1}$$ which is close to the number we are trying to estimate, $$f(x)=\sqrt{0.9}$$.

In reality, we could find the exact value of $$\sqrt{0.9}$$ by evaluating $$f(-0.1)=\sqrt{-0.1+1}=\sqrt{0.9}$$. But this is difficult, so instead we can use our linear approximation because we know it’s close to f(x) for x values near x=0. So instead of finding f(-0.1) we can find L(-0.1) and that will give us a good estimate.

$$L(-0.1)=1+\frac{1}{2}(-0.1)$$ $$L(-0.1)=1+(0.5)(-0.1)$$ $$L(-0.1)=1-0.05$$ $$L(-0.1)=0.95$$

So this tells us that $$\sqrt{0.9} \approx 0.95$$.

What if you aren’t given a function f(x) or an x=a value to use?

This seems nice to be able to estimate complicated values using this technique, but what if you need to estimate a complex value and aren’t given a function to use. Sometimes you aren’t given a function. And if you were trying to use this technique in the real world you probably wouldn’t be given a nice function to use and an a value that’s close to the input you need to estimate.

So how do you deal with this?

Well, the short answer is that you need to come up with the function and the a value on your own. Then once you have these you can apply the same technique above. Let me show you what I mean.

Let’s say you are told:

Use linear approximation to estimate $$\sqrt{24}$$.

The first thing you want to do is come up with the function to use to apply the linearization formula to. Since we are trying to find $$\sqrt{24}$$, our function is clearly going to need a square root in it somewhere. It is possible that you may need to experiment a bit and see how it works out, so let’s just start with the most obvious choice for now and say $$f(x)=\sqrt{x}$$.

If we do say $$f(x)=\sqrt{x}$$ then we can see that $$f(24)=\sqrt{24}$$ which is exactly the number that we are trying to estimate. But f(24) is hard to evaluate. So to find the a value we will want to use, you should consider what number is near 24 that we could plug into the function $$f(x)=\sqrt{x}$$ and easily figure out the result?

The closest number to 24 that we can easily plug into our function would be 25. Because 25 is a perfect square, we know that $$f(25)=\sqrt{25}=5$$, which is a nice round number. This is perfect for linear approximation because we need an input that is near the location we are trying to estimate whose output we know.

Since 25 is near 24 and we know the exact value of f(25), we can find the linear approximation of $$f(x)=\sqrt{x}$$ at a=25 and use this to estimate $$f(24)=\sqrt{24}$$ just like we did in the example above.

I’m not going to work this all the way through because it will be the exact same process as the last example now that we know $$f(x)=\sqrt{x}$$ and a=25. You can also see the rest of the solution to this problem in the video above.

Differentials and how to find dy

Differentials go hand-in-hand with linear approximation and they have some interesting applications of their own.

Given some function f(x), you can find its differential, dy, simply by using the following formula.

$$dy=f'(x) \ dx$$

For example, say you are given the function $$y=e^{\frac{x}{10}}$$ and you are told to find the differential dy. All you need to do is apply the above formula.

You know that $$f(x)=e^{\frac{x}{10}}$$ Therefore, you can apply the chain rule to find $$f'(x)=e^{\frac{x}{10}} \cdot \frac{1}{10}$$ $$f'(x)=\frac{1}{10}e^{\frac{x}{10}}$$

So as a result, we know that

$$dy=\frac{1}{10}e^{\frac{x}{10}} \ dx$$

Application of Differentials: Estimating Error

Estimating error is one of the more common uses for differentials. This can then be used to find the percentage error of a measurement. Let me explain what this means with an example.

Let’s say you measure a sphere to have a radius of 5 m. However, you know that the instrument you used to measure the radius of this sphere could have up to 5 cm (or 0.05 m) of error. Use differentials to estimate the maximum error in the measured volume of this sphere.

Knowing the the volume of a sphere is $$V=\frac{4}{3}\pi r^3$$ we will use this as our function. We will be able to use the differential of this function to estimate the maximum possible error in the measured volume of this sphere based on the maximum possible error in the radius. We already know the possible error in the radius, so we can use this and relate it to the volume.

First all we need to do is find the differential of our volume equation. This will require taking the derivative of $$\mathbf{V=\frac{4}{3}\pi r^3}$$. Using the formula of a differential as stated in the previous section, the differential is

$$dV=4 \pi r^2 \ dr$$

Then with this, all you need to do is plug in the information we know to find the possible error in the volume. Keep in mind, r represents the radius of the sphere that we know to be 5 m. And dr will represent the possible error in the radius, which we know to be 0.05 m. It’s important that we use the same units for all of these inputs since the output will use the same units in that case.

$$dV=4 \pi (5m)^2(0.05m)$$ $$dV=5 \pi m^3$$

So we know that the maximum error in the measurement we have for the volume of this sphere is $$\mathbf{5 \pi m^3\approx 15.708m^3}$$.

Percentage Error

Once we find the maximum possible error as outlined above, we can use this to find the percentage error of our measurement. This is simply the maximum possible error in the measurement divided by the measurement itself. So in this case it would be

$$Percentage \ Error = \frac{error \ in \ volume}{volume}.$$

$$Percentage \ Error = \frac{5 \pi}{\frac{500}{3}\pi} = 3\%$$

Limits to Infinity

Limits as x approaches infinity can be tricky to think about. This is because infinity is not a number that x can ever be equal to. To evaluate a limit as x goes to infinity, we cannot just simply plug infinity in for x and see what we get. As a result, things like $$\mathbf{e^{\infty}}$$ and $$\mathbf{\frac{1}{\infty}}$$ don’t actually have a value.

So how can we deal with infinity?

Although infinity doesn’t have a specific value and can’t be plugged into functions, we can think about what will happen to a given function as x approaches infinity.

All this really means is that x is continually getting infinitely large. And as x gets bigger and bigger and bigger, what y value will our function get closer and closer to?

Let’s look at a few common examples and what they mean.

One Divided by Infinity

Like I said before, infinity is not a value. Therefore, $$\frac{1}{\infty}$$ isn’t an actual number and doesn’t have a value. However, what we want to think about is what y value 1/x will approach as x goes to infinity. This is exactly what is being asked when we see: $$\lim_{x \to \infty} \frac{1}{x}$$

So let’s think about what happens to 1/x when we plug in bigger and bigger numbers for x.

So you can see in the table above that as x gets bigger and bigger, 1/x gets closer and closer to 0. Or in other words,

as x approaches infinity, 1/x approaches 0

We would write this mathematically as: $$\lim_{x \to \infty} \frac{1}{x} = 0$$

We can also see this graphically using Mathway. Notice in the graph below that as the x value goes toward infinity, you can see the y value getting closer to the y-axis (y=0).

Limits Going to Infinity

The other common example I mentioned is the limit as x goes to infinity of $$\mathbf{e^x}$$. Or $$\lim_{x \to \infty} e^x$$

Again, it doesn’t really make sense to say that we can just plug infinity in for x and get $$\mathbf{e^{\infty}}$$. This doesn’t actually have a value. This isn’t a number. Instead, we want to think about what y value $$\mathbf{e^x}$$ goes toward as x goes to infinity. So let’s look at what happens as we raise e to a larger and larger power.

So we can see here that $$\mathbf{e^x}$$ starts giving us very large numbers quite quickly. And as we continue to plug in larger values for x, $$\mathbf{e^x}$$ will continue to get bigger and bigger and bigger.

as x approaches infinity, $$\mathbf{e^x}$$ approaches infinity

We would write this mathematically as: $$\lim_{x \to \infty} e^x = \infty$$

Rational Functions

Finding the limit as x approaches infinity of rational functions is a common limit you will run into. This is important because this is how you find horizontal asymptotes of rational functions. You are just looking to see what y value your function will get really close to (without touching that value) as your x goes to infinity.

What is a rational function?

A rational function is a function that is a fraction where the top and bottom of the fraction are polynomials. Basically this just means that the numerator and denominator of the fraction will be a sum of a handful of terms that are a constant times x raised up to some power. So it will look like this: $$f(x)=\frac{a_nx^n + a_{n-1}x^{n-1} + … + a_2x^2 + a_1x + a_0}{b_mx^m + b_{m-1}x^{m-1} + … + b_2x^2 + b_1x + b_0}$$

How do you take the limit of a rational function?

There are really only 3 cases you need to consider and the video above discusses these three cases as well. Any rational function will fall into one of these three categories, and each limit within each category will work out the same.

All you need to do is look at the degree of the polynomial on the top and bottom of the fraction. The degree of a polynomial is the highest power that x is being raised to. So for example, $$\mathbf{y=-4x^5+6x^2+x-12}$$ is a polynomial of degree 5, because the highest power of x is 5.

Case 1: Degree of numerator is larger than degree of denominator

If the degree of the numerator is higher than the degree of the polynomial on the denominator, then the limit will go to infinity or negative infinity. This will only depend on the sign of the coefficient of the highest power x term on the numerator.

If Degree(P(x)) > Degree(Q(x)), then $$\mathbf{\lim\limits_{x \to \infty} \frac{P(x)}{Q(x)}= \pm \infty}$$

Example:

$$\lim_{x \to \infty} \frac{x^4-3x^2+x}{x^3-x+2}$$ $$=\lim_{x \to \infty} \frac{x^4-3x^2+x}{x^3-x+2} \cdot \frac{\frac{1}{x^3}}{\frac{1}{x^3}}$$ $$=\lim_{x \to \infty} \frac{\frac{x^4}{x^3}-\frac{3x^2}{x^3}+\frac{x}{x^3}}{\frac{x^3}{x^3}-\frac{x}{x^3}+\frac{2}{x^3}}$$ $$=\lim_{x \to \infty} \frac{x-\frac{3}{x}+\frac{1}{x^2}}{1-\frac{1}{x^2}+\frac{2}{x^3}}$$ $$= \frac{\lim\limits_{x \to \infty}x-\lim\limits_{x \to \infty}\frac{3}{x}+\lim\limits_{x \to \infty}\frac{1}{x^2}}{\lim\limits_{x \to \infty}1-\lim\limits_{x \to \infty}\frac{1}{x^2}+\lim\limits_{x \to \infty}\frac{2}{x^3}}$$ $$= \frac{\lim\limits_{x \to \infty}x-0+0}{1-0+0}$$ $$=\frac{\lim\limits_{x \to \infty}x}{1}$$ $$=\lim_{x \to \infty}x$$ $$=\infty$$

Case 2: Degree of numerator is smaller than degree of denominator

If the degree of the numerator is smaller than the degree of the denominator then the limit will go to 0.

If Degree(P(x)) < Degree(Q(x)), then $$\mathbf{\lim\limits_{x \to \infty} \frac{P(x)}{Q(x)}= 0}$$

Example:

$$\lim_{x \to \infty} \frac{16x^4}{0.0001x^5+18x}$$ $$=\lim_{x \to \infty} \frac{16x^4}{0.0001x^5+18x} \cdot \frac{\frac{1}{x^5}}{\frac{1}{x^5}}$$ $$=\lim_{x \to \infty} \frac{\frac{16x^4}{x^5}}{\frac{0.0001x^5}{x^5}+\frac{18x}{x^5}}$$ $$=\lim_{x \to \infty} \frac{\frac{16}{x}}{0.0001+\frac{18}{x^4}}$$ $$= \frac{\lim\limits_{x \to \infty}\frac{16}{x}}{\lim\limits_{x \to \infty}0.0001+\lim\limits_{x \to \infty}\frac{18}{x^4}}$$ $$= \frac{0}{0.0001+0}$$ $$=0$$

Case 3: Degree of numerator is equal to degree of denominator

If the degree of the numerator is equal to the degree of the denominator then the limit will be equal to the coefficient of the highest power x term in the numerator divided by the coefficient of the highest power x term in the denominator.

If Degree(P(x)) = Degree(Q(x)), then $$\mathbf{\lim\limits_{x \to \infty} \frac{P(x)}{Q(x)}= \frac{a}{b}} \$$ where a is the coefficient of the highest power x term in P(x), and b is the coefficient of the highest power x term in Q(x).

$$\lim_{x \to \infty} \frac{x^2+7}{-3x^2}$$ $$=\lim_{x \to \infty} \frac{x^2+7}{-3x^2} \cdot \frac{\frac{1}{x^2}}{\frac{1}{x^2}}$$ $$=\lim_{x \to \infty} \frac{\frac{x^2}{x^2} + \frac{7}{x^2}}{\frac{-3x^2}{x^2}}$$ $$=\lim_{x \to \infty} \frac{1 + \frac{7}{x^2}}{-3}$$ $$= \frac{\lim\limits_{x \to \infty}1 + \lim\limits_{x \to \infty}\frac{7}{x^2}}{\lim\limits_{x \to \infty}-3}$$ $$= \frac{1+0}{-3}$$ $$=-\frac{1}{3}$$

Other Examples

$$\mathbf{\lim\limits_{x \to \infty} arctan \big( e^x \big)}$$ | Solution

$$\mathbf{\lim\limits_{x \to \infty} \frac{sin(x)}{x}}$$ | Solution

$$\mathbf{\lim\limits_{x \to \infty} \frac{ln(x)}{\sqrt{x}}}$$ | Solution

Solutions

Example 1 Solution

$$\mathbf{\lim\limits_{x \to \infty} arctan \big( e^x \big)}$$

This is going to be based on the fact that we already discussed above that $$\mathbf{\lim\limits_{x \to \infty} e^x = \infty}$$. Since we know that, we can say that $$\mathbf{y=e^x}$$ and rewrite our limit as: $$\lim_{y \to \infty} arctan(y)$$

This is because y goes to infinity as x goes to infinity since $$\mathbf{y=e^x}$$. Now we can find this limit by looking at a graph of y=arctan(x).

Looking at this graph we can see that y=arctan(x) has a horizontal asymptote at $$\mathbf{y=\frac{\pi}{2}}$$. As x goes toward infinity, you can see that the y value of our function gets closer and close to $$\mathbf{\frac{\pi}{2}}$$. So this tells us $$\lim_{y \to \infty} arctan(y)=\frac{\pi}{2}$$ $$\lim_{x \to \infty} arctan \big( e^x \big)=\frac{\pi}{2}$$

Example 2 Solution

$$\mathbf{\lim\limits_{x \to \infty} \frac{sin(x)}{x}}$$

We know that $$\mathbf{-1 \leq sin(x) \leq 1}$$ for all x. Since we are looking at this limit as x goes to positive infinity, we can also say that $$-\frac{1}{x} \leq \frac{sin(x)}{x} \leq \frac{1}{x}$$

We also know that $$\mathbf{\lim\limits_{x \to \infty} -\frac{1}{x}=0}$$ and that $$\mathbf{\lim\limits_{x \to \infty} \frac{1}{x}=0}$$. Since we know $$\mathbf{\frac{sin(x)}{x}}$$ is between $$\mathbf{-\frac{1}{x}}$$ and $$\mathbf{\frac{1}{x}}$$ we can use Squeeze Theorem to say that $$\lim_{x \to \infty} \frac{sin(x)}{x}=0$$

Example 3 Solution

$$\mathbf{\lim\limits_{x \to \infty} \frac{ln(x)}{\sqrt{x}}}$$

For this limit, we will be able to use L’Hospital’s Rule. This is because ln(x) and $$\mathbf{\sqrt{x}}$$ both go to infinity as x goes to infinity. This gives us an indeterminate form that is a possible application of L’Hospital’s Rule. We can also check to make sure that this meets the other conditions needed to apply L’Hospital’s Rule.

$$\lim_{x \to \infty} \frac{ln(x)}{\sqrt{x}}$$ $$=\lim_{x \to \infty} \frac{\frac{d}{dx}ln(x)}{\frac{d}{dx}\sqrt{x}}$$ $$=\lim_{x \to \infty} \frac{\frac{1}{x}}{\frac{1}{2x^{1/2}}}$$ $$=\lim_{x \to \infty} \frac{1}{x} \cdot \frac{2x^{1/2}}{1}$$ $$=\lim_{x \to \infty} \frac{2}{x^{1/2}}$$ $$=\lim_{x \to \infty} \frac{2}{\sqrt{x}}$$ $$=0$$

Implicit Differentiation Examples

If you haven’t already read about implicit differentiation, you can read more about it here. Once you check that out, we’ll get into a few more examples below.

$$\mathbf{1. \ \ ycos(x) = x^2 + y^2}$$ | Solution

$$\mathbf{2. \ \ xy=x-y}$$ | Solution

$$\mathbf{3. \ \ x^2-4xy+y^2=4}$$ | Solution

$$\mathbf{4. \ \ \sqrt{x+y}=x^4+y^4}$$ | Solution

$$\mathbf{5. \ \ e^{x^2y}=x+y}$$ | Solution

For each of the above equations, we want to find dy/dx by implicit differentiation. In general a problem like this is going to follow the same general outline. Although, this outline won’t apply to every problem where you need to find dy/dx, this is the most common, and generally a good place to start. Start with these steps, and if they don’t get you any closer to finding dy/dx, you can try something else. Here are the steps:

• Take the derivative of both sides of the equation with respect to x.
• Separate all of the dy/dx terms from the non-dy/dx terms.
• Factor out the dy/dx.
• Isolate dy/dx.

Some of these examples will be using product rule and chain rule to find dy/dx.

Solutions

$$\mathbf{1. \ \ ycos(x) = x^2 + y^2}$$

$$ycos(x)=x^2+y^2$$ $$\frac{d}{dx} \big[ ycos(x) \big] = \frac{d}{dx} \big[ x^2 + y^2 \big]$$ $$\frac{dy}{dx}cos(x) + y \big( -sin(x) \big) = 2x + 2y \frac{dy}{dx}$$ $$\frac{dy}{dx}cos(x) – y sin(x) = 2x + 2y \frac{dy}{dx}$$ $$\frac{dy}{dx}cos(x) -2y \frac{dy}{dx} = 2x + ysin(x)$$ $$\frac{dy}{dx} \big[ cos(x) -2y \big] = 2x + ysin(x)$$ $$\frac{dy}{dx} = \frac{2x + ysin(x)}{cos(x) -2y}$$

$$\mathbf{2. \ \ xy=x-y}$$

$$xy = x-y$$ $$\frac{d}{dx} \big[ xy \big] = \frac{d}{dx} \big[ x-y \big]$$ $$1 \cdot y + x \frac{dy}{dx} = 1-\frac{dy}{dx}$$ $$y+x \frac{dy}{dx} = 1 – \frac{dy}{dx}$$ $$x \frac{dy}{dx} + \frac{dy}{dx} = 1-y$$ $$\frac{dy}{dx} \big[ x+1 \big] = 1-y$$ $$\frac{dy}{dx} = \frac{1-y}{x+1}$$

$$\mathbf{3. \ \ x^2-4xy+y^2=4}$$

$$x^2-4xy+y^2=4$$ $$\frac{d}{dx} \big[ x^2-4xy+y^2 \big] = \frac{d}{dx} \big[ 4 \big]$$ $$2x \ – \bigg[ 4x \frac{dy}{dx} + 4y \bigg] + 2y \frac{dy}{dx} = 0$$ $$2x \ – 4x \frac{dy}{dx} – 4y + 2y \frac{dy}{dx} = 0$$ $$-4x\frac{dy}{dx}+2y\frac{dy}{dx}=-2x+4y$$ $$\frac{dy}{dx} \big[ -4x+2y \big] = -2x+4y$$ $$\frac{dy}{dx}=\frac{-2x+4y}{-4x+2y}$$ $$\frac{dy}{dx}=\frac{-x+2y}{-2x+y}$$

$$\mathbf{4. \ \ \sqrt{x+y}=x^4+y^4}$$

$$\sqrt{x+y}=x^4+y^4$$ $$\big( x+y \big)^{\frac{1}{2}}=x^4+y^4$$ $$\frac{d}{dx} \bigg[ \big( x+y \big)^{\frac{1}{2}}\bigg] = \frac{d}{dx}\bigg[x^4+y^4 \bigg]$$ $$\frac{1}{2} \big( x+y \big) ^{-\frac{1}{2}} \bigg( 1+\frac{dy}{dx} \bigg)=4x^3+4y^3\frac{dy}{dx}$$ $$\frac{1}{2} \cdot \frac{1}{\sqrt{x+y}} \cdot \frac{1+\frac{dy}{dx}}{1} = 4x^3+4y^3\frac{dy}{dx}$$ $$\frac{1+\frac{dy}{dx}}{2 \sqrt{x+y}}= 4x^3+4y^3\frac{dy}{dx}$$ $$1+\frac{dy}{dx}= \bigg[ 4x^3+4y^3\frac{dy}{dx} \bigg] \cdot 2 \sqrt{x+y}$$ $$1+\frac{dy}{dx}= 8x^3 \sqrt{x+y} + 8y^3 \frac{dy}{dx} \sqrt{x+y}$$ $$\frac{dy}{dx} \ – \ 8y^3 \frac{dy}{dx} \sqrt{x+y}= 8x^3 \sqrt{x+y} \ – \ 1$$ $$\frac{dy}{dx} \bigg[ 1 \ – \ 8y^3 \sqrt{x+y} \bigg]= 8x^3 \sqrt{x+y} \ – \ 1$$ $$\frac{dy}{dx}= \frac{8x^3 \sqrt{x+y} \ – \ 1}{1 \ – \ 8y^3 \sqrt{x+y}}$$

$$\mathbf{5. \ \ e^{x^2y}=x+y}$$

$$e^{x^2y}=x+y$$ $$\frac{d}{dx} \Big[ e^{x^2y} \Big] = \frac{d}{dx} \big[ x+y \big]$$ $$e^{x^2y} \bigg( 2xy + x^2 \frac{dy}{dx} \bigg) = 1 + \frac{dy}{dx}$$ $$2xye^{x^2y} + x^2e^{x^2y} \frac{dy}{dx} = 1+ \frac{dy}{dx}$$ $$x^2e^{x^2y} \frac{dy}{dx} \ – \ \frac{dy}{dx} = 1 \ – \ 2xye^{x^2y}$$ $$\frac{dy}{dx} \big(x^2e^{x^2y} \ – \ 1 \big) = 1 \ – \ 2xye^{x^2y}$$ $$\frac{dy}{dx} = \frac{1 \ – \ 2xye^{x^2y}}{x^2e^{x^2y} \ – \ 1}$$