¼ö½ÄÀ» ´Ù·ç±â À§Çؼ sympy ¸ðµâÀ» ºÒ·¯µéÀδÙ.
from sympy import *
init_printing() # ¼ö½ÄÀ» º¸±âÁÁ°Ô Ãâ·ÂÇÏ´Â ÇÔ¼ö¸¦ È£ÃâÇÑ´Ù
º¯¼ö $x \,\, y \, \, z$ ¸¦ »ç¿ëÇÏ·Á¸é, symbols( ) ÇÔ¼ö·Î ±âÈ£µéÀ» ¼±¾ðÇØ¾ß ÇÑ´Ù.
x, y, z = symbols('x y z')
´ÙÇ×½Ä $\,A = -3xy + x^2 + 2y^2 +x $ ¸¦ ÀÔ·ÂÇÑ´Ù.
A = -3*x*y + x**2 + 2*y**2 + x
$x$ ´Â ±âÈ£(symbol)·Î¼ »ç¿ëÇϱâ Àü¿¡ ¼±¾ðÇßÁö¸¸, ¼ö½Ä $A$ ´Â ¹Ì¸® ¼±¾ðÇÏÁö ¾Ê°í ¹Ù·Î »ç¿ëÇÏ¿´´Ù.
À§¿¡¼ $x$ ¿Í °°ÀÌ ±âÈ£·Î ¾²ÀÌ´Â º¯¼ö´Â, ±× º¯¼ö¿¡ ´ëÇÏ¿© Çظ¦ ±¸Çϰųª, ¹ÌÀûºÐÀ» ±¸ÇÏ´Â µî ¼öÇÐÀÇ ±âº»ÀûÀÎ µ¶¸³ º¯¼ö¸¦ ³ªÅ¸³½´Ù.
µ¶¸³ º¯¼öÀÇ ÇÔ¼ö·Î¼, ±× Ç¥ÇöÀÌ ¸í½ÃÀûÀ¸·Î ÁÖ¾îÁö´Â Á¾¼Ó º¯¼ö ( À§ÀÇ ¿¹¿¡¼ $A(x,y)$ ) ´Â ¹Ì¸® ¼±¾ðÇÏÁö ¾Ê´Â´Ù.
´ÙÇ×½Ä $A$ ÀÇ ³»¿ëÀ» Ãâ·ÂÇØ º¸ÀÚ.
A
´ÙÇ×½Ä $A$ ¸¦ $x$ ¿¡ ´ëÇÏ¿© Á¤¸®ÇÑ´Ù. $\quad$ collect( ) ÇÔ¼ö
collect( A, x )
´ÙÇ×½ÄÀÇ µ¡¼ÀÀ» °è»êÇÑ´Ù.
$(5x^3-x^2+3x-1 ) + (-x^3+2x^2+5 ) $
( 5*x**3 - x**2 + 3*x - 1 ) + ( -x**3 + 2*x**2 + 5 )
´ÙÇ×½ÄÀ» Àü°³ÇÑ´Ù. $\quad$ expand( ) ÇÔ¼ö
$(x^2+x-2 ) \, (3x-1 ) $
expand( ( x**2 + x - 2 ) * ( 3*x - 1 ) )
°ö¼À °ø½ÄÀ» È®ÀÎÇÑ´Ù.
$(a+b+c)^2 = a^2+b^2+c^2+2ab+2bc+2ca$
a, b, c = symbols('a b c')
expand( ( a + b + c )**2 )
´ÙÇ×½ÄÀ» ÀμöºÐÇØÇÑ´Ù. $\quad$ factor( ) ÇÔ¼ö
$x^3-3x+2 = (x-1)^2 \, (x+2) $
factor( x**3 - 3*x + 2 )
´ÙÀ½ ´ÙÇ×½ÄÀ» ÀμöºÐÇØÇÑ´Ù.
$2x^2+5xy+3y^2+3x+5y-2 $
factor( 2*x**2 + 5*x*y + 3*y**2 + 3*x + 5*y - 2 )
À¯¸®½ÄÀ» ¾àºÐÇÑ´Ù. $\quad$ cancel( ) ÇÔ¼ö
$$\frac {x^2-2x+1} {x^2-3x+2} $$( x**2 - 2*x + 1 ) / ( x**2 - 3*x + 2 )
cancel( ( x**2 - 2*x + 1 ) / ( x**2 - 3*x + 2 ) )
´ÙÀ½ À¯¸®½ÄÀ» °è»êÇÑ´Ù. $\quad$ cancel( ) ÇÔ¼ö
$$\frac 1 {x-1} + \frac 2 {x+2} $$cancel( 1/(x-1) + 2/(x+2) )
À§ÀÇ °á°ú¸¦ ÀμöºÐÇØ ÇÑ´Ù. $\quad$ factor( ) ÇÔ¼ö
factor( _ )
¹ØÁÙ ' _ ' Àº ¹Ù·Î Á÷ÀüÀÇ Ãâ·ÂÀ» °¡¸®Å²´Ù.
´ÙÀ½ À¯¸®½ÄÀ» °£´ÜÈ÷ ÇÑ´Ù. $\quad$ simplify( ) ÇÔ¼ö
$$\frac {x-1+ \frac 1 {x-1} } {x-1- \frac 1 {x-1} } $$A = ( x - 1 + 1/(x-1) ) / ( x - 1 - 1/(x-1) )
A
simplify( A )