Introduction to Computer Algebra Systems

Post on 05-Dec-2014

2.538 views 4 download

description

This presentation gives a brief overview of the capabilities of software packages known as 'computer algebra systems'. The stress is on symbolic and graphic computations. Maple is used as a vehicle to illustrate the concepts.

Transcript of Introduction to Computer Algebra Systems

Computer Algebra Systems

Dr. V. N. KrishnachandranDepartment of Computer Applications

Vidya Academy of Science and TechnologyThrissur – 680 501

1

Outline

IntroductionNumerical computations

Symbolic computations

Some popular CAS’s : Maple, Matlab, …

Maple in actionMaple syntax

Algebra with Maple

Calculus with Maple

Differential equations with Maple

Maple packages

LinearAlgebra package

inttrans package

Graphics with Maple

2

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Introduction

3

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

A CAS is a software package having capabilities for

• numerical computations

• symbolic computations

• graphical computations

Computer Algebra Systems

4

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Introduction

Numerical computations

5

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Numerical computation

glT π2=

g = 981, π = 3.14, l = 51.5 .

Let

Find T when

Example 1

Use logarithm tables or an electronic calculator to calculate this expression and get .T = 1.439

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Numerical computation

∫−

1

0

2

2

dxex

Evaluate the following integral using trapezoidal rule:

Example 2

7

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Introduction

Symbolic computations

8

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Symbolic computation

Solve the quadratic equation:

0)()()( 2 =−+−+− acxcbxba

Example 3

Solution :

baacx

−−

= ,1

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Symbolic computation

Obtain the general solution of the differential equation:

baxdxdyp

dxyd

+=+2

2

Example 4

10

(See next slide for solution)

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Symbolic computation

Complementary Function = px21 eCC −+

Particular Integral = ⎟⎠⎞

⎜⎝⎛

⎟⎠⎞

⎜⎝⎛ −+ x

pabx

2a

p1 2

y = C. F. + P.I.

Example 4 : Solution

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Introduction

Graphical computations

12

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Graphical computation

( ) ( ) ( )3 ,5for

3/1223/23/2

==−=+

bababyax

Draw the curve:Example 5

13

(See next slide for solution)

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Graphical computation

14

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Graphical computation

)3(sin32 θ−=r

Draw the curve (polar coordinates):Example 6

15

(See next slide for solution)

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Graphical computation

16

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Graphical computation

zyx =− 22

Plot the surface:Example 7

17

(See next slide for solution)

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Graphical computation

18

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Introduction

Some popular CAS’s

19

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Some popular CAS’s

20

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Some popular CAS’s

21

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Some popular CAS’s

22

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Symbolic Math Toolbox in

Some popular CAS’s

23

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Maple in action

24

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Maple in action

Maple syntax

25

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Operation Symbol Example

Addition + a + b

Subtraction - a - b

Multiplication * a*b

Division / a/b

Exponentiation ^ (**) a^b(a**b)

Maple syntax

26

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Math Maple Math Maple

sin x sin(x) sin -1 x arcsin(x)

cos x cos(x) cos -1 x arccos(x)

tan x tan(x) tan -1 x arctan(x)

sec x sec(x) sec -1 x arcsec(x)

cosec x csc(x) cosec -1 x arccsc(x)

cot x cot(x) cot -1 x arccot(x)

Maple syntax

27

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Math Maple

log x log(x)

|x | abs(x)

e^x exp(x)

√x sqrt(x)

Maple syntax

28

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Maple syntax

Example 8Mathematical expression

⎟⎠⎞

⎜⎝⎛

++++ −

216ax

axx1cbxe logsin)(cos

Maple expression:exp(a*x)*(cos(b*x+c))^6 + arcsin( sqrt(1 + log(x/(x+a^2)) ) )

29

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Maple in action

Algebra with Maple

30

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Algebra

Maple input> F:=expand((x-2*x^2*y)^3);

Example 9Expand the following and assign the expression to F:

31

( )322 yxx −

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Algebra

Example 9 (continued)Maple output:

32

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Example 10To solve the quadratic equation

Maple input> solve( (a-b)*x^2+(b-c)*x+(c-a)=0,x);

0acxcbxba 2 =−+−+− )()()(

Algebra

33

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Algebra

Example 10 (continued)Maple output:

34

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Algebra

Example 11Solve the cubic equation

Maple input> solve(2*x^3+3*x^2-x+5=0,x);

= + − + 2 x3 3 x2 x 5 0

35

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Algebra

36

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Algebra

Example 12To find the solutions as floatingpoint numbers:

37

Maple input> evalf(%);

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Algebra

Example 12 (continued)Maple output:

38

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Maple in action

Calculus with Maple

39

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

∂∂y ( )f , ,x y z

Maple input:> diff( f(x,y,z) , y );

Differentiation

General format to evaluate derivatives:

To find

40

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Let us consider the function:

Maple input> f := x^2 * exp(-z) + (2*y^3 - x) * arctan(x/z);

= ( )f , ,x y z + x2 e( )−z

( ) − 2 y3 x ⎛⎝⎜⎜

⎞⎠⎟⎟arctan

xz

41

Differentiation

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Example 13To obtain the derivative of f with respect to x

Differentiation

42

Maple input> diff(f,x);

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Example 13 (continued)

Maple output:

43

Differentiation

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Example 14

Maple input> diff(f, y, z) ;

∂ ∂∂ 2

y z ( )f , ,x y z

To find

44

Differentiation

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Example 14 (continued)Maple output:

45

Differentiation

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Maple input> taylor( x/((x+1)*(x-2)), x=1, 4);

x( ) + x 1 ( ) − x 2

46

Differentiation

Example 15To obtain the taylor series

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Example 15 (continued)Maple output:

47

Differentiation

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Integration

The general format for evaluating indefinite integrals: To find

Maple input> int(f(x),x);

48

dxxf∫ )(

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Integration

Maple input> int(x^2 - sin(x), x);

( )dxxx∫ − )sin(2

49

Example 16A simple example:

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Integration

50

Example 16 (continued)Maple output:

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Integration

Maple input> int( (a*x+b)/sqrt(p*x^2+q*x+r) , x );

51

dxrqxpx

bax∫

++

+2

Example 17A very complicated integral

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

52

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Integration

Maple input> int(x^x,x);

∫ dxx x

53

Example 18Sometimes Maple may not be able to obtain an explicit expression for an integral.

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Integration

Example 18 (continued)Maple output:

54

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

The general format for evaluating definite integrals: To find

Maple input:> int ( f(x) , x=a..b );

Integration

55

∫b

a

dxxf )(

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Integration

Example 19Evaluate:

Maple input> int(x/(1+x^2), x = 0 .. 1);

56

∫ +

1

021

dxx

x

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Integration

Example 20Limits can contain (Pi) and (infinity)

Maple input> int(x*sin(n*x), x=-Pi/2 .. Pi/2);

π ∞

∫−

2/

2/

)sin(π

π

dxnxx

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Integration

58

Example 20 (continued)Maple output

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Maple in action

Differential equations with Maple

59

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Differential equations

Example 21First order equations

Maple input> dsolve( x*diff(y(x), x) + y(x) = x );

60

xydxdyx =+

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Differential equations

Example 21 (continued)Maple output

61

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Differential equations

Example 22Second order equations

Maple input> dsolve( diff(y(x),x,x)+a^2*y(x)=x);

62

xyadx

yd=+ 2

2

2

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Differential equations

Example 22 (continued)Maple output

63

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Maple in action

Maple packages

64

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Packages

Some packages

combinat combinatorial functions

inttrans integral transforms

LinearAlgebra Linear algebra

networks graph networks

numtheory number theory

plots displaying graphs 65

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Maple in action

LinearAlgebra package

66

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

LinearAlgebra package

This is a collection of functions for symbolic computations involving vectors and matrices.

67

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

LinearAlgebra package

Load LinearAlgebra package> with(LinearAlgebra);

68

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

LinearAlgebra package

To define the matrix

Maple input>A:=Matrix([[1, -3, 4],[2, 3, 4],[-4, 0, 5]]);

⎢⎢⎢⎢⎢

⎥⎥⎥⎥⎥

1 − 3 42 3 4

− 4 0 5

69

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

LinearAlgebra package

Example 23

To find the inverse of A

70

Maple input> MatrixInverse(A);

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

LinearAlgebra package

Example 24To find the characteristic polynomial in terms of lambda

71

Maple input> CharacteristicPolynomial(A,lambda);

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

LinearAlgebra package

Example 25To find the eigen values of A

72

Maple input> Eigenvalues(A);

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Maple in action

inttrans package

73

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

inttrans package

The inttrans package is a collection of functions designed to compute integral transforms like Laplace transforms and Fourier transforms.

74

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

inttrans package

To load inttrans packge> with(inttrans);

75

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

inttrans package

Example 26To find the Laplace transform of

Maple input> laplace(t^2*sin(3*t)*exp(-4*t), t, s);

76

tett 42 )3sin( −

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

inttrans package

Example 27To find the inverse Laplace transform of

Maple input> invlaplace(s/((s^2+s+1)^2), s, t);

77

( )22 1++ sss

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Maple in action

Graphics with Maple

78

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Graphics

Example 28To plot the graph of the function

Maple input> plot( x**3 – x + 5 , x = -2..2 );

79

53 +− xx

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

80

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Graphics

Example 29To plot the surface given by the function

Maple input> plot3d(sin(x*y), x=-Pi..Pi, y=-Pi..Pi);

81

)sin(),( xyyxf =

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

82

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Graphics:plots package

To use the plots package> with(plots);

83

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Graphics:plots package

Example 30To plot the curve given by the equation

Maple input> implicitplot(x^3 + y^3 = 3*x*y, x = -2..2, y = -2..2);

84

xyyx 333 =+

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

85

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

Graphics:plots package

Example 31To plot the surface given by the equation

Maple input> implicitplot3d( x^3 + y^3 + z^3 +1 = (x+y+z+1)^3, x=-2..2, y=-2..2, z=-2..2);

86

3333 )1(1 +++=+++ zyxzyx

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

87

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501

THANK YOU …

88

Introduction to Computer Algebra Systems

V. N. Krishnachandran, Vidya Academy of Science and Technology, Thrissur - 680501