A journey of a software engineer and computer science enthusiast
Search This Blog
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:
x2−4x2−4+4x2x∣x∣x=7=45=45+4=49=49=7 or x=−7
2. Numbers
Definitions
Mathematicians like to classify the different kinds of number-like objects into sets:
The natural numbers: N = {0,1,2,3,4,5,6,7, … }
The integer: Z = { … , −3,−2,−1,0,1,2,3, … }
The rational numbers: Q = {35, 722, 1.5,0.125,−7, … }
The real numbers: R = {−1,0,1,2,e,π,4.94..., … }
The complex numbers: C = {−1,0,1,i,1+i,2+3i, … }
Operations on numbers
Addition is commutative and associative. That means: a+b=b+a a+b+c=(a+b)+c=a+(b+c)
Subtraction is the inverse operation of addition.
Multiplication is also commutative and associative. ab=b timesa+a+a+...+a=a timesb+b+b+...+b ab=ba 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=b timesaaa...a a−b=ab1 na≡an1
The symbol “≡” 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:
5−x6=xu=x5−u6=u
4. Functions and their inverses
The inverse functionf−1 performs the opposite action of the function f so together the two functions cancel each other out. For example:
f(x)=c
f−1(f(x))=x=f−1(c)
x=f−1(c)
Common functions and their inverses: functionf(x)x+22xx22x3x+5axexp(x)≡exsin(x)cos(x)⇔inversef−1(x)⇔x−2⇔21x⇔±x⇔log2(x)⇔31(x−5)⇔loga(x)⇔ln(x)≡loge(x)⇔sin−1(x)≡arcsin(x)⇔cos−1(x)≡arccos(x)
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) and abc=(ab)c=a(bc)
Commutative property: a+b=b+a and ab=ba
Distributive property: a(b+c) = ab+ac
Some algebraic tricks are useful when solving equations
Expanding brackets: (x+3)(x+2)=x2+5x+6
Factoring: 2x2y+2x+4x=2x(xy+1+2)=2x(xy+3)
Quadratic factoring: x2−5x+6=(x−2)(x−3)
Completing the square: Ax2+Bx+C=A(x−h)2+k e.g: x2+4x+1=(x+2)2−3
6. Solving quadratic equations
The solutions to the equation ax2+bx+c=0 are x1=2a−b+b2−4acandx2=2a−b−b2−4ac
Actually, we can use the technique completing the square to explain this formula.
7. The Cartesian plane
Vectors and points
Point: P=(Px,Py). To find this point, start from the origin and move a distance Px on the x-axis, then move a distance Py on the y-axis.
Vector: v=(vx,vy). 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:R→R
A function as a set of input-output pairs (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:A→B. Function is a mapping from numbers to numbers.
Function composition: fog(x)≡f(g(x))=z
Inverse function: f−1(f(x))≡f−1of(x)=x
Table of values: {(x1,f(x1)),(x2,f(x2)),...}
Function graph: using the Cartesian plane
Relations: e.g: sin2x+cos2x=1
9. Function references
- Line
The equation of a line: f(x)=mx+b and f−1(x)=m1(x−b)
The general equation: Ax+By=C
I searched from somewhere and found that a lot of people says a basic concept for implementing this feature looks like below: HTML code: <div id="parent"> <div id="child"> </div> </div> And, CSS: #parent{ position: relative; overflow:hidden; } #child{ position: absolute; top: -1; right: -1px; } However, I had a lot of grand-parents in my case and the above code didn't work. Therefore, I needed an alternative. I presumed that my app uses Boostrap and AngularJs, maybe some CSS from them affects mine. I didn't know exactly the problem, but I believed when all CSS is loaded into my browser, I could completely handle it. www.tom-collinson.com I tried to create an example to investigated this problem by Fiddle . Accidentally, I just changed: position: parent; to position: static; for one of parents -> the problem is solved. Look at my code: <div class="modal-body dn-placeholder-parent-positi...
Previously, we maintained OpenShift templates for deploying apps in development environments as well as delivering these templates to our customers for their on-prem deployment. Customers who refer to our templates (as well as documentation) have their own configuration management tools to automate the deployment such as ArgoCD and FluxCD. My son's buildings Our developers usually modify templates (YAML) directly on OpenShift for testing and then adjust the corresponding templates stored in the Git repository in Bitbucket. This sometimes causes an issue that delivered templates are incorrect because: - Developers forget to update the templates in Git repositories. - Developers don’t test the templates Therefore, our goal was to integrate a tool into our CI/CD that can automate and manage the configuration of OpenShift apps. The delivered templates should be the ones that are able to run on our OpenShift with the following purposes: - Automate deployment from templated in Git repos...
I have received the following exercise from an interviewer, he didn't give the name of the problem. Honestly, I have no idea how to solve this problem even I have tried to read it three times before. Since I used to be a person who always tells myself "I am not the one good at algorithms", but giving up something too soon which I feel that I didn't spend enough effort to overcome is not my way. Then, I have sticked on it for 24 hours. According to the given image on the problem, I tried to get more clues by searching. Thanks to Google, I found a similar problem on Hackerrank (attached link below). My target here was trying my best to just understand the problem and was trying to solve it accordingly by the Editorial on Hackerrank. Due to this circumstance, it turns me to love solving algorithms from now on (laugh). Check it out! Problem You are given a very organized square of size N (1-based index) and a list of S commands The i th command will follow t...
The following is a series of posts about "functional programming in Java" which is the result of my understanding by reading the book " Java 8 in Action: Lambdas, Streams, and Functional-style Programming, by Alan Mycroft and Mario Fusco ". 1. Why functional programming? 2. Functional programming in Java 8 3. Java 8 - Using Functions as Values 4. Java 8 - Persistent data structure Persistent data structure is also known as a simple technique but it's very important. Its other names are functional data structure and immutable data structure. Why is it "persistent"? Their values persist and are isolated from changes happening elsewhere. That's it! This technique is described as below: If you need a data structure to represent the result of a computation, you should make a new one and not mutable an existing data structure. Destructive updates version public static A doSomething(A a){ a.setProp1("new value"); return...
Suppose that we have a list of employees. Everytime, we want to add new employee into this list, the name of the employee will be generated with the following rules: - the name of the new one is set to " [originalname] 1 " - in case the name already exist, " [originalname] 2 " is used, and so on. Here is my code snippet by Javascript: var employees =[ {id: 1, name: 'name'}, {id: 2, name: 'name 1'}, {id: 3, name: 'name 2'}, {id: 5, name: 'name 4'} ]; var commonUtils = { isExistName: function(_name, _collection, _prop) { for(var i = 0; i< _collection.length; i++){ if(_collection[i][_prop].localeCompare(_name)==0){ return true; } } return false; }, generateNewName: function(_name, _collection, _prop){ var i = 1; var searching = true; while (searching) { var newName = _name+ " " + i; if (!this.isExistName(newName, _collection, _pro...
Comments
Post a Comment