Aula Prática de TFCOMP-II

Começem por criar e guardar em disco um Notebook com o nome TFC_grupo.nb, onde 'grupo' é o nome do vosso grupo de trabalho. Neste Notebook criem uma célula de título identificando os elementos constituintes do grupo (nome, número e contactos).

Defina a variável $Post  de forma a formatar com TableForm todos os resultados do tipo List apenas. Experimente definir algumas matrizes e vectores, e veja como aparecem em Output . (Faça Clear[$Post] antes de passar ao problema seguinte.)

Preencha com exemplos originais a seguinte tabela de "alias" para operadores do Mathematica.  Utilize o comando ?Nome para aceder à ajuda on-line do Mathematica. Escolha uma destas células, dê-lhe uma etiqueta (com Alt j) e crie um hyper-link para ela a partir do nome do operador respectivo na tabela seguinte:

({{Operador, Alias, Exemplo, Resultado}, {Apply, "@@", f @@ (a + b), f[a, b]}, {Blank, "_", □, □}, {Condition, "/;", □, □}, {Equal, "==", □, □}, {Function, "&", □, □}, {Map, "/@", □, □}, {Optional, "_.", □, □}, {Part, "[[]]", □, □}, {PatternTest, "?", □, □}, {ReplaceAll, "/.", □, □}, {ReplaceRepeated, "//.", □, □}, {Rule, "->", □, □}, {RuleDelayed, ":>", □, □}, {SameQ, "===", □, □}, {Slot, "#", □, □}, {SlotSequence, "##", □, □}, {Unequal, "!=", □, □}, {UnsameQ, "=!=", □, □}})

Crie versores  (Subscript[e, x]),  (Subscript[e, y]),  (Subscript[e, z]) formando uma base ortogonal não trivial em (ℝ^3). A partir destes defina uma função F[V] cujo resultado é a lista de componentes do vector arbitrário V na base dada. Deduza uma função polarS[V] que dê a representação dum vector arbitrário V em coordenadas esféricas {r, ϕ, θ} relativas à base escolhida.

Defina funções com os nomes indicados para cada uma das seguintes tarefas:

Aplicar um operador arbitrário operator a uma sub-expressão de qualquer expressão expression determinada por uma lista de posições position.

Imprimir uma lista das sub-expressões de expression, e as respectivas posições, mas deixar inalterada a expressão.

Imprimir uma lista das sub-expressões da parte de expression referida por pos, e as respectivas posições, mas deixar inalterada a expressão.

Apêndices

Some common mathematical functions.

({{"\!\(\*StyleBox[\"\\\"Sqrt[\\\"\", \"MR\"]\)\!\(\*StyleBox[\"\\\"x\\\"\", \"TI\"]\)\!\(\*StyleBox[\"\\\"]\\\"\", \"MR\"]\) ", "square root ("(Sqrt[x])")  "}, {"\!\(\*StyleBox[\"\\\"Exp[\\\"\", \"MR\"]\)\!\(\*StyleBox[\"\\\"x\\\"\", \"TI\"]\)\!\(\*StyleBox[\"\\\"]\\\"\", \"MR\"]\) ", "exponential ("(e^x)")  "}, {"\!\(\*StyleBox[\"\\\"Log[\\\"\", \"MR\"]\)\!\(\*StyleBox[\"\\\"x\\\"\", \"TI\"]\)\!\(\*StyleBox[\"\\\"]\\\"\", \"MR\"]\) ", "natural logarithm ("(Subscript[log, e]) x")  "}, {"\!\(\*StyleBox[\"\\\"Log[\\\"\", \"MR\"]\)\!\(\*StyleBox[\"\\\"b\\\"\", \"TI\"]\)\!\(\*StyleBox[\"\\\",\\\"\", \"MR\"]\) \!\(\*StyleBox[\"\\\"x\\\"\", \"TI\"]\)\!\(\*StyleBox[\"\\\"]\\\"\", \"MR\"]\) ", "logarithm to base "b" ("(Subscript[log, b]) x") "}, {"\!\(\*StyleBox[\"\\\"Sin[\\\"\", \"MR\"]\)\!\(\*StyleBox[\"\\\"x\\\"\", \"TI\"]\)\!\(\*StyleBox[\"\\\"]\\\"\", \"MR\"]\),  \!\(\*StyleBox[\"\\\"Cos[\\\"\", \"MR\"]\)\!\(\*StyleBox[\"\\\"x\\\"\", \"TI\"]\)\!\(\*StyleBox[\"\\\"]\\\"\", \"MR\"]\),  \!\(\*StyleBox[\"\\\"Tan[\\\"\", \"MR\"]\)\!\(\*StyleBox[\"\\\"x\\\"\", \"TI\"]\)\!\(\*StyleBox[\"\\\"]\\\"\", \"MR\"]\) ", "trigonometric functions (with arguments in radians) "}, {"\!\(\*StyleBox[\"\\\"ArcSin[\\\"\", \"MR\"]\)\!\(\*StyleBox[\"\\\"x\\\"\", \"TI\"]\)\!\(\*StyleBox[\"\\\"]\\\"\", \"MR\"]\),  \!\(\*StyleBox[\"\\\"ArcCos[\\\"\", \"MR\"]\)\!\(\*StyleBox[\"\\\"x\\\"\", \"TI\"]\)\!\(\*StyleBox[\"\\\"]\\\"\", \"MR\"]\),  \!\(\*StyleBox[\"\\\"ArcTan[\\\"\", \"MR\"]\)\!\(\*StyleBox[\"\\\"x\\\"\", \"TI\"]\)\!\(\*StyleBox[\"\\\"]\\\"\", \"MR\"]\) ", "inverse trigonometric functions  "}, {"\!\(\*StyleBox[\"\\\"n\\\"\", \"TI\"]\)\!\(\*StyleBox[\"\\\"!\\\"\", \"MR\"]\) ", "factorial (product of integers "1, 2, …, n")  "}, {"\!\(\*StyleBox[\"\\\"Abs[\\\"\", \"MR\"]\)\!\(\*StyleBox[\"\\\"x\\\"\", \"TI\"]\)\!\(\*StyleBox[\"\\\"]\\\"\", \"MR\"]\) ", "absolute value   "}, {"\!\(\*StyleBox[\"\\\"Round[\\\"\", \"MR\"]\)\!\(\*StyleBox[\"\\\"x\\\"\", \"TI\"]\)\!\(\*StyleBox[\"\\\"]\\\"\", \"MR\"]\) ", "closest integer to "x"  "}, {"\!\(\*StyleBox[\"\\\"Mod[\\\"\", \"MR\"]\)\!\(\*StyleBox[\"\\\"n\\\"\", \"TI\"]\)\!\(\*StyleBox[\"\\\",\\\"\", \"MR\"]\) \!\(\*StyleBox[\"\\\"m\\\"\", \"TI\"]\)\!\(\*StyleBox[\"\\\"]\\\"\", \"MR\"]\) ", n" modulo "m" (remainder on division of "n" by "m")   "}, {"\!\(\*StyleBox[\"\\\"Random[\\\"\", \"MR\"]\) \!\(\*StyleBox[\"\\\"]\\\"\", \"MR\"]\) ", "pseudorandom number between 0 and 1   "}, {"\!\(\*StyleBox[\"\\\"Max[\\\"\", \"MR\"]\)\!\(\*StyleBox[\"\\\"x\\\"\", \"TI\"]\)\!\(\*StyleBox[\"\\\",\\\"\", \"MR\"]\) \!\(\*StyleBox[\"\\\"y\\\"\", \"TI\"]\)\!\(\*StyleBox[\"\\\",\\\"\", \"MR\"]\) … \!\(\*StyleBox[\"\\\"]\\\"\", \"MR\"]\),  \!\(\*StyleBox[\"\\\"Min[\\\"\", \"MR\"]\)\!\(\*StyleBox[\"\\\"x\\\"\", \"TI\"]\)\!\(\*StyleBox[\"\\\",\\\"\", \"MR\"]\) \!\(\*StyleBox[\"\\\"y\\\"\", \"TI\"]\)\!\(\*StyleBox[\"\\\",\\\"\", \"MR\"]\) … \!\(\*StyleBox[\"\\\"]\\\"\", \"MR\"]\) ", "maximum, minimum of "x", "y", "…"    "}, {"\!\(\*StyleBox[\"\\\"FactorInteger[\\\"\", \"MR\"]\)\!\(\*StyleBox[\"\\\"n\\\"\", \"TI\"]\)\!\(\*StyleBox[\"\\\"]\\\"\", \"MR\"]\) ", "prime factors of \!\(\*StyleBox[\"\\\"n\\\"\", \"TI\"]\) (see Section ""3.2.4"")   "}})

A few ways to enter special notations on a standard English-language keyboard.

({{"Esc\!\(\*StyleBox[\"\\\"pEsc\\\"\", \"MR\"]\) ", "the symbol "π" "}, {"Esc\!\(\*StyleBox[\"\\\"infEsc\\\"\", \"MR\"]\) ", "the symbol "∞" "}, {"Esc\!\(\*StyleBox[\"\\\"eeEsc\\\"\", \"MR\"]\) ", "the symbol "e" for the exponential constant (equivalent to \!\(\*StyleBox[\"\\\"E\\\"\", \"MR\"]\)) "}, {"Esc\!\(\*StyleBox[\"\\\"iiEsc\\\"\", \"MR\"]\) ", "the symbol "i" for "(Sqrt[-1])" (equivalent to \!\(\*StyleBox[\"\\\"I\\\"\", \"MR\"]\)) "}, {"Esc\!\(\*StyleBox[\"\\\"degEsc\\\"\", \"MR\"]\) ", "the symbol "°" (equivalent to \!\(\*StyleBox[\"\\\"Degree\\\"\", \"MR\"]\)) "}, {"Ctrl[\!\(\*StyleBox[\"\\\"^]\\\"\", \"MR\"]\)  or  Ctrl[\!\(\*StyleBox[\"\\\"6]\\\"\", \"MR\"]\) ", "go to the superscript for a power "}, {"Ctrl[\!\(\*StyleBox[\"\\\"/]\\\"\", \"MR\"]\) ", "go to the denominator for a fraction "}, {"Ctrl[\!\(\*StyleBox[\"\\\"@]\\\"\", \"MR\"]\)  or  Ctrl[\!\(\*StyleBox[\"\\\"2]\\\"\", \"MR\"]\) ", "go into a square root "}, {"Ctrl["␣"] (Control-Space) ", "return from a superscript, denominator or square root "}})

Complex number operations.

({{"\!\(\*StyleBox[\"\\\"x\\\"\", \"TI\"]\) \!\(\*StyleBox[\"\\\"+\\\"\", \"MR\"]\) \!\(\*StyleBox[\"\\\"I\\\"\", \"MR\"]\) \!\(\*StyleBox[\"\\\"y\\\"\", \"TI\"]\) ", "the complex number "x + i y" "}, {"\!\(\*StyleBox[\"\\\"Re[\\\"\", \"MR\"]\)\!\(\*StyleBox[\"\\\"z\\\"\", \"TI\"]\)\!\(\*StyleBox[\"\\\"]\\\"\", \"MR\"]\) ", "real part  "}, {"\!\(\*StyleBox[\"\\\"Im[\\\"\", \"MR\"]\)\!\(\*StyleBox[\"\\\"z\\\"\", \"TI\"]\)\!\(\*StyleBox[\"\\\"]\\\"\", \"MR\"]\) ", "imaginary part  "}, {"\!\(\*StyleBox[\"\\\"Conjugate[\\\"\", \"MR\"]\)\!\(\*StyleBox[\"\\\"z\\\"\", \"TI\"]\)\!\(\*StyleBox[\"\\\"]\\\"\", \"MR\"]\) ", "complex conjugate "\(z\^*\)" or "\(z\&_\)"  "}, {"\!\(\*StyleBox[\"\\\"Abs[\\\"\", \"MR\"]\)\!\(\*StyleBox[\"\\\"z\\\"\", \"TI\"]\)\!\(\*StyleBox[\"\\\"]\\\"\", \"MR\"]\) ", "absolute value "\(\(|\)\(z\)\(|\)\)"   "}, {"\!\(\*StyleBox[\"\\\"Arg[\\\"\", \"MR\"]\)\!\(\*StyleBox[\"\\\"z\\\"\", \"TI\"]\)\!\(\*StyleBox[\"\\\"]\\\"\", \"MR\"]\) ", "the argument "ϕ" in "\(\(|\)\(z\)\(|\)\(e\^\(i  ϕ\)\)\)"  "}})