2020-수학-가형-홀수-17¶
문제¶
풀이¶
from sympy import *
x, y = symbols('x y')
P = Point(x,y)
A = Point(0,5*sqrt(3))
B = Point(-5,0)
C = Point(5,0)
eqn = P.distance(B) - P.distance(C)-2
eqn
\[\displaystyle - \sqrt{y^{2} + \left(x - 5\right)^{2}} + \sqrt{y^{2} + \left(x + 5\right)^{2}} - 2\]
sol = solve(eqn,x)
sol
[-sqrt(6*y**2 + 144)/12, sqrt(6*y**2 + 144)/12]
import random
y_val = round(random.uniform(-100,100),4)
x_val = sol[1].subs(y,y_val)
min_distance = A.distance(Point(x_val,y_val))
P_is_not_stable = True
print([("x_val","y_val"), "new distance", "new area"])
while P_is_not_stable:
init_y = y_val
for y_delta in [10,-10, 1,-1, 0.5, -0.5, 0.1,-0,1, 0.01,-0.01, 0.001,-0.001,0.0001,-0.0001] :
y_temp = round(y_val+y_delta,4)
x_temp = sol[1].subs(y,y_temp)
P_temp = Point(x_temp,y_temp)
dist = A.distance(P_temp)
if dist < min_distance:
area = abs(Triangle(P_temp, B, C).area)
min_distance = dist
x_val = x_temp
y_val = y_temp
print(["new P found!", (x_val,y_val), dist.evalf(), (area/sqrt(3)).evalf()])
break
if init_y == y_val:
print("P is stable!")
print(["area of PBC divided by sqrt(3):", (area/sqrt(3)).evalf()])
P_is_not_stable = False
area/sqrt(3).evalf()
[('x_val', 'y_val'), 'new distance', 'new area']
['new P found!', (6.84580095536064, -33.1777), 42.3943320361720, 95.7757701304632]
['new P found!', (4.83565652768577, -23.1777), 32.2030882272126, 66.9082566709819]
['new P found!', (2.86975447040625, -13.1777), 22.0257060563202, 38.0407432115007]
['new P found!', (1.19194828764367, -3.1777), 11.8978105768470, 9.17322975201937]
['new P found!', (1.71444569868806, 6.8223), 2.51344367332520, 19.6942837074619]
['new P found!', (1.88401584930081, 7.8223), 2.06196088468146, 22.5810350534100]
['new P found!', (1.97125887537634, 8.3223), 2.00001862127464, 24.0244107263841]
['new P found!', (1.96950005595752, 8.3123), 2.00000062071713, 23.9955432129246]
['new P found!', (1.96967591338017, 8.3133), 2.00000007703163, 23.9984299642706]
['new P found!', (1.96985177625543, 8.3143), 2.00000005417938, 24.0013167156165]
['new P found!', (1.96983418972258, 8.3142), 2.00000003302710, 24.0010280404819]
['new P found!', (1.96981660324424, 8.3141), 2.00000001708316, 24.0007393653473]
['new P found!', (1.96979901682041, 8.314), 2.00000000634755, 24.0004506902127]
['new P found!', (1.96978143045110, 8.3139), 2.00000000082027, 24.0001620150781]
['new P found!', (1.96976384413631, 8.3138), 2.00000000050133, 23.9998733399436]
P is stable!
['area of PBC divided by sqrt(3):', 23.9998733399436]
\[\displaystyle 23.9998733399436\]