Skip to content

Commit

Permalink
*
Browse files Browse the repository at this point in the history
  • Loading branch information
imteekay committed Aug 31, 2024
1 parent 8e54478 commit 06c0341
Showing 1 changed file with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Plotting this graph:
loading="lazy"
/>

For this equation `q(x) = 2x + 1`, we can say the rate of change is `2`. Generalizing, we having `f(x) = mx + C`, `m` is the rate of change.
For this equation `q(x) = 2x + 1`, we can say the rate of change is `2`. Generalizing, we have `f(x) = mx + C`, `m` is the rate of change.

We calculate the rate of change the same as the slope:

Expand Down Expand Up @@ -69,7 +69,7 @@ This plots the behavior of the function and average velocity:

## Limits

In a quadratic equation we have a bunch of points in the curve and we can plot like this:
In a quadratic equation, we have a bunch of points in the curve and we can plot like this:

```python
def f(x):
Expand Down Expand Up @@ -103,7 +103,7 @@ Generating this graph:

But we can still see gaps between points. And now we need to understand the concept of limits.

Not all functions are continuous. Take this function as example:
Not all functions are continuous. Take this function as an example:

```bash
g(x) = -(12/2x)², where x ≠ 0
Expand Down Expand Up @@ -135,17 +135,17 @@ Plotting `g(x)`, we get this graph:

The function `g(x)` is non-continuous at `x = 0`

Limits can be applied to continous functions like `a(x) = x² + 1`
Limits can be applied to continuous functions like `a(x) = x² + 1`

When `x` is approaching `0`, `a(x) = 1`.

That's because when `x` is slightly greater than `0` and slightly smaller than `0` (e.g. 0.000001 and -0.000001), the result will be slightly greater than `1` and slightly smaller than `1`, respectively.

This is how we write it: when `x` approaching `0`, the limit of `a(x)` is `1`.
This is how we write it: when `x` approaches `0`, the limit of `a(x)` is `1`.

`lim x->0 a(x) = 1`

We can also apply this concept to non-continuous points. Take this function as example: `b(x) = -2x²/x`, where `x ≠ 0`.
We can also apply this concept to non-continuous points. Take this function as an example: `b(x) = -2x²/x`, where `x ≠ 0`.

Let's plot it with Python

Expand All @@ -164,7 +164,7 @@ plt.plot(x,y, color='purple')
plt.show()
```

Here's how it looks like in a graph:
Here's what it looks like in a graph:

<img
src="/series/mathematics-for-machine-learning/non-continuous-function-ii.png"
Expand Down Expand Up @@ -204,12 +204,12 @@ We plot this graph:
loading="lazy"
/>

Approaching from negative and positive sides result in infinite.
Approaching from negative and positive sides results in infinite.

- -♾️ when approaching from the negative side: lim x->25 d(x) = -♾️
- +♾️ when approaching from the positive side: lim x->25 d(x) = +♾️

We can use factorization when direct substitution doesn't work. Take this function as example:
We can use factorization when direct substitution doesn't work. Take this function as an example:

```bash
g(x) = (x² - 1) / (x - 1)
Expand Down Expand Up @@ -266,9 +266,9 @@ Generating this graph:
loading="lazy"
/>

We can use pretty much the same idea using the rationalization.
We can use pretty much the same idea using rationalization.

Limits also have rules of operations: addition, substraction, multiplication, division, etc.
Limits also have rules of operations: addition, subtraction, multiplication, division, etc.

Addition:

Expand Down Expand Up @@ -456,13 +456,13 @@ It generates these two functions in the graph:
loading="lazy"
/>
Some interpretation of this graph:
Some interpretations of this graph:
- The point where the derivative line crosses 0 on the y-axis is also the point where the function value stops increasing and starts decreasing. When the slope has a positive value, the function is increasing; and when the slope has a negative value, the function is decreasing.
- The tangent line (the slope in each point) is rotating clockwise throughout the graph.
- At the highest point, the tangent line would be perfectly horizontal, representing a slope of 0.
To illustrate the interpretation, we have three tangent lines: one when the function is increasing, one when the function is decreasing, and the another one when it's horizontal, in other words, when the slope is 0.
To illustrate the interpretation, we have three tangent lines: one when the function is increasing, one when the function is decreasing, and the other one when it's horizontal, in other words, when the slope is 0.
<img
src="/series/mathematics-for-machine-learning/critical-points-tangent-lines.png"
Expand All @@ -486,7 +486,7 @@ The derivative will be 0 when `x` is 5.
**Second Order Derivatives**
We can use second order derivatives to determine if the critical point is minima or maxima.
We can use second-order derivatives to determine if the critical point is minima or maxima.
```bash
k(x) = -10x² + 100x + 3
Expand All @@ -496,7 +496,7 @@ k''(x) = -20
The second derivative has a constant value, so we know that the slope of the prime derivative is linear, and because it's a negative value, we know that it is decreasing.
When the derivative crosses 0, it we know that the slope of the function is decreasing linearly, so the point at `x = 0` must be a maximum point.
When the derivative crosses 0, we know that the slope of the function is decreasing linearly, so the point at `x = 0` must be a maximum point.
The same happens when finding a minimum point.
Expand All @@ -508,15 +508,15 @@ w''(x) = 2
It's a positive constant, so it's increasing when crossing `0`, therefore, it means this a minimum point.
Optimization is one of the application of finding critical points.
Optimization is one of the applications of finding critical points.
Imagine a formula representing the expected number of subscriptions to Netflix:
```bash
s(x) = -5x + 100
```
In this case, `s(x)` being the number of subscriptions and `x` the monthly fee.
In this case, `s(x)` is the number of subscriptions, and `x` is the monthly fee.
The monthly revenue can be calculated as the subscription volume times the monthly fee:
Expand All @@ -525,7 +525,7 @@ r(x) = s(x)·x
r(x) = -5x² + 100x
```
First find the prime derivative:
First, find the prime derivative:
```bash
r'(x) = -10x + 100
Expand All @@ -540,7 +540,7 @@ r'(x) = -10x + 100
x = 10
```
And finally checking if the critical point is a maximum or minimum point using the second order derivative:
Finally checking if the critical point is a maximum or minimum point using the second-order derivative:
```bash
r'(x) = -10x + 100
Expand All @@ -552,7 +552,7 @@ A negative constant value in the second order derivative tells it's a maximum po
## Partial Derivatives
How do we calculate the derivate of multi variables functions?
How do we calculate the derivate of multi-variables functions?
```bash
f(x, y) = x² + y²
Expand Down Expand Up @@ -583,9 +583,9 @@ We get the same idea when calculating the partial derivative with respect to `y`
2y
```
We use partial derivatives to compute a gradient. A gradient is a way to find the analog of the slope for multi-dimensonal surfaces.
We use partial derivatives to compute a gradient. A gradient is a way to find the analog of the slope for multi-dimensional surfaces.
You can find minimum and maximum of curves using derivatives. In the same way, you can find the minimum and maximum of surfaces by following the gradiennt and finding the points were the gradient is zero in all directions.
You can find the minimum and maximum of curves using derivatives. In the same way, you can find the minimum and maximum of surfaces by following the gradient and finding the points where the gradient is zero in all directions.
For this function:
Expand All @@ -606,9 +606,9 @@ The gradient is a 2-dimensional vector:
grad(f(x, y)) = [2x, 2y]
```
We can use the concept of gradient in a minimization algorithm called gradient descent method, where you take a guess, compute the gradient, take a small step in the direction of the gradient, and determine if it's close to `0` (the gradient will be `0` at the minimum).
We can use the concept of gradient in a minimization algorithm called the gradient descent method, where you take a guess, compute the gradient, take a small step in the direction of the gradient, and determine if it's close to `0` (the gradient will be `0` at the minimum).
The cost function provides a way to evaluate the performance of a model. Gradient descent is an optimization algorithm used to minimize the cost function. One type of cost functions is the Mean Squared Error (MSE). Minimizing the cost function means
The cost function provides a way to evaluate the performance of a model. Gradient descent is an optimization algorithm used to minimize the cost function. One type of cost function is the Mean Squared Error (MSE). Minimizing the cost function means
- Finding the model parameters that result in the smallest possible cost, indicating the best fit to the data.
- Lower values of the cost function indicate a model that better predicts the actual outcomes.
Expand Down

0 comments on commit 06c0341

Please sign in to comment.