Programming problem collection (Q31-Q35)

Question 31: Stochastic gradient descent (SGD) with one variable

Find the minimum value of the function shown below by the stochastic gradient descent method. Also, explain the algorithm and the changes in behavior when the parameters are changed.

Answer example

Question 32: Stochastic gradient descent (SGD)

Find the minimum value of the function shown below by the stochastic gradient descent method. Also, explain the algorithm and the changes in behavior when the parameters are changed.

Answer example

Question 33: Rotation

When you enter the point $ P = (x, y) $ and the angle $ t $ (degree) on the 2D Euclidean coordinates, rotate it counterclockwise by $ t $ from the origin $ O = (0, 0) $ Create a function that outputs the coordinates.

Example 33-1

P = [1, 0]
t = 45
[0.70710678, 0.70710678]

Example 33-2

P = [0, 1]
t = 30
[-0.5      ,  0.8660254]

Answer example

Q34: Regular polygon

When you enter the point $ P = (x, y) $ on the two-dimensional coordinates and the integer $ n $, the positive $ with the point $ P $ as one vertex and the origin $ O = (0, 0) $ as the center of gravity Create a function that outputs the vertices of an n $ polygon and draw its regular $ n $ polygon.

Example 34-1

P = [0, 1]
n = 5

output_7_0.png

Example 34-2

P = [0, 1]
n = 7

output_8_0.png

Answer example

Question 35: Pentagram

Line $ P_n $ and point $ P_1 $, point $ P_i $ and $ P_ {i + 1} $ for a set of regular $ n $ polygonal vertices $ P_i (i = 1 ... n) $ You can draw a regular $ n $ polygon by connecting with, but you can draw a star figure by devising the order of connecting the lines. Draw the following shape.

Example 35-1

output_11_0.png

Example 35-2

output_12_0.png

Example 35-3

mandara.png

Answer example

Recommended Posts

Programming problem collection (Q31-Q35)
Programming problem collection (Q11 to Q15)
[Python] Dynamic programming knapsack problem
Scientific Programming Petit Tech Collection in Python
[Mathematical optimization problem] Linear programming using PuLP