Python Encyclopedia for Academics
  • Course Outline
  • Artificial Intelligence
    • Data Science Foundation
      • Python Programming
        • Introduction and Basics
          • Variables
          • Print Function
          • Input From User
          • Data Types
          • Type Conversion
        • Operators
          • Arithmetic Operators
          • Relational Operators
          • Bitwise Operators
          • Logical Operators
          • Assignment Operators
          • Compound Operators
          • Membership Operators
          • Identity Operators
      • Numpy
        • Vectors, Matrix
        • Operations on Matrix
        • Mean, Variance, and Standard Deviation
        • Reshaping Arrays
        • Transpose and Determinant of Matrix
      • Pandas
        • Series and DataFrames
        • Slicing, Rows, and Columns
        • Operations on DataFrames
        • Different wayes to creat DataFrame
        • Read, Write Operations with CSV files
      • Matplotlib
        • Graph Basics
        • Format Strings in Plots
        • Label Parameters, Legend
        • Bar Chart, Pie Chart, Histogram, and Scatter Plot
  • Machine Learning Algorithms
    • Regression Analysis In ML
      • Regression Analysis in Machine Learning
      • Proof of Linear Regression Formulas
      • Simple Linear Regression Implementation
      • Multiple Linear Regression
      • Advertising Dataset Example
      • Bike Sharing Dataset
      • Wine Quality Dataset
      • Auto MPG Dataset
    • Classification Algorithms in ML
      • Proof of Logistic Regression
      • Simplified Mathematical Proof of SVM
      • Iris Dataset
  • Machine Learning Laboratory
    • Lab 1: Titanic Dataset
      • Predicting Survival on the Titanic with Machine Learning
    • Lab 2: Dow Jones Index Dataset
      • Dow Jones Index Predictions Using Machine Learning
    • Lab 3: Diabetes Dataset
      • Numpy
      • Pandas
      • Matplotlib
      • Simple Linear Regression
      • Simple Non-linear Regression
      • Performance Matrix
      • Preprocessing
      • Naive Bayes Classification
      • K-Nearest Neighbors (KNN) Classification
      • Decision Tree & Random Forest
      • SVM Classifier
      • Logistic Regression
      • Artificial Neural Network
      • K means Clustering
    • Lab 4: MAGIC Gamma Telescope Dataset
      • Classification in ML-MAGIC Gamma Telescope Dataset
    • Lab 5: Seoul Bike Sharing Demand Dataset
      • Regression in ML-Seoul Bike Sharing Demand Dataset
    • Lab 6: Medical Cost Personal Datasets
      • Predict Insurance Costs with Linear Regression in Python
    • Lab 6: Predict The S&P 500 Index With Machine Learning And Python
      • Predict The S&P 500 Index With Machine Learning And Python
  • Artificial Neural Networks
    • Biological Inspiration vs. Artificial Neurons
    • Review linear algebra and calculus essentials for ANNs
    • Activation Function
  • Mathematics
    • Pre-Calculus
      • Factorials
      • Roots of Polynomials
      • Complex Numbers
      • Polar Coordinates
      • Graph of a Function
    • Calculus 1
      • Limit of a Function
      • Derivative of Function
      • Critical Points
      • Indefinite Integrals
  • Calculus 2
    • 3D Coordinates and Vectors
    • Vectors and Vector Operations
    • Lines and Planes in Space (3D)
    • Partial Derivatives
    • Optimization Problems (Maxima/Minima) in Multivariable Functions
    • Gradient Vectors
  • Engineering Mathematics
    • Laplace Transform
  • Electrical & electronics Eng
    • Resistor
      • Series Resistors
      • Parallel Resistors
    • Nodal Analysis
      • Example 1
      • Example 2
    • Transient State
      • RC Circuit Equations in the s-Domain
      • RL Circuit Equations in the s-Domain
      • LC Circuit Equations in the s-Domain
      • Series RLC Circuit with DC Source
  • Computer Networking
    • Fundamental
      • IPv4 Addressing
      • Network Diagnostics
  • Cybersecurity
    • Classical Ciphers
      • Caesar Cipher
      • Affine Cipher
      • Atbash Cipher
      • Vigenère Cipher
      • Gronsfeld Cipher
      • Alberti Cipher
      • Hill Cipher
Powered by GitBook
On this page
  • Example 1
  • Example 2
  • Example 3
  • Example 4
  • Example 5
  • Example 6
  • Keywords
  1. Mathematics
  2. Calculus 1

Limit of a Function

Nerd Cafe

Example 1

  • Limit:

lim⁡x→2(3x+1)\lim_{x \to 2} (3x+1)x→2lim​(3x+1)
  • Solution:

3×(2)+1=73\times (2)+1=73×(2)+1=7
  • Python Code:

from sympy import symbols, limit

x = symbols('x')
expr = 3*x + 1
result = limit(expr, x, 2)
print(result)
  • Output:

7

Example 2

  • Limit:

lim⁡x→0sin(x)x\lim_{x \to 0} \frac{sin(x)}{x}x→0lim​xsin(x)​
  • Solution: Using Taylor Series

Use the Taylor expansion of sin(x) around 0:

sin(x)=x−x33!+x55!−...sin(x)=x-\frac{x^{3}}{3!}+\frac{x^{5}}{5!}-...sin(x)=x−3!x3​+5!x5​−...

So:

sin(x)x=x−x33!+x55!−...x=1−x26+x4120−...\frac{sin(x)}{x}=\frac{x-\frac{x^{3}}{3!}+\frac{x^{5}}{5!}-...}{x}=1-\frac{x^{2}}{6}+\frac{x^{4}}{120}-...xsin(x)​=xx−3!x3​+5!x5​−...​=1−6x2​+120x4​−...

Now take the limit:

lim⁡x→0(1−x26+x4120−...)=1\lim_{x \to 0} \left( 1-\frac{x^{2}}{6}+\frac{x^{4}}{120}-... \right)=1x→0lim​(1−6x2​+120x4​−...)=1
  • Python Code:

from sympy import sin

expr = sin(x)/x
result = limit(expr, x, 0)
print(result)
  • Output:

1

Example 3

  • Limit:

lim⁡x→1x2−1x−1\lim_{x \to 1} \frac{x^{2}-1}{x-1}x→1lim​x−1x2−1​
  • Solution: Factor numerator:

x2−1x−1=(x−1)(x+1)x−1=x+1⇒lim⁡x→1(x+1)=2\frac{x^{2}-1}{x-1}=\frac{(x-1)(x+1)}{x-1}=x+1\Rightarrow \lim_{x \to 1} (x+1)=2x−1x2−1​=x−1(x−1)(x+1)​=x+1⇒x→1lim​(x+1)=2
  • Python Code:

expr = (x**2 - 1)/(x - 1)
result = limit(expr, x, 1)
print(result)
  • Output:

2

Example 4

  • Limit:

lim⁡x→01−cos(x)x2\lim_{x \to 0} \frac{1-cos(x)}{x^{2}}x→0lim​x21−cos(x)​
  • Solution: This is a known standard limit:

Expand cos⁡(𝑥) using Taylor series:

cos(x)=1−x22!+x44!−...cos(x)=1-\frac{x^{2}}{2!}+\frac{x^{4}}{4!}-...cos(x)=1−2!x2​+4!x4​−...

So:

1−cos(x)=1−(1−x22!+x44!−...)=x22!−x44!+...1-cos(x)=1-\left( 1-\frac{x^{2}}{2!}+\frac{x^{4}}{4!}-... \right)=\frac{x^{2}}{2!}-\frac{x^{4}}{4!}+...1−cos(x)=1−(1−2!x2​+4!x4​−...)=2!x2​−4!x4​+...

Substitute into the limit:

lim⁡x→0(1−cos(x)x2)=lim⁡x→0(x22!−x44!+...x2)\lim_{x \to 0} \left( \frac{1-cos(x)}{x^{2}} \right)=\lim_{x \to 0} \left( \frac{\frac{x^{2}}{2!}-\frac{x^{4}}{4!}+...}{x^{2}} \right)x→0lim​(x21−cos(x)​)=x→0lim​(x22!x2​−4!x4​+...​)

Simplify the expression:

lim⁡x→0(12!−x24!+...)=12\lim_{x \to 0} \left( \frac{1}{2!}-\frac{x^{2}}{4!}+... \right)=\frac{1}{2}x→0lim​(2!1​−4!x2​+...)=21​
  • Python Code:

from sympy import cos

expr = (1 - cos(x))/x**2
result = limit(expr, x, 0)
print(result)
  • Output:

1/2

Example 5

  • Limit:

lim⁡x→∞5x2+52x2+7\lim_{x \to \infty } \frac{5x^{2}+5}{2x^{2}+7}x→∞lim​2x2+75x2+5​
  • Solution:

lim⁡x→∞5x2+52x2+7=lim⁡x→∞5+5x22+7x2=52\lim_{x \to \infty } \frac{5x^{2}+5}{2x^{2}+7}=\lim_{x \to \infty } \frac{5+\frac{5}{x^{2}}}{2+\frac{7}{x^{2}}}=\frac{5}{2}x→∞lim​2x2+75x2+5​=x→∞lim​2+x27​5+x25​​=25​
  • Python Code:

from sympy import oo

expr = (5*x**2 + 3)/(2*x**2 + 7)
result = limit(expr, x, oo)
print(result)
  • Output

5/2

Example 6

  • Limit:

lim⁡x→0x∣x∣\lim_{x \to 0} \frac{x}{\left| x \right|}x→0lim​∣x∣x​
  • Solution:

    • From left: −1

    • From right: 1

    • Left ≠ Right → Limit does not exist

  • Python Code:

from sympy import Abs

expr = x / Abs(x)
left_limit = limit(expr, x, 0, dir='-')
right_limit = limit(expr, x, 0, dir='+')
print(f"Left: {left_limit}, Right: {right_limit}")
  • Output

Left: -1, Right: 1

Keywords

limit, calculus, trigonometric limits, Taylor series, squeeze theorem, sin(x)/x, fundamental limit, L'Hôpital's rule, limit definition, mathematical proof, nerd cafe

PreviousCalculus 1NextDerivative of Function

Last updated 2 months ago