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-position&quo
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<
For example, I have a program with an Animal abstract class and two sub-classes Dog and Bird. I want to add new behavior for the class Animal, this is "fly". Now, I face two approaches to solve this issue: 1. Adding an abstract method "fly" into the class Animal. Then, I force the sub-classes should be implemented this method, something like: public abstract class Animal{ //bla bla public abstract void fly(); } public class Bird extends Animal{ //bla bla public void fly(){ System.out.println("Fly high"); } } public class Dog extends Animal{ //bla bla public void fly(){ System.out.println("Cant fly"); } } 2. Creating an interface with method "fly" inside. The same issue to an abstract class, I force the classes these implement this interface should have a method "fly" inside: public interface Flyable{ public void fly(); } public class Bird implements Flyable{ //bla bla public void fly(){ System.out.pr
Special characters such as square brackets ([ ]) can cause an exception " java.util.regex.PatternSyntaxException " or something like this if we don't handle them correctly. I had met this issue. In my case, my customers want our application should allow some characters in German and French even not allow some special characters. The solution is that we limit the allowed characters by showing the validation message on GUI. For an instance, the message looks like the following: "This field can't contain any special characters; only letters, numbers, underscores (_), spaces and single quotes (') are allowed." I used Regular Expression to check it. For entering Germany and French, I actually don't have this type of keyboard, so I referred these sites: * German characters: http://german.typeit.org/ * French characters: http://french.typeit.org/ Here is my code: package vn.nvanhuong.practice; import java.util.regex.Matcher; import java.util
Motivator It's important for a team to have an agreement on how the changes of source code should be applied. According to projects and teams size, we will define a workflow or select one from recommended workflows ; the "Feature Branch Workflow" is a candidate. What is it? - One branch "master" for main codebase - Several separated branches for features development Why should we care? - Be super simple and allow each developer works on a particular feature. - A stable codebase (master) benefits for continuous integration (CI) environment - Leverage "Pull request" for Code review How it works? A lifecyle of a feature branch (usually created by a story) 1. Creator creates a new branch from a story. For example: "ABC-1-setup-projects" 2. Creator checkouts the created branch and works on the branch (commits, pushes) 3. Creator has done the feature, he uses "pull request" to merge his branch into branch "master
Comments
Post a Comment