반응형

 

사람이 수학에서 쓰는 표현 방식으로 나타낼 수 있다.

'''
고급수학 숫자 형식처럼 출력하기.
[10.1f]  에서 10은 숫자표시, 1은 소숫점 이하 자리 정밀도 표시
[10.2e]  에서 10은 숫자표시, e는 10의 몇 승으로 표시.
'''

pi = 3.14159

print(format(pi,"10.1f"))   # 소숫점 자릿수 표현.
print(format(pi,"10.3f"))
print(format(pi,"10.5f"))
print("\n")
print(format(pi,"10.1e"))   # 10의 몇승으로 표현.
print(format(pi,"10.3e"))
print(format(pi,"10.5e"))
print("\n")
print(format(300,"10d"))    # 앞에 공백을 10자리 포함.
print(format(300,"5d"))

 

(결과)

 

 

 

반응형
반응형

 

미분하는 함수 라이브러리를 사용하기 위해서는 sympy 가 필요하다.

cmd로 다운로드 한다.

pip install sympy

sympy 설치 완료

코드

import math
from sympy import symbols, Limit    # pip install sympy

x, a, h = symbols('x, a, h')

fx = 3 * (x**2) - 4 * x + 1     # 함수 f(x) 정의
fxa = fx.subs({x: a})           # f(x)에 x = a 대입
fxh = fx.subs({x: a + h})       # f(x)에 x = a + h 대입

result = Limit( (fxh - fxa)/h, h, 0 ).doit()     # 극한값(미분계수) 계산

print(fx)
print(fxa)
print(fxh)

print("미분 Result:", result)

 

미분이 잘 되었는가 결과 확인을 위해 미분을 자동으로 해주는 사이트를 이용했다.

www.derivative-calculator.net/

 

Derivative Calculator • With Steps!

Above, enter the function to derive. Differentiation variable and more can be changed in "Options". Click "Go!" to start the derivative calculation. The result will be shown further below. How the Derivative Calculator Works For those with a technical back

www.derivative-calculator.net

아래 함수를 미분하면, 아래와 같은 결과가 나온다.

 

 

(결과) 잘 미분 되었다.

 

반응형
1

+ Recent posts