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<
So far, Primefaces has used image sprites for displaying the sort icons. This leads to a problem if we want to make a different style for these icons; for example, I would make the icon "arrow up" more blurry at the first time the table loading because I want to highlight the icon "arrow down". I found a way that I can replace these icons with Font Awesome icons. We will use "CSS Pseudo-classes" to achieve it. The hardest thing here is that we should handle displaying icons in different cases. There is a case both "arrow up" and "arrow down" showing and other case is only one of these icons is shown. .ui-sortable-column-icon.ui-icon.ui-icon-carat-2-n-s { background-image: none; margin-left: 5px; font-size: 1.1666em; position: relative; } .ui-sortable-column-icon.ui-icon.ui-icon-carat-2-n-s:not(.ui-icon-triangle-1-s)::before { content: "\f106"; font-family: "FontAwesome"; position:
I have a table that is displayed a list of competence groups. When I click on a competence group, it will display a table that contains a lot of criteria belong to the competence group. Each times I click on a competence group, a "loading" icon is displayed while waiting for all criteria is fully displayed. <div id="loading" style="display: none;"> <div></div> <div></div> I tried to write a Selenium test to make sure this behavior is covered. I saw that the loading icon element is always available on DOM tree because I just used Jquery to handle its displaying. Beside that, the loading icon is appeared dynamically and quickly disappear afterwards. It is hard to checking the visibility on GUI of loading icon. By normal way that I frequently used, the code looks like: public boolean isLoadingIconDisplayed() { List<WebElement> loadingIcons = driver.findElements(By.id("loading")); if(!loadingIcons.isE
I use the calendar Primefaces component with timeOnly and timeZone attributes for using only hour format (HH:mm). Like this: <p:calendar id="xabsOvertimeTimeFrom" pattern="HH:mm" timeOnly="true" value="#{data.dateFrom}" timeZone="#{data.timeZone}"/> We can convert the value of #{data.dateFrom} from GMT/UTC time zone to local, conversely, from local time zone to GMT/UTC time zone. Here is my functions: package vn.nvanhuong.timezoneconverter; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.TimeZone; public class TimeZoneConverter { /** * convert a date with hour format (HH:mm) from local time zone to UTC time zone */ public static Date convertHourToUTCTimeZone(Date inputDate) throws ParseException { if(inputDate == null){ return null; } Calendar calendar = Calendar.getInstance(); calendar.setTime(inputDate); int
Comments
Post a Comment