Category Archives: Mathematics

Mathematics for Computer Science and Data Science – Sunday Mathematics: #2

Mathematics for Computer Science and Data Science

Why, What, Where, When and How These Concepts Matter

Post #1 on Sunday Mathematics here.

Data Science is much more than learning Python, SQL, or Machine Learning libraries. Mathematics provides the foundation that helps us understand why algorithms work, when to use them, and how to interpret results correctly. The following areas form the mathematical backbone of modern Data Science, AI, Computer Science, and GeoAI.


1. Linear Algebra โ€“ The Language of Data

Why?

Most datasets, images, videos, documents, and neural networks are represented as matrices and vectors.

What?

  • Vectors and matrices
  • Eigenvalues and eigenvectors
  • Matrix decompositions (SVD, QR, LU)
  • Dimensionality reduction (PCA)

Where?

  • Machine Learning
  • Deep Learning
  • Recommendation Systems
  • Computer Vision
  • Search Engines

Example

A photograph is simply a matrix of pixel values. PCA compresses large datasets while retaining important information.


2. Probability and Statistics โ€“ Managing Uncertainty

Why?

Real-world data is noisy and uncertain. Probability helps us quantify uncertainty and make informed decisions.

What?

  • Probability distributions
  • Bayes Theorem
  • Hypothesis testing
  • Confidence intervals
  • Regression models

Where?

  • Risk analysis
  • Medical diagnosis
  • Forecasting
  • Business analytics

Example

When Netflix recommends a movie, it predicts the probability that you will like it.


3. Calculus and Optimization โ€“ Learning from Data

Why?

Machine Learning models learn by minimizing errors.

What?

  • Derivatives and gradients
  • Partial derivatives
  • Gradient Descent
  • Convex optimization
  • Lagrange multipliers

Where?

  • Neural Networks
  • Deep Learning
  • Reinforcement Learning
  • Operations Research

Example

Training a neural network is like repeatedly walking downhill on an error landscape until the lowest error point is reached.


4. Discrete Mathematics โ€“ Logic of Computing

Why?

Computers work using logic, sets, graphs, and discrete structures rather than continuous mathematics.

What?

  • Mathematical logic
  • Set theory
  • Relations and functions
  • Graph theory
  • Combinatorics

Where?

  • Algorithms
  • Databases
  • Cybersecurity
  • Network analysis

Example

Social media friendship networks are graphs where people are nodes and relationships are edges.


5. Time Series Analysis โ€“ Understanding Change Over Time

Why?

Many datasets evolve with time.

What?

  • AR, MA, ARIMA models
  • Autocorrelation
  • Seasonality
  • Fourier Analysis
  • Spectral analysis

Where?

  • Stock markets
  • Weather forecasting
  • IoT sensors
  • Demand prediction

Example

Retail companies forecast future sales using historical sales patterns and seasonal trends.


6. Geospatial Mathematics โ€“ Understanding Location

Why?

Many decisions depend on “where” things happen.

What?

  • Coordinate systems
  • Map projections
  • Spatial interpolation
  • Spatial topology
  • Geodesic calculations

Where?

  • GPS systems
  • Urban planning
  • Agriculture
  • Disaster management
  • GeoAI

Example

Google Maps uses geospatial mathematics to determine shortest routes and travel times.


7. Category Theory โ€“ Mathematics of Abstraction

Why?

As systems become complex, we need higher-level ways to describe relationships and transformations.

What?

  • Objects and morphisms
  • Functors
  • Natural transformations
  • Monoids and monads

Where?

  • Functional programming
  • Distributed systems
  • Data pipelines
  • Advanced AI architectures

Example

Modern software frameworks use composable components that follow principles inspired by category theory.


How Everything Connects

A typical Data Science project uses all these areas:

  1. Linear Algebra stores and transforms data.
  2. Statistics helps understand uncertainty.
  3. Calculus & Optimization train models.
  4. Discrete Mathematics powers algorithms and data structures.
  5. Time Series Analysis handles temporal data.
  6. Geospatial Mathematics adds location intelligence.
  7. Category Theory helps design scalable systems and abstractions.

Final Takeaway

Think of Data Science as building a smart city:

  • Linear Algebra = roads and infrastructure.
  • Statistics = traffic measurements and uncertainty.
  • Calculus = optimization of routes.
  • Discrete Mathematics = traffic rules and network design.
  • Time Series = predicting future traffic.
  • Geospatial Mathematics = maps and navigation.
  • Category Theory = the architectural blueprint connecting everything together.

Together, these mathematical foundations transform raw data into knowledge, predictions, decisions, and intelligent systems.

Brief, practical examples for each major category in the mind map, illustrating how these mathematical concepts are actually used in computer science and data science:

1. Discrete Mathematics

  • Mathematical Logic: Designing the conditional logic (if/else statements) in a software program or optimizing SQL queries.
  • Set Theory and Relations: Managing relational databases, where a database JOIN operation is directly based on the intersection of two sets.
  • Graph Theory: Social network analysis (e.g., how Facebook suggests friends) or GPS navigation apps finding the shortest route using Dijkstra’s algorithm.
  • Combinatorics: Calculating the number of possible password combinations to evaluate cybersecurity strength.

2. Calculus and Optimization

  • Differential Calculus: Gradient Descent in machine learning, which calculates gradients (derivatives) to update weights and minimize error during neural network training.
  • Integral Calculus: Computing the Area Under the ROC Curve (AUC) to measure the performance of a classification model.
  • Mathematical Optimization: Tuning a Support Vector Machine (SVM) classifier to find the optimal hyperplane that separates two classes with the maximum margin.

3. Linear Algebra

  • Vectors and Matrices: Representing an image as a matrix of pixel values so a computer can process it.
  • Eigenvalues and Eigenvectors: Googleโ€™s PageRank algorithm, which uses the dominant eigenvector of a web-link matrix to rank webpages in search results.
  • Matrix Decompositions: Singular Value Decomposition (SVD) used in Netflix-style recommendation systems to uncover latent user preferences.
  • Dimensionality Reduction: Principal Component Analysis (PCA), which shrinks a dataset with 100 features down to 3 key features to make it easier to visualize and train.

4. Probability and Statistics

  • Probability Theory: Naive Bayes Classifiers calculating the probability that an incoming email is “Spam” based on the words it contains.
  • Probability Distributions: Using a Poisson Distribution to model and predict the number of users logging into a server during peak hours.
  • Statistical Inference: Running an A/B Test on a website to see if a blue button yields a statistically significant increase in clicks compared to a red button.
  • Regression Analysis: Using Logistic Regression to predict a binary outcome, such as whether a bank customer will default on a loan (Yes/No).

5. Geospatial Mathematics

  • Coordinate Systems and Projections: Converting raw GPS latitude and longitude coordinates into a flat, 2D map projection in Google Maps.
  • Spherical Geometry: Using the Haversine formula to calculate the actual flight path distance between London and New York over the Earth’s curved surface.
  • Spatial Analysis and Interpolation: Kriging to estimate pollution levels at an unmeasured city block based on data from surrounding air-quality sensors.
  • Topology and Spatial Relations: Defining geofences, such as an app triggering a notification when a delivery driver enters a 1-mile radius buffer around your house.

6. Category Theory

  • Fundamental Structures: Ensuring function composition in code is associative (e.g., making sure f(g(x)) behaves reliably in functional programming languages like Haskell or Scala).
  • Functors and Transformations: Using a .map() function in JavaScript or Python to transform every element inside a list without altering the list’s overall structure.
  • Monads and Monoids: Using a Monad to safely handle “Null” values or side effects (like API calls) without crashing a program or using Monoids in big data frameworks (like MapReduce) to parallelize data aggregation.

7. Time Series Analysis

  • Stochastic Processes: Modeling stock price movements as a Random Walk to simulate future market risks.
  • Time Series Modeling: An ARIMA model predicting next month’s electricity demand based on historical usage patterns over the last 5 years.
  • Frequency Domain Analysis: Using Fourier Transforms to clean audio data by converting the sound wave into frequencies and filtering out background hiss/noise.
  • Evaluation and Decomposition: Splitting retail sales data into its baseline trend, seasonal holiday spikes, and random noise to understand true business growth.

Concept Credit: Neil Harwani

Creation Help: ChatGPT, XMind and Gemini

๐Ÿ“ข Stay informed:

Keywords from Calculus

Comprehensive List of Topics in Calculus:

  1. Limits and Continuity
  2. Limits of Functions
  3. One-Sided Limits
  4. Limit Laws
  5. L’Hรดpital’s Rule
  6. Continuity and Discontinuity
  7. Intermediate Value Theorem
  8. Infinite Limits
  9. Limits at Infinity

Differential Calculus

  1. Derivatives
  2. Rules of Differentiation
  3. Chain Rule
  4. Product Rule
  5. Quotient Rule
  6. Implicit Differentiation
  7. Higher-Order Derivatives
  8. Derivatives of Trigonometric Functions
  9. Derivatives of Exponential Functions
  10. Derivatives of Logarithmic Functions
  11. Derivatives of Hyperbolic Functions
  12. Inverse Function Theorem
  13. Mean Value Theorem
  14. Rolleโ€™s Theorem
  15. Taylor and Maclaurin Series
  16. Linear Approximation
  17. Differential Equations (First-Order)
  18. Newton’s Method
  19. Optimization Problems
  20. Related Rates
  21. Curvature and Radius of Curvature
  22. Concavity and Points of Inflection
  23. Asymptotes and Limits
  24. Critical Points
  25. Maximum and Minimum Values
  26. Applications of Derivatives

Integral Calculus

  1. Antiderivatives
  2. Indefinite Integrals
  3. Definite Integrals
  4. Riemann Sums
  5. Fundamental Theorem of Calculus
  6. Techniques of Integration
  7. Integration by Parts
  8. Partial Fraction Decomposition
  9. Trigonometric Integrals
  10. Trigonometric Substitution
  11. Improper Integrals
  12. Integration by Substitution
  13. Numerical Integration (Simpson’s Rule, Trapezoidal Rule)
  14. Integration of Rational Functions
  15. Gamma and Beta Functions
  16. Area Under Curves
  17. Volume of Solids of Revolution
  18. Arc Length
  19. Surface Area of Revolution
  20. Average Value of a Function
  21. Work and Energy Problems
  22. Center of Mass and Centroids
  23. Moments of Inertia
  24. Probability Density Functions (PDF)
  25. Applications of Integration

Multivariable Calculus

  1. Partial Derivatives
  2. Chain Rule for Partial Derivatives
  3. Directional Derivatives
  4. Gradient Vector
  5. Divergence and Curl
  6. Lagrange Multipliers
  7. Multiple Integrals (Double and Triple Integrals)
  8. Change of Variables (Jacobian)
  9. Cylindrical and Spherical Coordinates
  10. Surface Integrals
  11. Line Integrals
  12. Greenโ€™s Theorem
  13. Stokesโ€™ Theorem
  14. Divergence Theorem
  15. Laplacian and Harmonic Functions
  16. Scalar and Vector Fields
  17. Vector-Valued Functions
  18. Tangent and Normal Vectors
  19. Curvilinear Coordinates
  20. Parametric Surfaces and Curves

Series and Sequences

  1. Convergence and Divergence of Sequences
  2. Series and Partial Sums
  3. Geometric Series
  4. Harmonic Series
  5. Power Series
  6. Taylor Series
  7. Maclaurin Series
  8. Radius and Interval of Convergence
  9. Alternating Series
  10. Absolute and Conditional Convergence
  11. Ratio and Root Tests
  12. Comparison Test
  13. Integral Test
  14. P-Series
  15. Binomial Series
  16. Fourier Series
  17. Uniform Convergence
  18. Complex Series

Vector Calculus

  1. Vector Fields
  2. Dot Product
  3. Cross Product
  4. Scalar and Vector Projections
  5. Gradient, Divergence, and Curl
  6. Line Integrals of Vector Fields
  7. Surface Integrals of Vector Fields
  8. Path Independence and Conservative Fields
  9. Potential Functions
  10. Flux and Circulation
  11. Conservative Fields
  12. Helmholtz Decomposition
  13. Irrotational and Solenoidal Fields

Differential Equations and Advanced Topics

  1. Ordinary Differential Equations (ODEs)
  2. Partial Differential Equations (PDEs)
  3. Separation of Variables
  4. Fourier Transform and Laplace Transform
  5. Eigenvalues and Eigenfunctions
  6. Bessel Functions
  7. Legendre Polynomials
  8. Sturm-Liouville Theory
  9. Nonlinear Differential Equations
  10. Systems of Differential Equations
  11. Stability and Phase Portraits
  12. Boundary Value Problems
  13. Greenโ€™s Functions

Short list of good courses / links / books on Mathematics, Operating Systems and AIML / ChatGPT – Part 1

Here is a short list of good courses / links / books on Mathematics, Operating Systems and AIML / ChatGPT – Part 1:

Email me: Neil@HarwaniSystems.in

Mystery of โ€˜Perfect Numbersโ€™ Resolved โ€“ Perfect Number is Always Even and Predictable

Mystery of โ€˜Perfect Numbersโ€™ Resolved โ€“ Perfect Number is Always Even and Predictable

Vrajlal Sapovadia (Ph.D.)
Sweta Patel (Ph.D.)

Introduction

In number theory, a perfect number is a positive integer that is equal to the sum of its proper positive divisors, excluding the number itself. In other words, a perfect number is a number that is half the sum of all of its positive divisors (including itself) i.e. ฯƒ1(n) = 2n. To explain in practical terms, we elaborate first few Perfect Numbers. It may be noted that โ€˜Perfect Numbersโ€™ are sparse are thinly dispersed. Starting from 3rd Century BC, mathematicians are working on Perfect Numbers. Till April 2018, i.e. during last 2300 years active research, researchers could recognize only 50 perfect numbers. There are 2 perfect numbers in first 100 and 4 in first million. Absolute distance between two perfect numbers increase exponentially as you go higher to the next perfect number[1]. One can find at least one perfect number till 4 digit numbers, and then it becomes a real rarity. Subsequent perfect numbers appears at 8, 10, 12 and 19 digits. 15th perfect number has 770 digits while 16th have 1327 digits. 25th perfect number has 13066 digits. 50th perfect number has 46,498,850 digits.

The current literature is still debating on two issues:

  1. Can perfect number is predictable?
  2. Can perfect number be odd?

We argue that perfect number is predictable and we have developed a formula which answers both lead questions as follow:

  1. Perfect number is predictable
  2. Perfect number is always even

Predictability

Euclid proved that 2pโˆ’1(2p โˆ’ 1) is an even perfect number whenever 2p โˆ’ 1 is prime (Euclid, Prop. IX.36). the first four perfect numbers are generated by the formula 2pโˆ’1(2p โˆ’ 1), with p a prime number, as follows:

for p = 2:ย ย  21(22 โˆ’ 1) = 6

for p = 3:ย ย  22(23 โˆ’ 1) = 28

for p = 5:ย ย  24(25 โˆ’ 1) = 496

for p = 7:ย ย  26(27 โˆ’ 1) = 8128.

Prime numbers of the form 2p โˆ’ 1 are known as Mersenne primes, after the seventeenth-century monk Marin Mersenne, who studied number theory and perfect numbers. For 2p โˆ’ 1 to be prime, it is necessary that p itself be prime. However, not all numbers of the form 2p โˆ’ 1 with a prime p are prime; for example, 211 โˆ’ 1 = 2047 = 23 ร— 89 is not a prime number.[11] In fact, Mersenne primes are very rareโ€”of the 2,270,720 prime numbers p up to 37,156,667,[12] 2p โˆ’ 1 is prime for only 45 of them.

Nicomachus (60โ€“120 AD) conjectured that every perfect number is of the form 2pโˆ’1(2p โˆ’ 1) where 2p โˆ’ 1 is prime.[13] Ibn al-Haytham (Alhazen) circa 1000 AD conjectured that every even perfect number is of that form.[14] It was not until the 18th century that Leonhard Euler proved that the formula 2pโˆ’1(2p โˆ’ 1) will yield all the even perfect numbers. Thus, there is a one-to-one correspondence between even perfect numbers and Mersenne primes; each Mersenne prime generates one even perfect number, and vice versa. This result is often referred to as the Euclidโ€“Euler theorem. As of January 2018, 50 Mersenne primes are known,[15] and therefore 50 even perfect numbers (the largest of which is 277232916 ร— (277232917 โˆ’ 1) with 46,498,850 digits).

Owing to their form, 2pโˆ’1(2p โˆ’ 1), every even perfect number is represented in binary as p ones followed by p โˆ’ 1ย  zeros. Interestingly, when a perfect number is converted into binary, it is not only a pernicious number, but binary sequence is spectacular having all 1 on the left side followed by all 0. Interestingly count of 1 is a prime number (p) and 0 is p-1.

610 = 1102

1 (p = 2) and 0 (1)

2810 = 111002

1 (p = 3) 0 (2)

49610 = 1111100002

1 (p = 5) 0 (4)

812810 = 11111110000002

1 (p = 7) 0 (6)

3355033610 = 11111111111110000000000002

1 (p = 13) 0 (12)

858986905610 = 1111111111111111100000000000000002

1 (p = 17) 0 (16)

13743869132810 = 11111111111111111110000000000000000002

1 (p = 19) 0 (18)

230584300813995212810 = 11111111111111111111111111111110000000000000000000000000000002

1 (p = 31) 0 (30)

Thus every even perfect number is a pernicious number. Note that every even perfect number is also a practical number. Therefore a formula to find a perfect number can be developed as 1โ€ฆ.(p) 0โ€ฆ(p-1), where 1 (p) and 0 (p-1) are binary symbol. Thus, a binary number so written equal to a PRIME (p) โ€˜1โ€™ followed by p-1 โ€˜0โ€™ could be a perfect number. It may be noted that all prime count does not result into perfect number. Therefore, it is pertinent to test each prime number with formula[2] will establish whether resultant number is perfect number or not. But in any case, this will reduce substantially the experiment time to find next perfect number or this formula provides a lead to find perfect number with less experiment time.

Odd vs. Even

It is unknown whether there is any odd perfect number, though various results have been obtained. In 1496, Jacques Lefรจvre stated that Euclid’s rule gives all perfect numbers, thus implying that no odd perfect number exists. More recently, Carl Pomerance has presented a heuristic argument suggesting that indeed no odd perfect number should exist. All perfect numbers are also Ore’s harmonic numbers, and it has been conjectured as well that there are no odd Ore’s harmonic numbers other than 1. An exhaustive search by the GIMPS[3] distributed computing project has shown that the first 46 are all even numbers represented by 2pโˆ’1(2p โˆ’ 1).

First 50 perfect numbers listed[4] are all even and their last one or two digits are always 6 or 28. In support of arguments made by various researchers, we found that a perfect number can be presented as binary with formula 1โ€ฆ.(p) 0โ€ฆ(p-1). Any binary pattern as 1 (n) 0 (n-1) will always result into even number. Therefore any perfect number is always a even number.

[1] 6 (1), 28 (2), 496 (3), 8128 (4), 33550336 (8), 8589869056 (10), 137438691328 (12), 2305843008139952128 (19)
[2] Binary numbers 1โ€ฆ.(p) 0โ€ฆ(p-1)
[3] The Great Internet Mersenne Prime Search (GIMPS) is a collaborative project of volunteers who use freely available software to search for Mersenne prime numbers.
[4] https://en.wikipedia.org/wiki/List_of_perfect_numbers