Skip to main content

Math fundamentals and Katex


It was really tough for me to understand many articles about data science due to the requirements of understanding mathematics (especially linear algebra). I’ve started to gain some basic knowledges about Math by reading a book first.

The great tool Typora and stackedit with supporting Katex syntax simply helps me to display Math-related symbols.

Let’s start!

The fundamental ideas of mathematics: “doing math” with numbers and functions. Linear algebra: “doing math” with vectors and linear transformations.

1. Solving equations

Solving equations means finding the value of the unknown in the equation. To find the solution, we must break the problem down into simpler steps. E.g:

x24=45x24+4=45+4x2=49x=49x=7x=7 or x=7\begin{aligned} x^2 - 4 &= 45\\ x^2 - 4 + 4 &= 45 + 4\\ x^2 &= 49\\ \sqrt{x}&=\sqrt{49}\\ |x| &= 7\\ x=7 &\text{ or } x=-7 \end{aligned}

2. Numbers

Definitions
Mathematicians like to classify the different kinds of number-like objects into sets:

  • The natural numbers: NN = {0,1,2,3,4,5,6,70, 1, 2, 3, 4, 5, 6, 7, … }
  • The integer: ZZ = { … , 3,2,1,0,1,2,3-3, -2, -1, 0, 1, 2, 3, … }
  • The rational numbers: QQ = {53{5}\over{3}, 227{22}\over{7}, 1.5,0.125,71.5, 0.125, -7, … }
  • The real numbers: RR = {1,0,1,2,e,π,4.94...-1, 0, 1, \sqrt{2}, e, \pi, 4.94..., … }
  • The complex numbers: CC = {1,0,1,i,1+i,2+3i-1, 0, 1, i, 1 + i, 2 + 3i, … }

Operations on numbers

  • Addition is commutative and associative. That means:
    a+b=b+aa + b = b+ a
    a+b+c=(a+b)+c=a+(b+c)a + b + c = (a + b) + c = a + (b + c)
  • Subtraction is the inverse operation of addition.
  • Multiplication is also commutative and associative.
    ab=a+a+a+...+ab times=b+b+b+...+ba timesab = \underbrace{a + a + a + ... + a}_{\text{b times}} = \underbrace{b + b + b + ... + b}_{\text{a times}}
    ab=baab = ba
    abc=(ab)c=a(bc)abc = (ab)c = a(bc)
  • Division is the inverse operation of multiplication. You cannot divide by 0.
  • Exponentiation is multiplying a number by itself many times.
    ab=aaa...ab timesa^b = \underbrace{aaa...a}_{\text{b times}}
    ab=1aba^{-b} = {{1}\over{a^b}}
    ana1n\sqrt[n]{a} \equiv a^{{1}\over{n}}

The symbol “\equiv” stands for “is equivalent to” and is used when two mathematical object are identical.

3. Variables

Variables are placeholder names for any number or unknown. Variable substitution: we can often change variables and replace one unknown variable with another to simplify an equation. For example:

65x=xu=x65u=u \begin{aligned} {6 \over{5 - \sqrt{x}}} = \sqrt{x}\\ u = \sqrt{x}\\ {6 \over{5 - u}} = u \end{aligned}

4. Functions and their inverses

The inverse function f1f^{-1} performs the opposite action of the function ff so together the two functions cancel each other out. For example:

  1. f(x)=cf(x) = c
  2. f1(f(x))=x=f1(c)f^{-1}(f(x)) = x = f^{-1}(c)
  3. x=f1(c)x=f^{-1}(c)

Common functions and their inverses:
functionf(x)inversef1(x)x+2x22x12xx2±x2xlog2(x)3x+513(x5)axloga(x)exp(x)exln(x)loge(x)sin(x)sin1(x)arcsin(x)cos(x)cos1(x)arccos(x) \begin{aligned} function f(x) &\Leftrightarrow inverse f^{-1}(x)\\ x+2 &\Leftrightarrow x-2\\ 2x &\Leftrightarrow {1\over2}x\\ x^2 &\Leftrightarrow \pm{\sqrt{x}}\\ 2^x &\Leftrightarrow log{_2}(x)\\ 3x + 5 &\Leftrightarrow {1\over 3}(x-5)\\ a^x &\Leftrightarrow log{_a}(x)\\ exp(x) \equiv e^x &\Leftrightarrow ln(x) \equiv log{_e}(x)\\ sin(x) &\Leftrightarrow sin^{-1}(x) \equiv arcsin(x)\\ cos(x) &\Leftrightarrow cos^{-1}(x) \equiv arccos(x) \end{aligned}
The principle of “digging” (Bruce Lee-style) toward the unknown by applying inverse functions is the key for solving all these types of equations, so be sure to practice using it.

5. Basic rules of algebra

Given any three numbers a, b, and c we can apply the following algebraic properties:

  • Associative property: a+b+c=(a+b)+c=a+(b+c)a + b + c = (a + b) + c = a + (b+ c) and abc=(ab)c=a(bc)abc = (ab)c = a(bc)
  • Commutative property: a+b=b+aa + b = b + a and ab=baab = ba
  • Distributive property: a(b+c)a(b + c) = ab+acab + ac

Some algebraic tricks are useful when solving equations

  • Expanding brackets: (x+3)(x+2)=x2+5x+6(x + 3)(x +2) = x^2 + 5x + 6
  • Factoring: 2x2y+2x+4x=2x(xy+1+2)=2x(xy+3)2x^2y + 2x + 4x = 2x(xy + 1 + 2) = 2x(xy + 3)
  • Quadratic factoring: x25x+6=(x2)(x3)x^2-5x+6=(x-2)(x-3)
  • Completing the square: Ax2+Bx+C=A(xh)2+kAx^2 + Bx + C = A(x- h)^2 + k e.g: x2+4x+1=(x+2)23x^2 + 4x + 1 = (x + 2)^2-3

6. Solving quadratic equations

The solutions to the equation ax2+bx+c=0ax^2 + bx + c =0 are
x1=b+b24ac2aandx2=bb24ac2a x_1 = {{-b + \sqrt{b^2 - 4ac}}\over{2a}} \quad and \quad x_2 = {{-b -\sqrt{b^2-4ac}}\over{2a}}
Actually, we can use the technique completing the square to explain this formula.

7. The Cartesian plane

Vectors and points

  • Point: P=(Px,Py)P = (P_x, P_y). To find this point, start from the origin and move a distance PxP_x on the x-axis, then move a distance PyP_y on the y-axis.
  • Vector: v=(vx,vy)\overrightarrow{v} = (v_x, v_y). Unlike points, we don’t necessarily start from the plane’s origin when mapping vectors.

Graphs of functions

The Cartesian plane is great for visualizing functions, f:RRf: {R} \rightarrow {R}

A function as a set of input-output pairs (x,y)=(x,f(x))(x, y) = (x, f(x))

8. Functions

We use functions to describe the relationship between variables.

To “know” a function, you must be able to understand and connect several of its aspects including definition, graph, values and relations.

Definition: f:ABf: A \rightarrow B. Function is a mapping from numbers to numbers.

  • Function composition: fog(x)f(g(x))=zfog(x)\equiv f(g(x)) = z
  • Inverse function: f1(f(x))f1of(x)=xf^{-1}(f(x)) \equiv f^{-1}o f(x) = x
  • Table of values: {(x1,f(x1)),(x2,f(x2)),...}\{(x1, f(x1)), (x2, f(x2)), ...\}
  • Function graph: using the Cartesian plane
  • Relations: e.g: sin2x+cos2x=1sin^2x + cos^2x = 1

9. Function references

- Line

The equation of a line: f(x)=mx+bf(x) = mx + b and f1(x)=1m(xb)f^{-1} (x) = {{1\over m} (x-b)}
The general equation: Ax+By=CAx + By = C

- Square/Quadratic: f(x)=x2f(x) = x^2

- Square root: f(x)=xx12f(x) = \sqrt x \equiv x ^{1\over2}

- Absolute value: f(x)=x={xif x0,cif x<0.f(x) = |x| = \begin{cases} x &\text{if } x \ge 0, \\ c &\text{if } x \lt 0.\end{cases}

- Polynomial functions: f(x)=a0+a1x+a2x2+a3x3+...+anxnf(x) = a_0 + a_1x + a_2x^2 + a_3x^3 + ... + a_nx^n

- Sine: f(x)=sin(x)f(x) = sin(x)

- Consine: f(x)=cos(x)=sin(x+π2)f(x) = cos(x) = sin(x + {\pi\over2})

- Tangent: f(x)=tan(x)sin(x)cos(x)f(x) = tan(x) \equiv {sin(x)\over{cos(x)}}

- Exponential: f(x)=exexp(x)f(x) = e^x \equiv exp(x)

- Natural logarithm: f(x)=ln(x)=loge(x)f(x) = ln(x) = log_e(x)

- Function transformation

Vertical translation: g(x)=f(x)+kg(x) = f(x) + k

Horizontal translation: g(x)=f(xh)g(x) = f(x-h)

Veritcal scaling: g(x)=Af(x)g(x) = Af(x)

Horizontal scaling: g(x)=f(ax)g(x) = f(ax)

- General quadratic function: f(x)=A(xh)2+kf(x) = A(x-h)^2 + k

- General sine function: f(x)=Asin(2πλxϕ)f(x) = Asin({2\pi\over\lambda}x - \phi)

10. Polynomials

In general, a polynomial of degree nn has the equation

f(x)=anxn+an1xn1+...+a2x2+a1x+a0k=0nakxkf(x) = a_nx^n + a_{n-1}x^{n-1} + ...+ a_2x^2 + a_1x + a_0 \equiv \displaystyle\sum_{k=0}^na_kx^k

11. Trigonometry

Pythagoras’ theorem
adj2+opp2=hyp2adj2hyp2+opp2hyp2=1sin2(θ)+cos2(θ)=1 \begin{aligned} |adj|^2 + |opp|^2 &= |hyp|^2\\ {{|adj|^2}\over{|hyp|^2}} + {{|opp|^2}\over{|hyp|^2}} &= 1\\ sin^2(\theta) + cos^2(\theta) &= 1 \end{aligned}

12. Trigonometric identities

sin2(θ)+cos2(θ)=1sin^2(\theta) + cos^2(\theta) = 1

sin(a+b)=sin(a)cos(b)+sin(b)cos(a)sin(a+ b) = sin(a)cos(b) + sin(b)cos(a)

cos(a+b)=cos(a)cos(b)sin(a)sin(b)cos(a+b) = cos(a)cos(b) - sin(a)sin(b)

And, more …

13. Geometry

A: area, P: perimeter, V: volume

Triangles: A=12ahaA = {1\over2}ah_a, P=a+b+cP = a + b + c

Sphere: A=4πr2A=4\pi r^2, V=43πr3V={{4\over3}\pi r^3}

Cylinder: A=2(πr2)+(2πr)hA = 2(\pi r^2) + (2\pi r)h, V=(πr2)hV = (\pi r^2)h

14. Circle

Radians: 2π[rad]=36002\pi [rad] = 360^0

15. Sovling systems of linear equations

a1x+b1y=c1a2x+b2y=c2 \begin{aligned} a_1x + b_1y = c1\\ a_2x + b_2y=c_2 \end{aligned}
There are some approaches to sovling it:

  • Solving by substitution
  • Solving by substraction
  • Solving by equating

Reference:
[1]. Ivan Savov, “No bullshit guide to linear algebra”.

Comments

Popular posts from this blog

Brainstorming camp

My team just started  building a new project about finance. There are something new with us rather than other processes happened before. Here is we didn't have requirements/user stories about the project yet and we needed to work together with another team in this time. Our product manager (PM) decided to have a camp to collect the ideas in order to getting started as well as make the communication between the teams. Firstly, our PM gave an introduction about the project to all members. Then, we decided to split and focus on four topics that we needed to discuss about them. They are: - General information: working agreements between two teams included coding convention. - Data model: structure of data. - GUI design: user interface and user experience (UX). - GUI technical framework: how data model and GUI can be worked together. The target of each topics should be given an overview and can be shown why and how to work with chosen approach. Finally, we separated all memb...

The HelloWorld example of JSF 2.2 with Myfaces

I just did by myself create a very simple app "HelloWorld" of JSF 2.2 with a concrete implementation Myfaces that we can use it later on for our further JSF trying out. I attached the source code link at the end part. Just follow these steps below: 1. Create a Maven project in Eclipse (Kepler) with a simple Java web application archetype "maven-archetype-webapp". Maven should be the best choice for managing the dependencies , so far. JSF is a web framework that is the reason why I chose the mentioned archetype for my example. 2. Import dependencies for JSF implementation - Myfaces (v2.2.10) into file pom.xml . The following code that is easy to find from  http://mvnrepository.com/  with key words "myfaces". <dependency> <groupId>org.apache.myfaces.core</groupId> <artifactId>myfaces-api</artifactId> <version>2.2.10</version> </dependency> <dependency> <groupId>org.apache.myfaces.core<...

The power of acceptance test

User Story is the place PO gives his ideas about features so that developers are able to know what requirements are. Acceptance tests are these show the most valuable things of the features represented by some specific cases. Usually PO defines them, but not always. Therefore, refining existing acceptance tests – even defining new ones that cover all features of the User Story must be a worth task. Acceptance test with Given When Then pattern If we understand what we are going to do, we can complete it by 50% I have worked with some members those just start implementing the features one by one and from top to down of the User Story description. Be honest, I am the one used to be. What a risky approach! Because it might meet a case that is very easy to miss requirements or needs to re-work after finding any misunderstood things. I have also worked with some members those accept spending a long time to clarify the User Story. Reading carefully of whole User Story by defining...

If We Want to Go Fast, We Need to Go Well

Have you ever thought that we won't need to code anymore because programs might be generated from specification? The answer can be yes or no; there is still arguing about it. The programming language is more and more closed to the requirements. The starting is from a very low level as Assembly to a very high level like Python. However, it doesn't make much sense when saying that we will eliminate coding. For me, we currently still need to express our ideas in exact words that tells the machine what we want. Otherwise, I hope in the future the machine is intelligent enough to understand our requirements directly from our words. ;) Take a look at the famous quote of Robert C.Martin about what I mentioned above: "Remember that code is really the language in which we ultimately express the requirements. We may create languages that are closer to the requirements. We may create tools that help us parse and assemble those requirements into formal structures. But we wi...

Installing NGINX on macOS

I have heard of a lot of NGINX recently. One of them was it can help for security issues; for sure, it much be more. It so happens that our team has got a ton of user stories from a security audit. It's time to delve into it. What is NGINX? In order to get a basic idea and have some fun , I've just picked some available posts from my favorite Vietnamese blogger communities as below: https://kipalog.com/posts/Cau-hinh-nginx-co-ban---Phan-1 https://viblo.asia/hoang.thi.tuan.dung/posts/ZabG912QGzY6 NGINX (pronounce: Engine-X) is a web server (comparing to IIS, Apache). It can be used as a reverse proxy ( this is what I need for security issues with configuration ), load balancer and more. How to get started? I found the below path for learning NGINX by googling "learn nginx": https://www.quora.com/What-are-some-good-online-resources-to-learn-Nginx In this post, I only went first step. This is installing NGINX on macOS and taking a first look at the confi...