10
Comandos Básicos do Maple Fundamentos Reiniciar e/ou limpar folha de trabalho > restart: O "Ponto-e-vírgula" permiti que o resultado apareça na folha de trabalho, enquanto que o "Dois pontos" não escreve o resultado. > a:=3+2; := a 5 > b:=3+2; := b 5 > b; 5 Para atribuir um valor a uma determinada variável utiliza-se " : = " > x:=3; := x 3 > x+2; 5 Para limpar o conteúdo de uma determinada variável utiliza-se " variável : = 'variável' " > x:='x'; := x x > x+2; x 2 Definindo funções. > f:=x->2*x^2 + x - 4*x^2 - 5*x + 10; := f x 2 x 2 4 x 10 > f(1); 4 > > f(1)+f(2); -2 Função como expressão algebrica ou variável generalizada. > F:=2*x^2 + x - 4*x^2 - 5*x + 10+y^4; := F 2 x 2 4 x 10 y 4 cálculo de F(0) > subs(x=1,y=8,F); 4100 Factorização: > G:=6*x^2+18*x-24; := G 6 x 2 18 x 24 > factor(G); 6( ) x 4 ( ) x 1 > G:=18*x^2+18*x-24-alpha*x-alpha*x**2+beta*x^2; := G 18 x 2 18 x 24 x x 2 x 2 > factor(G); 18 x 2 18 x 24 x x 2 x 2 > GG:=(collect(G,x)); := GG 24 ( ) 18 x 2 ( ) 18 x Gráficos > restart: Deve-se carregar a biblioteca "plots" para o traçado de gráficos mais complexos. > with(plots); animate animate3d animatecurve arrow changecoords complexplot complexplot3d , , , , , , , [ conformal conformal3d contourplot contourplot3d coordplot coordplot3d densityplot , , , , , , , display fieldplot fieldplot3d gradplot gradplot3d graphplot3d implicitplot , , , , , , , implicitplot3d inequal interactive interactiveparams intersectplot listcontplot , , , , , , listcontplot3d listdensityplot listplot listplot3d loglogplot logplot matrixplot multiple , , , , , , , , odeplot pareto plotcompare pointplot pointplot3d polarplot polygonplot , , , , , , , polygonplot3d polyhedra_supported polyhedraplot rootlocus semilogplot setcolors , , , , , , setoptions setoptions3d spacecurve sparsematrixplot surfdata textplot textplot3d , , , , , , , tubeplot ] > f:=x^2 - 1*x + a; := f x 2 x a > a:=1; := a 1 > plot(f,x=-8..8);

Aula Maple 1era Parte

Embed Size (px)

DESCRIPTION

comandos basicos do maple, parte 1

Citation preview

Comandos Básicos do Maple

FundamentosReiniciar e/ou limpar folha de trabalho> restart:O "Ponto-e-vírgula" permiti que o resultado apareça na folha de trabalho, enquanto que o "Dois pontos" não escreve o resultado.> a:=3+2;

:= a 5> b:=3+2;

:= b 5> b;

5Para atribuir um valor a uma determinada variável utiliza-se " : = "> x:=3;

:= x 3> x+2;

5Para limpar o conteúdo de uma determinada variável utiliza-se " variável : = 'variável' "> x:='x';

:= x x> x+2;

x 2Definindo funções. > f:=x->2*x^2 + x - 4*x^2 - 5*x + 10;

:= f x 2 x2 4 x 10> f(1);

4> > f(1)+f(2);

-2Função como expressão algebrica ou variável generalizada.> F:=2*x^2 + x - 4*x^2 - 5*x + 10+y^4;

:= F 2 x2 4 x 10 y4

cálculo de F(0)> subs(x=1,y=8,F);

4100Factorização:> G:=6*x^2+18*x-24;

:= G 6 x2 18 x 24> factor(G);

6 ( )x 4 ( )x 1> G:=18*x^2+18*x-24-alpha*x-alpha*x**2+beta*x^2;

:= G 18 x2 18 x 24 x x2 x2

> factor(G);

18 x2 18 x 24 x x2 x2

> GG:=(collect(G,x));

:= GG 24 ( ) 18 x2 ( )18 x

Gráficos> restart:Deve-se carregar a biblioteca "plots" para o traçado de gráficos mais complexos.> with(plots);

animate animate3d animatecurve arrow changecoords complexplot complexplot3d, , , , , , ,[

conformal conformal3d contourplot contourplot3d coordplot coordplot3d densityplot, , , , , , ,

display fieldplot fieldplot3d gradplot gradplot3d graphplot3d implicitplot, , , , , , ,

implicitplot3d inequal interactive interactiveparams intersectplot listcontplot, , , , , ,

listcontplot3d listdensityplot listplot listplot3d loglogplot logplot matrixplot multiple, , , , , , , ,

odeplot pareto plotcompare pointplot pointplot3d polarplot polygonplot, , , , , , ,

polygonplot3d polyhedra_supported polyhedraplot rootlocus semilogplot setcolors, , , , , ,

setoptions setoptions3d spacecurve sparsematrixplot surfdata textplot textplot3d, , , , , , ,

tubeplot ]> f:=x^2 - 1*x + a;

:= f x2 x a> a:=1;

:= a 1> plot(f,x=-8..8);

> > plot(x^2 - 5*x + 3,x=-5..5);

> f1:=plot(f,x=-5..6):> f2:=plot(f-20,x=-8..5,color=blue):> display(f1,f2);

> s:=seq([k,2*k^2],k=-20..20);

s [ ],-20 800 [ ],-19 722 [ ],-18 648 [ ],-17 578 [ ],-16 512 [ ],-15 450 [ ],-14 392, , , , , , , :=

[ ],-13 338 [ ],-12 288 [ ],-11 242 [ ],-10 200 [ ],-9 162 [ ],-8 128 [ ],-7 98 [ ],-6 72, , , , , , , ,

[ ],-5 50 [ ],-4 32 [ ],-3 18 [ ],-2 8 [ ],-1 2 [ ],0 0 [ ],1 2 [ ],2 8 [ ],3 18 [ ],4 32 [ ],5 50, , , , , , , , , , ,

[ ],6 72 [ ],7 98 [ ],8 128 [ ],9 162 [ ],10 200 [ ],11 242 [ ],12 288 [ ],13 338 [ ],14 392, , , , , , , , ,

[ ],15 450 [ ],16 512 [ ],17 578 [ ],18 648 [ ],19 722 [ ],20 800, , , , ,> plot([s],style=point,title=`Seqüência de Pontos`, color=blue);

> plot3d(cos(x*y),x=-3..3,y=-3..3); > contourplot(cos(x*y),x=-3..3,y=-3..3,axes=boxed);

> implicitplot(cos(x*y)=0.5,x=-3..3,y=-3..3,numpoints=5000, axes=boxed);

Para acessar o "help" basta escrever o comando, posicionar o cursor em cima do comando e apertar F1.> plots> F:=plot(cos(x), x=-Pi..Pi, y=-Pi..Pi, style=line): G:=plot(tan(x), x=-Pi..Pi, y=-Pi..Pi, style=point): display({F, G}, axes=boxed, scaling=constrained, title=`Cosine and Tangent`);

>

Solução de Equações> restart:Resolvendo uma equação> eq1:=x+8=4;

:= eq1 x 8 4> isolate(eq1,x);

x -4O valor não está armazenado na variável. Para isto deve-se executar o comando:> assign(%);> 2+x;

-2> x:='x';

:= x x

Ou.> x1:=solve(eq1,x);

:= x1 -4Resolvendo um sistema de equações> eq1:=x+y+z=3; eq2:=x-y+3*z=5; eq3:=2*x+y-z=8;

:= eq1 x y z 3

:= eq2 x y 3 z 5

:= eq3 2 x y z 8> solve({eq1,eq2,eq3},{x,y,z});

{ }, ,z-1

4y

-5

4x

9

2> assign(%);> 2*y;

-5

2

Derivadas e Integrais> restart:Deve-se carregar a biblioteca "student" para utilizar as funções de derivadas e integrais.> with(student);

D Diff Doubleint Int Limit Lineint Product Sum Tripleint changevar, , , , , , , , , ,[

completesquare distance equate integrand intercept intparts leftbox leftsum, , , , , , , ,

makeproc middlebox middlesum midpoint powsubs rightbox rightsum showtangent, , , , , , , ,

simpson slope summand trapezoid, , , ]> g:= x -> cos(x);

:= g x ( )cos x> (Diff(g(x),x));

d

d

x( )cos x

> diff(g(x),x);

( )sin x> h:=x^2*y+x*y^2;

:= h x2 y x y2

> diff(h,x,y);

2 x 2 y> Derivadas sucessivas.> eq:=cos(n*x);

:= eq ( )cos n x> diff(eq,x);

( )sin n x n> diff(eq,x,x);

( )cos n x n2

> diff(eq,x,x,x);

( )sin n x n3

Ou.> diff(eq,x$4);

( )cos n x n4

Integrais indefinidas. O Maple não atribui a constante de integração nos resultados. Por exemplo:> int(x,x);

x2

2> int(sin(x),x);

( )cos xIntegrais definidas.> > plot(x,x=0..2);

> int(x,x=0..2);

2Integrais duplas e triplas.> int(int(x+y,x),y);

1

2x2 y

1

2x y2

> int(int(x+y,x=x0..x1),y=y0..y1);

x12 ( )y1 y0

2

x02 ( )y1 y0

2

( )x1 x0 ( )y12 y02

2> factor(%);

( )y0 y1 ( )x1 x0 ( ) x1 y0 y1 x0

2> int(int(int(x+y+z,x),y),z);

1

2x2 y z

1

2x y2 z

1

2z2 x y

Vetores e matrizes> restart:Deve-se carregar a biblioteca "LinearAlgebra" para acessar as funções.> with(linalg);

BlockDiagonal GramSchmidt JordanBlock LUdecomp QRdecomp Wronskian addcol, , , , , , ,[

addrow adj adjoint angle augment backsub band basis bezout blockmatrix charmat, , , , , , , , , , ,

charpoly cholesky col coldim colspace colspan companion concat cond copyinto, , , , , , , , , ,

crossprod curl definite delcols delrows det diag diverge dotprod eigenvals, , , , , , , , , ,

eigenvalues eigenvectors eigenvects entermatrix equal exponential extend ffgausselim, , , , , , , ,

fibonacci forwardsub frobenius gausselim gaussjord geneqns genmatrix grad, , , , , , , ,

hadamard hermite hessian hilbert htranspose ihermite indexfunc innerprod intbasis, , , , , , , , ,

inverse ismith issimilar iszero jacobian jordan kernel laplacian leastsqrs linsolve, , , , , , , , , ,

matadd matrix minor minpoly mulcol mulrow multiply norm normalize nullspace, , , , , , , , , ,

orthog permanent pivot potential randmatrix randvector rank ratform row rowdim, , , , , , , , , ,

rowspace rowspan rref scalarmul singularvals smith stackmatrix submatrix, , , , , , , ,

subvector sumbasis swapcol swaprow sylvester toeplitz trace transpose vandermonde, , , , , , , , ,

vecpotent vectdim vector wronskian, , , ]Para criar um vetor de dimensão qualquer, basta fornecer a dimensão. > a:=vector(3);

:= a ( )array , .. 1 3 [ ]Os elementos são nulos.> print(a);

[ ], ,a1 a2 a3

A não ser que defina-se os elementos do vetor.> a:=vector(6,-3);

:= a [ ], , , , ,-3 -3 -3 -3 -3 -3> a:=vector([-1,3,8,4,4,4]);

:= a [ ], , , , ,-1 3 8 4 4 4Para acessar um elemento do vetor utiliza-se o índice do elemento entre colchetes "[ ]".> a[6];

4> 2*a[2];

6> a[2]:=0;

:= a2 0

> print(a);

[ ], , , , ,-1 0 8 4 4 4Para criar uma matriz de dimensão qualquer, basta fornecer a dimensao linhas x colunas.> a:=matrix(3,3);

:= a ( )array , , .. 1 3 .. 1 3 [ ]Os elementos são nulos.

> print(a);

a ,1 1 a ,1 2 a ,1 3

a ,2 1 a ,2 2 a ,2 3

a ,3 1 a ,3 2 a ,3 3

A não ser que defina-se os elementos da matriz.> a:=matrix(3,3,-1);

:= a

-1 -1 -1-1 -1 -1-1 -1 -1

> a:=matrix([[1,1,1],[1,-1,3],[2,1,-1]]);

:= a

1 1 11 -1 32 1 -1

Para acessar um elemento da matriz utiliza-se o índice do elemento entre colchetes "[ ]".> a[2,3];

3> 2*a[2,2];

-2> b:=vector([3,5,8]);

:= b [ ], ,3 5 8> linsolve(a,b);

, ,

9

2

-5

4

-1

4> print(a);

1 1 11 -1 32 1 -1

Matriz transposta.> transpose(a);

1 1 21 -1 11 3 -1

Determinante da matriz.> det(a);

8Inversa da matriz.> inv_a:=inverse(a);

:= inv_a

-1

4

1

4

1

27

8

-3

8

-1

43

8

1

8

-1

4

Multiplicação de matrizes.> ident:=evalm(inv_a&*b);

:= ident

, ,

9

2

-5

4

-1

4Adição de matrizes.> AA:=evalm(a+inv_a):Autovalores e Autovetores de uma matriz.> a:=matrix([[1,3],[4,5]]);

:= a

1 34 5

> eigenvalues(a);

,7 -1> eigenvectors(a);

,

, ,-1 1 { }

,

-3

21 [ ], ,7 1 { }[ ],1 2

Resolvendo sistemas lineares.> A := matrix( [[1,4],[-2,1]] ); x := vector(2); b := vector( [9,0] );

:= A

1 4-2 1

:= x ( )array , .. 1 2 [ ]

:= b [ ],9 0> evalm(A)*evalm((x))=evalm(b);

1 4-2 1

[ ],x1 x2 [ ],9 0

> linsolve(A, b);

[ ],1 2> with(LinearAlgebra);

&x Add Adjoint BackwardSubstitute BandMatrix Basis BezoutMatrix, , , , , , ,[

BidiagonalForm BilinearForm CharacteristicMatrix CharacteristicPolynomial Column, , , , ,

ColumnDimension ColumnOperation ColumnSpace CompanionMatrix, , , ,

ConditionNumber ConstantMatrix ConstantVector Copy CreatePermutation, , , , ,

CrossProduct DeleteColumn DeleteRow Determinant Diagonal DiagonalMatrix, , , , , ,

Dimension Dimensions DotProduct EigenConditionNumbers Eigenvalues Eigenvectors, , , , , ,

Equal ForwardSubstitute FrobeniusForm GaussianElimination GenerateEquations, , , , ,

GenerateMatrix Generic GetResultDataType GetResultShape GivensRotationMatrix, , , , ,

GramSchmidt HankelMatrix HermiteForm HermitianTranspose HessenbergForm, , , , ,

HilbertMatrix HouseholderMatrix IdentityMatrix IntersectionBasis IsDefinite, , , , ,

IsOrthogonal IsSimilar IsUnitary JordanBlockMatrix JordanForm LA_Main, , , , , ,

LUDecomposition LeastSquares LinearSolve Map Map2 MatrixAdd, , , , , ,

MatrixExponential MatrixFunction MatrixInverse MatrixMatrixMultiply MatrixNorm, , , , ,

MatrixPower MatrixScalarMultiply MatrixVectorMultiply MinimalPolynomial Minor, , , , ,

Modular Multiply NoUserValue Norm Normalize NullSpace OuterProductMatrix, , , , , , ,

Permanent Pivot PopovForm QRDecomposition RandomMatrix RandomVector Rank, , , , , , ,

RationalCanonicalForm ReducedRowEchelonForm Row RowDimension RowOperation, , , , ,

RowSpace ScalarMatrix ScalarMultiply ScalarVector SchurForm SingularValues, , , , , ,

SmithForm StronglyConnectedBlocks SubMatrix SubVector SumBasis SylvesterMatrix, , , , , ,

ToeplitzMatrix Trace Transpose TridiagonalForm UnitVector VandermondeMatrix, , , , , ,

VectorAdd VectorAngle VectorMatrixMultiply VectorNorm VectorScalarMultiply, , , , ,

ZeroMatrix ZeroVector Zip, , ]>

&x Add Adjoint BackwardSubstitute BandMatrix Basis BezoutMatrix, , , , , , ,[

BidiagonalForm BilinearForm CharacteristicMatrix CharacteristicPolynomial Column, , , , ,

ColumnDimension ColumnOperation ColumnSpace CompanionMatrix, , , ,

ConditionNumber ConstantMatrix ConstantVector Copy CreatePermutation, , , , ,

CrossProduct DeleteColumn DeleteRow Determinant Diagonal DiagonalMatrix, , , , , ,

Dimension Dimensions DotProduct EigenConditionNumbers Eigenvalues Eigenvectors, , , , , ,

Equal ForwardSubstitute FrobeniusForm GaussianElimination GenerateEquations, , , , ,

GenerateMatrix Generic GetResultDataType GetResultShape GivensRotationMatrix, , , , ,

GramSchmidt HankelMatrix HermiteForm HermitianTranspose HessenbergForm, , , , ,

HilbertMatrix HouseholderMatrix IdentityMatrix IntersectionBasis IsDefinite, , , , ,

IsOrthogonal IsSimilar IsUnitary JordanBlockMatrix JordanForm KroneckerProduct, , , , , ,

LA_Main LUDecomposition LeastSquares LinearSolve LyapunovSolve Map Map2, , , , , , ,

MatrixAdd MatrixExponential MatrixFunction MatrixInverse MatrixMatrixMultiply, , , , ,

MatrixNorm MatrixPower MatrixScalarMultiply MatrixVectorMultiply, , , ,

MinimalPolynomial Minor Modular Multiply NoUserValue Norm Normalize, , , , , , ,

NullSpace OuterProductMatrix Permanent Pivot PopovForm QRDecomposition, , , , , ,

RandomMatrix RandomVector Rank RationalCanonicalForm, , , ,

ReducedRowEchelonForm Row RowDimension RowOperation RowSpace, , , , ,

ScalarMatrix ScalarMultiply ScalarVector SchurForm SingularValues SmithForm, , , , , ,

StronglyConnectedBlocks SubMatrix SubVector SumBasis SylvesterMatrix, , , , ,

SylvesterSolve ToeplitzMatrix Trace Transpose TridiagonalForm UnitVector, , , , , ,

VandermondeMatrix VectorAdd VectorAngle VectorMatrixMultiply VectorNorm, , , , ,

VectorScalarMultiply ZeroMatrix ZeroVector Zip, , , ]> a:=Vector(3);

:= a

000

> a:=Matrix(3,3);

:= a

0 0 00 0 00 0 0

> a:=Matrix([[1,3,-8],[-2,3,5],[1,0,4]]); b:=Matrix([[9,3,3],[1,3,2],[1,3,4]]); c:= IdentityMatrix(3);

:= a

1 3 -8-2 3 51 0 4

:= b

9 3 31 3 21 3 4

:= c

1 0 00 1 00 0 1

> := d ( )Vector ,3 1

:= d

-1-1-1

Operações com matrizes na libreria Linear Algebra;soma e resta> e := a+b-c;

:= e

9 6 -5-1 5 72 3 7

Multiplicação> a.b;

4 -12 -23-10 18 2013 15 19

Operações Mixtas> f:=(a.b-Transpose(c)).d;

:= f

32-27-46

Inversa da matriz a;> Ainv:=MatrixInverse(a);

:= Ainv

4

25

-4

25

13

2513

75

4

25

11

75-1

25

1

25

3

25

ou> ainv:=a^(-1);

:= ainv

4

25

-4

25

13

2513

75

4

25

11

75-1

25

1

25

3

25Problemas de auto-valor;> A:=Matrix([[2,0],[-1,1]]);

:= A

2 0-1 1

> Eigenvalues(A);

21

> Eigenvectors(A);

,

21

-1 01 1

> > > >

>

Estruturas condicionais e sequenciaisLoop, estrutura for;> listar os 10 primeiros números inteiros;

> for to do end doi 10> i;> end do;

1

2

3

4

5

6

7

8

9

10Criar um vetor contendo os 10 primeiros múltiplos inteiros de 2

> NI:=Vector(10):> for i to 10 do> NI[i]:=2*i;> od:> NI:Estrutura condicional IF> Identificar o elemento de maior valor absoluto na matriz e;> Nmaior:=0;

:= Nmaior 0> for i to 3 do> for j to 3 do;> if (abs(a[i,j])>=abs(Nmaior)) then> Nmaior:=a[i,j];> end if:> od: od:> Nmaior;

-8