반응형
int_hex_str_bin

진법 표현 int hex str bin

파이썬에서 진법 표현 방법을 알아보자.

여러가지 진법 수 표현

기본적으로 숫자를 쓰면 10진수이다. 수 앞에 진법표기 접두어를 쓰면 해당 진법의 수로 인식을 한다. (숫자 0 다음에 문자 o/x/b)

  • 8진수 : 0o
  • 16진수 : 0x
  • 2진수 : 0b
i10 = 1234
i8 = 0o1234
i16 = 0x1234
i2 = 0b1010
print(i10, i8, i16, i2)
1234 668 4660 10
  • 그냥 print로 출력하면 10진수로 변환하여 출력해 준다.

여러가지 진법 수를 문자열로 변환

  • str, oct, hex, bin 함수를 사용한다.
i10 = 1234
print( str(i10), oct(i10), hex(i10), bin(i10))
1234 0o2322 0x4d2 0b10011010010

i16 = 0x4d2
print( str(i16), oct(i16), hex(i16), bin(i16))
1234 0o2322 0x4d2 0b10011010010
동일한 출력결과
  • 파라미터는 10진수일 필요없다. 아무거나 결국엔 십진수로 변수에 값이 할당되므로 같은 결과가 나온다.

포맷 스트링을 사용한 문자열 변환

  • format 함수로 사용하여 수를 진법 스트링으로(b, o, x) 변환한다.
  • 소문자면 소문자로 대문자면 대문자로 출력된다.
  • 앞에 #(샵)을 붙이면 prefix 도 출력한다.
print( format(1234, 'x'), format(1234, 'X'), format(1234, '#x'), format(1234, '#X') )
4d2 4D2 0x4d2 0X4D2
  • 출력 포맷 스트링을 사용하면 원하는 형태로 prefix를 줄 수 있다. (단, %방식은 %b를 지원하지 않는다.)
print( '%x %X 0x%x  '%(1234,1234,1234) )
4d2 4D2 0x4d2
print( '%d %o %x' % (1234,1234,1234) )
1234 2322 4d2
print( '{0:d} {0:o} {0:x} {0:b}'.format(1234,1234,1234,1234) )
1234 2322 4d2 10011010010

여러가지 진법 수 문자열을 수로 변환

print( int('0o2322', 8), int('0x4d2', 16), int('0b10011010010', 2) )
1234 1234 1234
  • 간단하게 스트링을 int로 타입 캐스팅하는데 기본이 10진수이고, 다른 진법인 경우는 진법을 명시를 해 주면 된다.

Author: crazyj7@gmail.com

'Python' 카테고리의 다른 글

파이썬 충돌해결 module conflict  (0) 2019.12.01
파이썬 개발환경/가상환경구축  (0) 2019.12.01
크롤링 BeautifulSoup 요약  (1) 2019.11.06
크롤링(Crawl) 2편  (2) 2019.10.27
웹 크롤링 Crawl 1편  (0) 2019.10.24
반응형
derivative_br_61

61. ddxx1x22+arcsinx2\frac{d}{dx} \frac{x\sqrt{1-x^2}}{2} + \frac{arcsinx}{2}

ddxx1x22+arcsinx2=12(1x2+x2x21x2+11x2)=1x2x2+121x2=22x221x2=1x21x2=1x2 \begin{aligned} &\frac{d}{dx}\frac{x\sqrt{1-x^2}}{2} + \frac{arcsinx}{2}\\ &=\frac{1}{2}(\sqrt{1-x^2}+x\frac{-2x}{2\sqrt{1-x^2}} +\frac{1}{\sqrt{1-x^2}})\\ &=\frac{1-x^2-x^2+1}{2\sqrt{1-x^2}}=\frac{2-2x^2}{2\sqrt{1-x^2}}\\ &=\frac{1-x^2}{\sqrt{1-x^2}}=\sqrt{1-x^2} \end{aligned}


62. ddxsinxcosxsinx+cosx\frac{d}{dx} \frac{sinx-cosx}{sinx+cosx}

ddxsinxcosxsinx+cosx=(cosx+sinx)(sinx+cosx)(sinxcosx)(cosxsinx)(1+2sinxcosx)=(sinx+cosx)2+(sinxcosx)2(sinx+cosx)2=1+2sinxcosx+12sinxcosx1+2sinxcosx=21+sin(2x) \begin{aligned} &\frac{d}{dx} \frac{sinx-cosx}{sinx+cosx}\\ &=\frac{(cosx+sinx)(sinx+cosx)-(sinx-cosx)(cosx-sinx)}{(1+2sinxcosx)}\\ &=\frac{(sinx+cosx)^2+(sinx-cosx)^2}{(sinx+cosx)^2}\\ &=\frac{1+2sinxcosx+1-2sinxcosx}{1+2sinxcosx}\\ &=\frac{2}{1+sin(2x)} \end{aligned}


63. ddx4x2(2x35x2)\frac{d}{dx}4x^2(2x^3 – 5x^2)

ddx4x2(2x35x2)=8x(2x35x2)+4x2(6x210x)=40x480x3=40x3(x2) \begin{aligned} &\frac{d}{dx}4x^2(2x^3 – 5x^2)\\ &=8x(2x^3-5x^2)+4x^2(6x^2-10x)\\ &=40x^4-80x^3=40x^3(x-2) \end{aligned}


64. ddx(x)(4x2)\frac{d}{dx}(\sqrt x)(4-x^2)

ddx(x)(4x2)=4x22x+x(2x)=4x24x22x=5x2+42x \begin{aligned} &\frac{d}{dx}(\sqrt x )(4-x^2)\\ &=\frac{4-x^2}{2\sqrt x}+\sqrt x(-2x)=\frac{4-x^2-4x^2}{2\sqrt x}\\ &=\frac{-5x^2+4}{2\sqrt x} \end{aligned}


65. ddx1+x1x\frac{d}{dx} \sqrt{\frac{1+x}{1-x}}

ddx1+x1x=ddx1x21x=2x(1x)21x2+1x2(1x)2=x2x+1x21x2(1x)2=1x1x2(1x)2=11x2(1x) \begin{aligned} &\frac{d}{dx}\sqrt{\frac{1+x}{1-x}}=\frac d {dx} \frac{\sqrt{1-x^2}}{1-x}\\ &=\frac{\frac{-2x(1-x)}{2\sqrt{1-x^2}}+\sqrt{1-x^2}}{(1-x)^2}\\ &=\frac{\frac{x^2-x+1-x^2}{\sqrt{1-x^2}} }{(1-x)^2} =\frac{1-x}{\sqrt{1-x^2}(1-x)^2}\\ &=\frac{1}{\sqrt{1-x^2}(1-x)} \end{aligned}


66. ddxsin(sinx)\frac{d}{dx}sin(sinx)

ddxsin(sinx)=cos(sinx)cosx \begin{aligned} &\frac{d}{dx}sin(sinx)\\ &=cos(sinx)cosx \end{aligned}


67. ddx(1+e2x)/(1e2x)\frac{d}{dx}(1+e^{2x})/(1-e^{2x})

ddx1+e2x1e2x=e2x2(1e2x)(1+e2x)(2e2x)(1e2x)2=2e2x2e4x+2e2x+2e4x(1e2x)2=4e2x(1e2x)2 \begin{aligned} &\frac{d}{dx}\frac{1+e^{2x}}{1-e^{2x}}\\ &=\frac{e^{2x}2(1-e^{2x})-(1+e^{2x})(-2e^{2x})}{(1-e^{2x})^2}\\ &=\frac{2e^{2x}-2e^{4x}+2e^{2x}+2e^{4x}}{(1-e^{2x})^2}\\ &=\frac{4e^{2x}}{(1-e^{2x})^2} \end{aligned}


68. ddx[x/(1+lnx)]\frac{d}{dx}[x/(1+lnx)]

ddxx1+lnx=1+lnxx(1/x)(1+lnx)2=lnx(1+lnx)2 \begin{aligned} &\frac{d}{dx} \frac{x}{1+lnx} \\ &=\frac{1+lnx-x(1/x)}{(1+lnx)^2}=\frac{lnx}{(1+lnx)^2} \end{aligned}


69. ddxxx/lnx\frac{d}{dx}x^{x/lnx}

ddxxx/lnxy=xx/lnx,lny=xlnxlnx=x,1ydy=dxdydx=y=xx/lnx=elnxx/lnx=e(x/lnx)lnx=ex \begin{aligned} &\frac{d}{dx}x^{x/lnx}\\ &y=x^{x/lnx}, lny=\frac{x}{lnx}lnx=x,\frac{1}{y}dy=dx\\ &\frac{dy}{dx}=y=x^{x/lnx}\\ &=e^{{lnx}^{x/lnx}}=e^{(x/lnx)lnx}=e^x \end{aligned}


70. ddxln[x21x2+1]\frac{d}{dx}ln[\sqrt{\frac{x^2-1}{x^2+1}}]

ddxln[x21x2+1]=x2+1x212x2x21x2+1x212x2x2+1x2+1=x(x2+1)x21xx21x21(x2+1)=x3+xx3+x(x21)(x2+1)=2x(x21)(x2+1) \begin{aligned} &\frac{d}{dx}ln[\sqrt{\frac{x^2-1}{x^2+1}}]\\ &=\sqrt \frac{x^2+1}{x^2-1}\frac{\frac{2x}{2\sqrt{x^2-1}}\sqrt{x^2+1}-\sqrt{x^2-1}{\frac{2x}{2\sqrt{x^2+1}}}}{x^2+1}\\ &=\frac{ \frac{x(x^2+1)}{\sqrt{x^2-1}} -x\sqrt{x^2-1} }{\sqrt{x^2-1}(x^2+1)}\\ &=\frac{x^3+x-x^3+x}{(x^2-1)(x^2+1)}=\frac{2x}{(x^2-1)(x^2+1)} \end{aligned}
Alt.
ln[x21x2+1]=12ln(x21)12ln(x2+1) ln[\sqrt{\frac{x^2-1}{x^2+1}}]=\frac{1}{2}ln(x^2-1)-\frac{1}{2}ln(x^2+1)



Author: crazyj7@gmail.com

'Math' 카테고리의 다른 글

Derivative100 [81-90]  (0) 2019.12.12
derivative100 [71-80]  (0) 2019.11.27
derivatie100 [51-60]  (0) 2019.11.18
D operator  (0) 2019.11.07
derivative100 [41-50]  (1) 2019.11.06
반응형
derivative_br_51

51. ddx10x\frac{d}{dx}10^x

ddx10x=10xln(10) \begin{aligned} &\frac{d}{dx}10^x\\ &=10^xln(10) \end{aligned}

y=ax,lny=xlna(1/y)dy=(lna)dxdy/dx=ylna=axlnaor10x=eln10x \begin{aligned} &y=a^x, lny=xlna \\ &(1/y)dy=(lna)dx \\ &dy/dx=ylna=a^xlna \\ or\\ &10^x=e^{ln10^x} \end{aligned}


52. ddxcubert(x+(lnx)2)\frac{d}{dx}cubert(x+(lnx)^2)

ddxx+(lnx)23=ddx(x+(lnx)2)1/3=13(x+(lnx)2)2/3(1+2ln(x)1x)=13(x+(lnx)2)2/3(1+2lnxx) \begin{aligned} &\frac{d}{dx}\sqrt[3]{x+(lnx)^2}\\ &=\frac{d}{dx}(x+(lnx)^2)^{1/3}=\frac{1}{3}(x+(lnx)^2)^{-2/3}(1+2ln(x)\frac{1}{x})\\ &=\frac{1}{3(x+(lnx)^2)^{2/3}}(1+\frac{2lnx}{x}) \end{aligned}


53. ddxx3/42x1/4\frac{d}{dx}x^{3/4} – 2x^{1/4}

ddxx3/42x1/4=34x1/412x3/4=3x3/44x2x1/44x=3x432x44x \begin{aligned} &\frac{d}{dx}x^{3/4} – 2x^{1/4}\\ &=\frac{3}{4}x^{-1/4}-\frac{1}{2}x^{-3/4}\\ &=\frac{3x^{3/4}}{4x}-\frac{2x^{1/4}}{4x}\\ &=\frac{3\sqrt[4]x^3-2\sqrt[4]x}{4x} \end{aligned}


54. ddxlog2(x1+x2)\frac{d}{dx}log_2 (x \sqrt{1+x^2})

ddxlog2(x1+x2)((d/dx)logax=1xlna)=1+x2+x2x21+x2x1+x2ln2=1+2x2x(1+x2)ln2 \begin{aligned} &\frac{d}{dx}log_2 (x \sqrt{1+x^2})\\ &((d/dx) log_ax=\frac{1}{xlna})\\ &=\frac{\sqrt{1+x^2}+x\frac{2x}{2\sqrt{1+x^2}}}{x\sqrt{1+x^2}ln2}\\ &=\frac{1+2x^2}{x(1+x^2)ln2} \end{aligned}


55. ddx(x1)/(x2x+1)\frac{d}{dx}(x-1)/(x^2-x+1)

ddxx1x2x+1=x2x+1(x1)(2x1)(x2x+1)2=x2x+1(2x23x+1)(x2x+1)2=x2+2x(x2x+1)2 \begin{aligned} &\frac{d}{dx} \frac{x-1}{x^2-x+1}\\ &=\frac{x^2-x+1-(x-1)(2x-1)}{(x^2-x+1)^2}\\ &=\frac{x^2-x+1-(2x^2-3x+1)}{(x^2-x+1)^2}\\ &=\frac{-x^2+2x}{(x^2-x+1)^2} \end{aligned}


56. ddx13cos3xcosx\frac{d}{dx}\frac{1}{3} cos^3x – cosx

ddx13cos3xcosx=133cos2x(sinx)+sinx=sinx(1cos2x)=sin3x \begin{aligned} &\frac{d}{dx} \frac{1}{3}cos^3x – cosx\\ &=\frac{1}{3}3cos^2x(-sinx)+sinx\\ &=sinx(1-cos^2x)=sin^3x \end{aligned}


57. ddxexcosx\frac{d}{dx}e^{xcosx}

ddxexcosx=excosx(cosxxsinx) \begin{aligned} &\frac{d}{dx}e^{xcosx}=e^{xcosx}(cosx-xsinx)\\ \end{aligned}


58. ddx(xx)(x+x)\frac{d}{dx}(x-\sqrt{x})(x+\sqrt{x})

ddx(xx)(x+x)=ddxx2x=2x1 \begin{aligned} &\frac{d}{dx}(x-\sqrt{x})(x+\sqrt{x})=\frac{d}{dx}x^2-x\\ &=2x-1 \end{aligned}


59. ddxarccot(1x)\frac{d}{dx}arccot(\frac{1}{x})

ddxarccot(1x)y=arccot1x,1x=coty,x2dx=csc2ydyR.T.,angle=y,o=x,a=1,h=x2+1dydx=x2csc2y=1x21+x2x2=11+x2(=ddxarctan(x)) \begin{aligned} &\frac{d}{dx}arccot(\frac 1 x)\\ & y=arccot \frac 1 x, \frac 1 x=cot y, -x^{-2}dx=-csc^2ydy\\ & R.T., angle=y, o=x, a=1, h=\sqrt{x^2+1} \\ & \frac {dy}{dx}=\frac {x^{-2}}{csc^2 y}=\frac{1}{x^2\frac{1+x^2}{x^2}}=\frac{1}{1+x^2} \\ &(=\frac{d}{dx}arctan(x)) \end{aligned}
Alt.
ddxarccot(x)=11+x2ddxarccot(1/x)=11+1/x2(1/x2)=1x2+1 \frac{d}{dx} arccot(x)=-\frac{1}{1+x^2}\\ \frac{d}{dx} arccot(1/x)=-\frac{1}{1+1/x^2}(-1/x^2)\\ =\frac{1}{x^2+1}


60. ddx(x)(arctanx)ln(x2+1)\frac{d}{dx}(x)(arctanx) – ln(\sqrt{x^2+1})

ddx(x)(arctanx)ln(x2+1)=arctanx+x11+x21x2+112x2+12x=arctanx+x1+x2x1+x2=arctanx \begin{aligned} &\frac{d}{dx}(x)(arctanx) – ln(\sqrt{x^2+1})\\ &=arctanx+x\frac{1}{1+x^2}-\frac{1}{\sqrt{x^2+1}}\frac{1}{2\sqrt{x^2+1}}2x\\ &=arctanx+\frac{x}{1+x^2}-\frac{x}{1+x^2}\\ &=arctan x \end{aligned}



Author: crazyj7@gmail.com

'Math' 카테고리의 다른 글

derivative100 [71-80]  (0) 2019.11.27
derivative100 [61-70]  (0) 2019.11.19
D operator  (0) 2019.11.07
derivative100 [41-50]  (1) 2019.11.06
derivative100 [31-40]  (0) 2019.11.05

+ Recent posts