카테고리 없음

소설에쓸 내용 검토

TaxosDevloper 2025. 3. 17. 08:30

소설에서 천사가 인간들에게 빛이 담긴 구를 선물해주는대, 이것이 블랙홀이 되지 않도록 하는 방법을 구해야 한다.......

먼저 슈바르츠실트 블랙홀이 반들어지는 조건은
아래 식을 만족하면 된다.

슈바르츠실트 반지름을 구하는 식
r = 2GM/c² = (2G/c²)M

SI단위계에 미터의 정의에 따라서
c = 299792458 m/s 로
2/c²
= 2/299792458 × 1/299792458 × s²/m²
= 1/149896229 × 1/299792458 × s²/m²
= 1/(149896229 × 299792458) × s²/m²
= 1/44937758936840882 s²/m²

슈바르츠실트
반지름과
질량의
비 ㅅ = 1/44937758936840882 G s²/m²

기억하자, 상수 ㅅ은 슈바르츠실트 반지름과 질량의 비다.

해당 구가 운동할때, 블랙홀이 되는 최고 속도는

운동에너지를 가질때 증가하는 질량은
절대적 최고속도인 c에대한 v의 비를 속도로 생각해서 (그래도 되는건진 모르겠제만)
Ek = ½mv²
m + Ek/c²
= m + m × ½(v/c)²
= m(1 + ½(v/c)²)
½(v/c)²만큼 증가하는데 이걸 버틸수 있나.....
아니 운동에너지 더하라는건 GPT가 알려준건데 믿기 빡세네

5cm = 0.05m


소수가 나와서 말인데
44937758936840882 좀 소인수분해 하겠다

def fac(x):
	p = 2
	if x == 1: yield 1
	elif x == 0: yield 0
	elif x == -1: yield -1
	elif x < -1:
		yield -1
		yield from fac(-x)
	else:
		while not (x & 1):
			yield 2
			x >>= 1
		while x != 1:
			p += 1
			while not (x % p or x == 1):
				yield p
				x //= p

#왜지... C언어가 나은것 같다...

어...? 그리 오래 걸리지도 않네...

list(fac(44937758936840882)) -> [2, 7, 7, 73, 73, 293339, 293339]

테스트 해야징...

from time import time as t
from functools import wraps as _smartdeco_lab

def jammin_banchmark(func):
	@_smartdeco_lab(func)
	def jbanf(*argv, **kargv):
		start = end = 0
		try:
			start, ret, end = t(), func(*argv, **kargv), t()
		except Exception as err:
			raise err
		else:
			return ret
		finally:
			print(end - start)
	return jbanf

>>> print(list(fac(44937758936840882))) #decorated
9.775161743164062e-06
[2, 7, 7, 73, 73, 293339, 293339]

뭐지...?

Python 3.12.9 (main, Feb  4 2025, 22:30:28) [Clang 18.0.3 (https://android.googlesource.com/toolchain/llvm-project d8003a456 on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from time import time as t
>>> from functools import wraps as _smartdeco_lab
>>>
>>> def jammin_banchmark(func):
...     @_smartdeco_lab(func)
...     def jbanf(*argv, **kargv):
...             start = end = 0
...             try:
...                     start, ret, end = t(), func(*argv, **kargv), t()
...             except Exception as err:
...                     raise err
...             else:
...                     return ret
...             finally:
...                     print(end - start)
...     return jbanf
...
>>> @jammin_banchmark
... def fac(x):
...     p = 2
...     if x == 1: yield 1
...     elif x == 0: yield 0
...     elif x == -1: yield -1
...     elif x < -1:
...             yield -1
...             yield from fac(-x)
...     else:
...             while not (x & 1):
...                     yield 2
...                     x >>= 1
...             while x != 1:
...                     p += 1
...                     while not (x % p or x == 1):
...                             yield p
...                             x //= p
...
>>> print(list(fac(44937758936840882)))
1.049041748046875e-05
[2, 7, 7, 73, 73, 293339, 293339]

아니 진짜...?

Python 3.12.9 (main, Feb  4 2025, 22:30:28) [Clang 18.0.3 (https://android.googlesource.com/toolchain/llvm-project d8003a456 on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from time import perf_counter as t
>>> from functools import wraps
>>>
>>> def jammin_banchmark(func):
...     @wraps(func)
...     def jbanf(*args, **kwargs):
...         start = t()
...         ret = func(*args, **kwargs)
...         end = t()
...         print(f"Execution time: {end - start:.10f} sec")...         return ret
...     return jbanf
...
>>> @jammin_banchmark
... def fac(x):
...     if x < 0:
...         yield -1
...         x = -x
...     while x % 2 == 0:
...         yield 2
...         x //= 2
...     p = 3
...     while p * p <= x:
...         while x % p == 0:
...             yield p
...             x //= p
...         p += 2
...     if x > 1:
...         yield x
...
>>> print(list(fac(44937758936840882)))
Execution time: 0.0000043230 sec
[2, 7, 7, 73, 73, 293339, 293339]

아니 이게 빠를수 있다고 ..? ㅋㅋ