Sie sind auf Seite 1von 35

Expressions, complex numbers, polynomials, and fractions in Maxima

In this Chapter we introduce Maxima functions that allow the manipulation of algebraic, logarithmic, exponential, and trigonometric expressions, among others. The chapter also presents manipulation of factorials and related functions, as well as operations with complex numbers. The Simplify menu The Simplify menu in the wxMaxima includes all the options shown in Figure 3.1. In this Chapter we will use these menu options in the simplification of algebraic, trigonometric, factorials, and complex expressions.

Figure 3.1. Simplify menu and sub menus Manipulating algebraic expressions The following items in the Simplify menu can be used to simplify algebraic expressions such as polynomials and fractions!

Simplify expression Simplify radicals Factor expression Factor complex $xpand expression $xpand logarithms Contract logarithms

e"ui#alent e"ui#alent e"ui#alent e"ui#alent e"ui#alent e"ui#alent e"ui#alent

to ratsimp() to radcan() to factor() to gfactor() to expand() to %,logexpan=super to logcontract() 3-1

Gilberto E. Urroz, 2008

To use these, and other menu items, you should ha#e the expression to be manipulated ready in the INPUT line, and then in#o&e the menu item. The following examples illustrates the use of the Simplify menu items listed abo#e. Simplify expression $nter the following expression in the INPUT line!

and select the menu item Simplify > Simplify expression to get the following output!

The result of the Simplify expression menu item is the command ratsimp 'rational simplification(, which, in this case, produced a factoring of the expression into two "uadratic expressions in x, each accompanied by other terms, such as y2z and y2, respecti#ely. In the following example, we apply the Simplify expression menu item to a sum of fractions, to produce a single fraction!

The two results abo#e suggest that any simplification in an algebraic expression in#ol#ing x and other #ariables will expand or collect terms around the x #ariable. In the following two examples x is the only #ariable in#ol#ed!

Simplify radicals Simplifies expressions in#ol#ing logarithms, exponentials, and radicals into a canonical form. The following examples illustrates applications of the menu item Simplify > Simplify radicals! 3-2
Gilberto E. Urroz, 2008

$xpression in#ol#ing exponentials!

$xpression in#ol#ing logarithms!

$xpression in#ol#ing radicals!

Factor expression Factors out algebraic expressions, as illustrated below. First, we factor a couple of polynomials!

3-3

Gilberto E. Urroz, 2008

The following example shows the factoring of a fraction!

Factor can also be applied to integers to produce their factors!

Factor complex This menu item is used to force polynomial factoring in#ol#ing complex numbers. For example, applying Factor to the following polynomial produces no factoring!

)owe#er, with Factor complex 'gfactor( produces the following factors!

*otice the difference results for the following two factorings+

Expand expression The menu item Expand expression can be applied to algebraic expressions and fractions!

3-4

Gilberto E. Urroz, 2008

To reco#er the simple fractional form use ratsimp

*,T$! To separate numerator and denominator of a fraction use functions n!m and denom, e.g.,

Expand logarit"m The Expand logarit"m menu item is a post fix operator of the form #$ logexpan%s!per& This command is used to expand a logarithm into sums or differences of logarithms, e.g.,

'ontract logarit"m The 'ontract logarit"m menu item performs the in#erse of the Expand logarit"m function, e.g.,

3-5

Gilberto E. Urroz, 2008

Factorials, combinations, and permutations The factorial, n(, of a positi#e integer number n is defined as the product! n( - n)n*+,)n*2, &&& -2+ Thus, 2( % 2+ % 2$ -( % -2+ % ., etc. In .axima, factorials are calculated by using the post fix operator (. '/ost fix means the operator is placed after the number(. Some examples are shown below!

From the definition of factorial, it follows that! n( % n)n*+,( % n)n*+,)n*2,( % n)n*+,)n*2,)n*-,( and so on. Combinations Factorials are used, for example, in combinatorial analysis for calculating the number of com/inations and perm!tations of n ob0ects ta&en r at a time, with n r. 1 combination is a selection of ob0ects in which the order in which they are selected is not important. For example, if you ha#e a collection of ob0ects 21,3,C,4,$5 and you ta&e three at a time, then selecting, say, 21,3,C5, 21,C,35, 23,1,C5, etc., corresponds to the same combination of elements since the order is not important. The tree diagram shown below illustrates all 16 combinations of the 7 elements 21,3,C,4,$5 ta&en three at a time.

3-6

Gilberto E. Urroz, 2008

The number of combinations of n elements ta&en r at a time is calculated using1! ')n$r, % n'r 1lso, ')n$r, % n'r -

n! n = . r n r ! r !

n = n n 1 n 2 ... n r 1 n r ! = n n 1 n 2 ... n r 1 nr ! r ! r! r

Thus, if n % 0 and r % -, as in the case presented abo#e, we find that ')0$-, is e"ual to!

1lternati#ely,

Maxima includes function com/ination'n$r( to calculate the number of combinations of n elements ta&en r at a time. 8sing the online "elp command '11( we find the following information about function com/ination!

/roceeding according to the information abo#e, we first load the f!ncts pac&age and then show some calculations of the number of combinations of 7 elements ta&en 1, 9, 3, and : at a time, respecti#ely!

1The notation

n r

is also referred to as the /inomial coefficient, since it represents the r*t" coefficient in the

expansion of the binomial )x2y,n&

3-7

Gilberto E. Urroz, 2008

Since the order of selection is not important when forming a combination of ob0ects, then the number of combinations of n elements ta&en n at a time is +. 1lso, the expression for ')n$n, is gi#en by n! n! C n , n = n = = =1 , n n n! n ! 0 ! n !

which leds to the interesting conclusion that 3( % +. /ermutations 1 permutation is a selection of ob0ects such that the order in which they are selected is important. Thus, if you ha#e 7 ob0ects, say, 21,3,C,4,$5, and you randomly select three of them, say, 21,C,$5, then 21,C,$5, 21,$,C5, 2C,1,$5, 2$,C,15, etc., are all permutations of those three elements. ;ou can actually produce the permutations of 21,C,$5 using the function perm!tations in Maxima!

The number of permutations of n elements ta&en r at a time is calculated using9! P)n$r, % n Pr 1lso, P)n$r, % n Pr n n 1 n 2 ... n r 1 n r ! = n n 1 n 2 ... n r 1 n r !
n! . n r !

Thus, if n % 0 and r % -, as in the case presented abo#e, we find that P)0$-, is e"ual to!

1lternati#ely,

Maxima includes functions perm!tation'n$r( to calculate the number of permutations of n elements ta&en r at a time. 8sing the online "elp command '11( we find the following information about function perm!tation. *otice that Maxima pro#ides three different online help entries related to the word perm!tation, so we ha#e to choose, by entering the proper number, which one of the three definitions we want to explore further. Choose 3 to obtain!
9The notation

n r

is also referred to as the /inomial coefficient, since it represents the r*t" coefficient in the

expansion of the binomial )x2y,n&

3-8

Gilberto E. Urroz, 2008

Since we ha#e already loaded the f!ncts pac&age 'when dealing with combinations(, we proceed to show some calculations of the number of permutations of 7 elements ta&en 1, 9, 3, and : at a time, respecti#ely!

The Gamma ( ) function The <amma function is defined by the infinite integral! z = t z1et dt
0

In Maxima, this function is calculated using gamma),, e.g.,

The <amma function for =ero and negati#e integer numbers is not defined, e.g.,

The <amma function is related to factorials as follows! n = n1 ! . The <amma function allows one to generali=e the factorial operator to non integer numbers, if we use! x ! = x 1 Some examples using Maxima are shown below!

3-9

Gilberto E. Urroz, 2008

The beta () function The beta function is defined in terms of the <amma function!
x , y = x y . x y

The beta function can also be related to factorials as!


x , y = x 1 ! y 1 ! x y 1 !

8sing Maxima the beta function is e#aluated as in the following examples!

Manipulating factorials, Gamma, and beta functions The Symplify menu in the wxMaxima interface includes the following items for manipulating factorials and relating them to the <amma and beta functions!

'on4ert to factorials This menu item can be used to con#ert expressions in#ol#ing the <amma and beta functions into factorial expressions, e.g.,

3-10

Gilberto E. Urroz, 2008

'on4ert to gamma This menu item is used to con#ert factorial expressions into <amma function expressions, e.g.,

Simplify factorials This menu item can be used to simplify selected factorial expressions such as!

'om/ine factorials This menu item is used to combine factorial expressions such as!

Manipulation of trigonometric expressions The sub menu Simplify > Trigonometric simplification offers the following items!

3-11

Gilberto E. Urroz, 2008

Simplify trigonometric This menu item utili=es the trigonometric identity sin2)x, 2 cos2)x, % + and the hyperbolic identity cos"2)x, * sin"2)x, % + to simplify expressions in#ol#ing tan$ sec$ tan"$ sec", etc., to expressions in#ol#ing only sin$ cos$ sin"$ and cos". To see examples of this command, load the demo file trgsmp&dem, i.e.,

The way this demo file is put together, as illustrated in the example abo#e, is to show a trigonometric expression, and then apply the function trigsimp to the gi#en expression to see the corresponding simplified expression. /ress 2$*T$>5 to see the rest of the demo examples. 5ed!ce trigonometric This menu item combines products and powers of trigonometric and hyperbolic sine and cosine into sine and cosine of multiples of the angle, trying to eliminate sin and cos from denominators in the case of fractions.

3-12

Gilberto E. Urroz, 2008

The following example shows that function trigred!ce acts term by term!

1t this point, we can use the menu item Simplify > Simplify expression 'ratsimp( to simplify the fractional sum to!

,ther types of reductions achie#able with trigred!ce are illustrated below!

Expand trigonometric This menu item allows expanding expressions such as sin)x2y,, sin)26x,, etc. For example!

,ne type of expansion that re"uires redefining an option in Maxima is the expansion of half angle expressions. 3y default, Maxima does not expand trigonometric functions of half angles, e.g.,

This is so because, by default, the "alfangles option is set to false!

3-13

Gilberto E. Urroz, 2008

Try setting the option "alfangles to tr!e and repeating the expansion!

'anonical form This menu item is used to produce a simplification of trigonometric expressions into a "uasi linear form, i.e., a#oiding powers of trigonometric functions as much as possible. Some examples are shown below.

1 second example!

Manipulating complex numbers and expressions The Simplify menu offers the following sub menu for the manipulation of complex numbers and expressions!

3-14

Gilberto E. Urroz, 2008

To understand the functions listed abo#e, we first pro#ide a few definitions related to complex numbers! 1 complex #ariable is a #ariable of the form z % x 2 iy$ with i2 % *+, where x and y are real numbers. The real part of z is x % 5e)z,$ while the imaginary part of z is y % Im)z,& 7rap"ical representation * 1 complex number can be represented as a point in the 8rgand9s diagram, a Cartesian coordinate system where the ordinate represents imaginary numbers. This representation is shown in the following figure!

Figure 3.9. >ectangular and polar forms of a complex number. The figure shows two different representations of the complex #ariable z, its Cartesian or rectang!lar form 'x2iy( and its polar form 'rei(. The radial distance r % ?z? -

x 2 y 2

is referred to as the mod!l!s of the complex number, while


1 % 8rg'z( - tan

y x

is referred to as the arg!ment of the complex number. The real and imaginary parts, x and y$ of the rectangular form of the complex number can be calculated in terms of the modulus and argument, r and , by using! x % r cos),, y % r sin),& 3-15
Gilberto E. Urroz, 2008

The polar form representation uses the 4e .oi#re formula for complex numbers, namely, e i = cos i sin . 1s a curious note, if one replaces = into this expression, the result is a combination of some of the most famous numbers in mathematics! e i =1 This expression in#ol#es the numbers!

e i 1

the base of the natural logarithms the unit imaginary number the ratio of the length of the circumference to its diameter the unit negati#e number

8sing the $uler formula, the e"ui#alence of the rectangular and the polar representations of a complex number becomes ob#ious! z =r e i = r cos i sin = r cos i r sin = x i y . *ext, we present some of the complex #ariable operations a#ailable in Maxima using the items in the Symplify >'omplex simplification sub menu. 'on4ert to rectform This menu item con#erts a complex expression into its rectangular form. This command can be used to show the results of complex number operations, as illustrated in these examples. First we define two complex numbers =1 and =9 and attempt an addition!

8sing the 'on4ert to rectform 'rectform( command we get!

The following examples show the command rectform applied to subtraction, multiplication, di#ision, and powers of complex numbers!

3-16

Gilberto E. Urroz, 2008

8sing actual numbers!

'on4ert to polarform This menu item con#erts a complex expression into its rectangular form. This command can be used to show the results of complex number operations, as illustrated in these examples. First we define two complex numbers z+ and z2 as follows!

In this case we use sub indices to define the #ariables t"eta:+; and t"eta:2;. The sum of the two complex numbers is a long expression in its polar form!

3-17

Gilberto E. Urroz, 2008

.ultiplications, di#isions, and powers will show more manageable expressions, although the user needs to reply to additional re"uests for information from Maxima!

The following examples use actual numbers!

3-18

Gilberto E. Urroz, 2008

7et real part This menu item extracts the real part of a complex #ariable or expression!

7et imaginary part This menu item extracts the imaginary part of a complex #ariable or expression

<emoi4re The simplest application of this menu item 'demoi4re( is to implement 4e .oi#re@s formula, e i = cos i sin , i.e.,

,ther examples are shown below!

3-19

Gilberto E. Urroz, 2008

Exponentialize This menu item is the in#erse of the <emoi4re menu item, producing the exponential form of complex expressions in#ol#ing trigonometric and hyperbolic functions, e.g.,

These two expressions, for example, show the definitions of the functions sin)z, and cos")z, in term of the real and imaginary parts, x and y. More functions for complex numbers .axima includes the following functions for manipulation of complex #ariables or expressions!

cabs carg con0ugate residue

complex absolute #alue 'modulus( complex argument complex con0ugate residue in complex plane

Ahile the modulus 'cabs( and argument 'carg( ha#e been defined before, in this section we include definitions related to the functions con=!gate and resid!e shown abo#e. The complex con=!gate of the complex number z % x 2 iy % rei is the reflection of z about the x*axis, i.e., z % x > iy % rei. The product of a complex numbers and its con0ugate is the s"uare of its modulus! z = = x2 + y2 = |z|2 = r2.

3-20

Gilberto E. Urroz, 2008

The following examples co#er applications of the functions ca/s, carg, and con=!gate for complex expressions!

1 Baurent series expansion for a complex expression re"uires a point of expansion z3& The Baurent series resembles a Taylor series expansion but it includes both positi#e and negati#e powers. The resid!e of a complex expression is the coefficient of the power ' 1( term in the expansion of the expression in a Baurent series. For additional information on Baurent series chec& out the following online lin&s! Ai&ipedia lin&! Aolfram .athworld lin&! http!CCen.wi&ipedia.orgCwi&iCBaurentDseries http!CCmathworld.wolfram.comCBaurentSeries.html

Function resid!e re"uires the complex expression being expanded, the complex #ariable, and the point of expansion, and returns the residue in the complex plane for the expression. $xamples!

3-21

Gilberto E. Urroz, 2008

Substitution and other menu items for expression manipulation The last set of functions in the Simplify menu include the following items!

S!/stit!te&&& This menu item acti#ates a dialogue form that allows the substitution of a #ariable into an expression. For example, the following two examples show the dialogue form and the resulting entry into the wxMaxima window!

Chec&ing the 2 5 5ational box in the the dialogue form implements function rats!/st 'rational s!/stitution( rather than s!/st alone. The difference, in this example, is that a rational simplification is applied to the resulting expression. )ere is another example!

3-22

Gilberto E. Urroz, 2008

1n alternati#e way to use function s!/st is to create a list of substitutions using e"ual signs, as illustrated in these examples!

E4al!ate no!n forms No!n forms, as opposite to 4er/ forms, are executable expressions in Maxima that remain une#aluated. The item menu E4al!ate no!n forms allows the e#aluation of those une#aluated expressions. To produce an une#aluated expression typically you precede it with an apostrophe. Some examples of une#aluated expressions, and their result after the E4al!ate no!n forms menu item is acti#ated, are shown below!

Toggle alge/raic flag The Maxima Man!al 'select it using ?elp > Maxima "elp( has a simple entry for the alge/raic flag. The Man!al indicates that the default #alue of the alge/raic flag is false$ and that it must be set to true 'using, alge/raic tr!e( Ein order for the simplification of algebraic integers to ta&e effect.F 3y using this menu item you can toggle the alge/raic flag between tr!e and false. To find out about the current setting use 'default set(!

3-23

Gilberto E. Urroz, 2008

8dd alge/raic e@!ality&&& This menu item acti#ates the tellrat function to produce algebraic e"uality between expressions. >efer to the Maxima Man!al for the operation of this function. 1cti#ate the Maxima Man!al using ?elp > Maxima "elp, clic& on the Index tab, and type tellrat!

Mod!l!s comp!tation&&& The menu item Mod!l!s comp!tation&&& allows the user to set the modulus for modular arithmetic calculations. The default #alue is false. The user can set the mod!l!s #alue to an integer #alue, say, 9, 3, etc. Typically the modulus is a positi#e prime number. The following references address the issue of modulus arithmetic! Ai&ipedia lin&! http!CCen.wi&ipedia.orgCwi&iC.odularDarithmetic Aolfram .athworld lin&! http!CCmathworld.wolfram.comC.odular1rithmetic.html

Some examples of modular arithmetic calculations are shown below. First, examples with mod!l!s % -

3-24

Gilberto E. Urroz, 2008

The second set of examples correspond to mod!l!s % 0!

Simple operations with polynomials In this section we pro#ide examples of functions that apply to polynomials. coeff The coeff function, coeff(p,x,n), is used to extract the coefficient of the #ariable x of order n in the polynomial p!

di4ide 'also 'alc!l!s > <i4ide polynomials&&&( The di4ide function, divide(p,q), produces the "uotient and residual of the polynomial di#ision pA@!

3-25

Gilberto E. Urroz, 2008

@!otient$ and remainder The @!otient and remainder functions, quotient(p,q) and remainder(p,q), produce, respecti#ely, the "uotient and residual of the polynomial di#ision pA@!

ratdiff The ratdiff 'rational differentiation( function, ratdiff(p,x), produces the deri#ati#e of a rational function p with respect to #ariable x!

allroots 'E@!ations > 5oots of polynomial( The allroots function, allroots(p) or allroots(p,x), calculates all the roots x of a polynomial p!

realroots 'E@!ations > 5oots of polynomial )real,( The allroots function, realroots(p) or realroots(p,x), calculates the real roots x of a polynomial p!

3-26

Gilberto E. Urroz, 2008

gcd ''alc!l!s > 7reatest common di4isor&&& ( The gcd function calculates the greatest common di#isor for two or more polynomials, e.g.,

Bet@s add one more polynomial to the gcd function!

Function gcd can also be applied to integers!

"orner Function "orner produces the expression corresponding to the )orner@s rule for e#aluating polynomials. The following example shows the )orner@s rule for a list of two polynomials!

lcm ''alc!l!s > Beast common m!ltiple &&&( The lcm function calculates the least common multiple for two polynomials, or integers. This function belongs to the f!ncts pac&age, which must be loaded before applying the function. Function lcm can be in#o&ed from the 'alc!l!s menu, howe#er, before using this menu item it is necessary to load the f!ncts pac&age. Thus, the first command to enter is! 3-27
Gilberto E. Urroz, 2008

The following example shows function lcm applied to pairs of numbers!

*ext, we apply function lcm to a pair of polynomials!

*,T$ 1! Function lcm belongs to pac&age f!ncts which contains a number of other useful functions that apply to polynomials and numbers. The contents of pac&age f!ncts are presented in a section at the end of this Chapter. *,T$ 9! For additional information on polynomials acti#ate the Maxima Man!al '?elp > Maxima "elp( and find the Polynomial chapter in the 'ontents tab.

3-28

Gilberto E. Urroz, 2008

Simple operations with fractions In this section we pro#ide examples of functions that apply to fractions. com/ine The com/ine function can be used to collect fractions with the same denominator!

partfrac ''alc!l!s > Partial fractions&&&( The partfrac function decomposes a single fraction into its partial fractions!

cfdisrep ''alc!l!s > 'ontin!ed fraction( The cfdisrep function is used to produce a continued fraction gi#en the coefficients of those fractions as illustrated in this example!

3-29

Gilberto E. Urroz, 2008

Functions in the functs pac age This section presents examples of functions in the f!ncts pac&age. The descriptions of the functions was ta&en from the Maxima online help facility for f!ncts, i.e.,

Interestingly enough, function lcm, which was presented in an earlier section, is not included in the help entries for f!ncts. rempart 'expr, n( >emo#es part n from the expression expr. If n is a list of the form 2l$m5 then parts l through m are remo#ed.

wrons&ian '2f+$ &&&$ fn5, x( >eturns the Arons&ian matrix of the functions f+$ &&&$ fn in the #ariable x. f+$ &&&$ fn may be the names of user defined functions, or expressions in the #ariable x.

3-30

Gilberto E. Urroz, 2008

tracematrix'M( >eturns the trace 'sum of the diagonal elements( of matrix M.

rational'z( .ultiplies numerator and denominator of z by the complex con0ugate of denominator, thus rationali=ing the denominator.

1 similar result is obtained by using function rectform!

gcdi#ide'p$@( Ahen taCegcd is tr!e, gcdi4ide di#ides the polynomials p and @ by their greatest common di#isor and returns the ratio of the results.

3-31

Gilberto E. Urroz, 2008

Ahen taCegcd is false, gcdi4ide returns pA@.

arithmetic 'a$d$n( >eturns the n th term of the arithmetic series a$ a2d$ a22d$ &&&$ a2)n*+,d&

geometric 'a$r$n( >eturns the n th term of the geometric series a$ ar$ ar2$ &&&$ arn*+.

harmonic 'a$/$c$n( >eturns the n th term of the harmonic series aA/$ aA)/2c,$ aA)/22c,$ &&&$ aA)/2)n*+,c(.

arithsum 'a$d$n( >eturns the sum of the arithmetic series from + to n.

geosum 'a$r$n( >eturns the sum of the geometric series from + to n. If n is infinity 'inf( then a sum is finite only if the absolute #alue of r is less than 1.

gaussprob 'x( >eturns the <aussian probability function G%eH' xH9C9(Cs"rt'9I%pi(@, i.e., the standard normal probability density function 'pdf(. 3-32
Gilberto E. Urroz, 2008

)ere is a list of ordinates of the standard normal pdf!

)ere is a list of probabilities of the inter#als *+ D x D +$ *2 D x D 2$ and *- D x D -$ respecti#ely,

*otice that integrals of the ga!sspro/'x( function are gi#en in terms of the error f!nction 'erf(. To find out about the error function chec& the Maxima online help!

Finally, a plot of the standard normal pdf is shown below! 3-33


Gilberto E. Urroz, 2008

gd 'x( >eturns the <udermannian function G9 I atan'%eHx %piC9(@.

agd 'x( >eturns the in#erse <udermannian function Glog 'tan '%piC: J

xC9(((@.

#ers 'x( >eturns the #ersed sine G1 cos 'x(@.

3-34

Gilberto E. Urroz, 2008

co#ers 'x( >eturns the co#ersed sine G1 sin 'x(@.

exsec 'x( >eturns the exsecant Gsec 'x( 1@.

ha# 'x( >eturns the ha#ersine G'1 cos'x((C9@.

3-35

Gilberto E. Urroz, 2008

Das könnte Ihnen auch gefallen