Skip to content

Commit

Permalink
added labs 1,2,3
Browse files Browse the repository at this point in the history
  • Loading branch information
KostyaBay committed Dec 8, 2021
1 parent bca865a commit b398cd6
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
Binary file added MathMod/lab_1/Math-mod-Baievskyi-93.xlsx
Binary file not shown.
9 changes: 9 additions & 0 deletions MathMod/lab_2/baievskyi_lab2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from scipy.optimize import linprog

z = [2, -1, 3, -2, 1]
lhs_ineq = [[-1, 1, 1, 0, 0], [1, -1, 0 , 1, 0], [1, 1, 0, 0, 1]]
rhs_ineq = [1, 1, 2]

opt = linprog(c = z, A_eq = lhs_ineq, b_eq = rhs_ineq,
method = "revised simplex")
print(opt)
27 changes: 27 additions & 0 deletions MathMod/lab_3/baievskyi_lab3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#Monte Carlo
import random
import matplotlib.pyplot as plt
import math

INTERVAL = 100000
x = []
y = []

rectangle = 0
for i in range(INTERVAL):
rand_x= random.uniform(0, 4)
x.append(rand_x)
rand_y= random.uniform(0, 4)
y.append(rand_y)
if((0 <= rand_x) and (rand_x <= 1) and (0 <= rand_y) and (rand_y <= 3)):
rectangle += 1
if((1 <= rand_x) and (rand_x <= 2) and (1 <= rand_y) and (rand_y <= 3)):
rectangle += 1
if((2 <= rand_x) and (rand_x <= 4) and (1 <= rand_y) and (rand_y <= 2)):
rectangle += 1
if((3 <= rand_x) and (rand_x <= 4) and (0 <= rand_y) and (rand_y <= 1)):
rectangle += 1
plt.scatter(x, y)
result = (rectangle * 16)/ INTERVAL
print(rectangle, result)
plt.show()

0 comments on commit b398cd6

Please sign in to comment.