[PYTHON] Differentiate a two-variable function

Today, I will mainly summarize the differential calculus of two-variable functions.

Make the state transition a vector

Before that, as a preliminary preparation, we often want to get directions from point information. For example, to get the flow line between stores in chronological order, or to get the history of accessed web pages.

If the individual information is the key and the access point is the area

#Find the key in the associative array
if key in dic:
    #Check if individual information is moving
    if dic[key]["area"] == area:
        pass
    else:
        #If it is moving, output the move source and move destination
        self._output(
            key, dic[key]["area"],
            area, timestamp,
            int(timestamp) - dic[key]["timestamp"]
        )
        #Replace the associative array information with the destination and its time stamp
        dic[key] == {
            "area": area, "timestamp": int(timestamp)
        }
else:
    #If it is not in the associative array, it is stored as the move source and its time mark.
    dic[key] = {
        "area": area, "timestamp": int(timestamp)
    }

with this key, from, to, time You can get the movement information between the two points.

Differential calculus of multivariable functions

Directional derivative

When there is a two-variable function z = f (x, y), the point that advances from the point x = (a, b) on the xy plane in the direction of the vector u = (α, β) is

x + hu = (a + hα, b + hβ)

It will be. With this

\frac {\partial f} {\partial \mathbf{u}} (a,b) = \lim_{h\rightarrow 0} \frac {f(a+h\alpha, b+h\beta) - f(a,b)} {h}

U defined as is Directional derivative.

Partial differential coefficient

Partial differential coefficient for x with a differential coefficient that fixes y of f (x, y) and changes only x It is called AE% E5% 88% 86).

The above partial derivative at point (a, b) is

\frac {df} {dx} (a,b) = \lim_{h \to 0} \frac {f(a + h, b) - f(a, b)} {h}

Is defined as, which is equivalent to the directional derivative according to u = (1, 0).

Higher partial derivative

Partial derivative of f (x, y) with respect to x

\frac {\partial f} {\partial x} = f_x

After obtaining, if partial differentiation is possible with respect to y, [higher-order (higher-order) partial derivative](http://ja.wikipedia.org/wiki/%E5%81%8F%E5%BE%AE] % E5% 88% 86 # .E9.AB.98.E9.9A.8E.E5.81.8F.E5.B0.8E.E9.96.A2.E6.95.B0)

\frac {\partial} {\partial y} \left(\frac {\partial f} {\partial x} \right) = \frac {\partial^2 f} {\partial y\partial x} = f_{xy}

Can be obtained.

Slope

Scalar field [gradient] in vector analysis (http://en.wikipedia.org/wiki/%E5%8B%BE%E9%85%8D_%28%E3%83%99%E3%82%AF%E3 You get% 83% 88% E3% 83% AB% E8% A7% A3% E6% 9E% 90% 29).

Use it for a scalar field defined in an area of space to get the ** gradient ** of the scalar function. The definition formula is as follows.

\nabla \psi = \mathrm{grad} \psi = \frac {\partial \psi} {\partial x} i + \frac {\partial \psi} {\partial y} j + \frac {\partial \psi} {\partial z} k

The downward triangle is called the nabla.

Summary

Since computers can only perform simple calculations, it is good to understand general solutions for nth-order polynomials, such as Taylor's theorem and polynomial approximation.

Recommended Posts

Differentiate a two-variable function
Make a function decorator
Create a function in Python
Try creating a CRUD function
Let's draw a logistic function
What is a callback function?
Call a Python function from p5.js.
A function that returns a random name
How to make a recursive function
[Python] Make the function a lambda function
Python-dynamically call a function from a string
Create a Python function decorator with Class
Precautions when pickling a function in python
A memorandum of using Python's input function
I had turtle draw a trigonometric function
A simple IDAPython script to name a function
Equipped with a card function using payjp