## 2418 Reputation

14 years, 106 days

Dr. Robert J. Lopez, Emeritus Professor of Mathematics at the Rose-Hulman Institute of Technology in Terre Haute, Indiana, USA, is an award winning educator in mathematics and is the author of several books including Advanced Engineering Mathematics (Addison-Wesley 2001). For over two decades, Dr. Lopez has also been a visionary figure in the introduction of Maplesoft technology into undergraduate education. Dr. Lopez earned his Ph.D. in mathematics from Purdue University, his MS from the University of Missouri - Rolla, and his BA from Marist College. He has held academic appointments at Rose-Hulman (1985-2003), Memorial University of Newfoundland (1973-1985), and the University of Nebraska - Lincoln (1970-1973). His publication and research history includes manuscripts and papers in a variety of pure and applied mathematics topics. He has received numerous awards for outstanding scholarship and teaching.

## Drawing Solids in Maple...

Maple does not yet have the ability to "fill" between two arbitrary curves or surfaces. However, there are several tricks that sometimes allow Maple to nearly do this task. The plot command admits the filled=true option that shades between a curve and the horizontal axis. The generalization of this in the plot3d command "fills" to the z=0 plane.

In Maple 14 there are five new task templates for drawing regions of integration. (See in the Task Browser under Calculus, Multivariate, Integration, Visualizing Regions of Integration.) In several of these, "solids" are drawn. These drawings are done surface-by-surface, each of the six possible bounding surfaces being drawn parametrically. Open one of these task templates and view the code through the Context Menu for the Graph buttons.

Without a general all-purpose tool for drawing an arbitrary solid, each example requires tricks and devices specific to the given solid. I wish it were otherwise.

RJL Maplesoft

## Flight of a baseball...

Somehow, I have the feeling that if the flight of a baseball is the bottom line here, then a differential equation might just be at stake. If so, why are we re-inventing the wheel? Maple's dsolve/numeric command has enough flexibility to handle these data-storage issues without having to micromanage the data the way this discussion is going.

So, if I'm right, then we should be talking about Maple's dsolve/numeric capability and how to use it efficiently, and not about storing the individually computed data points. Let Maple's internal routines handle that and just use the top-level integrator to set up and solve for the trajectory.

Of course, you could have been assigned the task or re-writing a numeric solver for ODEs. If so, I doubt you will reproduce (in the time the typical assignment takes) the sophistication already built into the existing Maple code.

So, can we step back and see what the underlying issue really is?

RJL Maplesoft

## List of vectors or lists, vs. Array or M...

After seeing that individual components of the sublists (i.e., triples) need to be changed, I decided to ask one of the Maple programmers about the efficiency of this approach. Turns out that changing an element of a list requires Maple to recreate the full list. Not very efficient.

The suggestion was to use an Array or Matrix of size 3x120. Each column would represent one of the triples, and the 120 columns would be the 120 "vectors" you originally asked about. It's much more efficient computationally to change an element in an Array or Matrix. It all has to do with allocation to memory locations, pointers, etc.

If you need the "linear algebra" properties of these 120 vectors, use a Matrix. If the data structure is just a storage for 360 numbers, an Array will suffice.

Create the Array with A:=Array(1..3,1..120);

Assign a value to the location row=2, column=25 with the syntax A(2,25):=x;

Access this value with A(2,25);

If instead, a Matrix is appropriate, use B:=Matrix(3,120);

Assign a value to location row=2, column=25 with the same syntax as in the Array.

A single column can be extracted from the Matrix with the command LinearAlgebra:-Column(B,25);

Of course, if a number of commands from the LinearAlgebra package are to be used, simply load the package via the syntax with(LinearAlgebra) so that calls to commands in the package don't need the prefix LinearAlgebra:-

It would be useful to know what kind of "advanced calculus functions" are to be applied to the columns of the Array or Matrix. Some of these functions might reside in the VectorCalculus package. Recall that I pointed out earlier that a VectorCalculus Vector carries as an attribute its coordinate system. This is not the case for LinearAlgebra Vectors, so a conversion might be necessary. However, if the vector operations are just dot and cross products, it is not necessary to go to the VectorCalculus package. We can give better advice if we know more specifically just what operations you need to inflict on your vectors, or triples, as the case may be.

RJL Maplesoft

## Differentiation with respect to somethin...

This is a problem encountered in physics, or in the calculus of variations (think variational mechanics). The diff command is modified in the Physics package to do what you want.

For example, to differentiate sin(x) with respect to sin(x), and therefore get the answer 1, you can use

Physics:-diff(sin(x),sin(x))

RJL Maplesoft

## Array of Physics Vectors...

The Vector construct at top-level would suffice. These are the same vectors as in the LinearAlgebra package. However, vectors in the VectorCalculus package are not the same - these have the attribute of a coordinate system attached.

You could also use simple lists to keep track of triples of numbers: [1,3,5] is a list of three numbers.

The best book I ever bought for Maple was Andre Heck's Introduction to Maple. I bought the first two editions, but by the time the third edition came out I was either out of money or didn't need another copy of the text.

RJL Maplesoft

## Removing the order term from a series...

RJL Maplesoft

In particular, to remove the "big oh" term from a series S, use

convert(S,polynom);

This effects a change in the internal structure of the object. The internal representation of a series does not allow for evaluation or plotting. Simply removing the O-term wouldn't help either. It's the internal representation that has to change, and the convert command does that, as well as remove from the display the O-term.

It's possible to make this conversion interactively through the Context Menu. Select Series->Truncate to polynomial.

This option activates the convert command, although on the screen it will appear that all that has happend is that the expression has been truncated.

## The animate command...

RJL Maplesoft

My first suggestion would be to use the animate command. For example, try something like

animate(plot,[t*(4-x^2),x=-2..2],t=0..10);

The animate command (in the plots package) will animate plots created by plotting functions. These functions can be built-in plot commands such as plot or plot3d, or they can be user-defined procedures that result in a plot structure. The command is pretty robust, and has a lot of built-in features that are tedious to reproduce when building an animation with display/insequence=true.

Mixing 2d and 3d plots requires more care. In fact, you can't. You have to "elevate" the 2d plot to a 3d plot. The typical technique I've used for this is via the transform command from the plottools package. One uses this command to define a function whose job is to change each 2d point in the 2d plot structure to an equivalent 3d point. So, suppose you had a 2d plot structure whose name was Q, and which generated the graph of a curve in the plane. If you want this curve to appear in the z=0 plane in a 3d plot called R, execute f := transform((x, y) -> [x, y, 0]):

Then, join the plots of Q and R with display([R, f(Q)])

For the rest, it's not exactly clear what you want to do. I have this vague sense that perhaps you want to animate a series or set of disturbances resembling stones dropped into a lake. Not sure, so perhaps this needs some iteration on your part.

## RJL Maplesoft Specifically...

RJL Maplesoft

Specifically coded for such applications, the command convert(expr,phaseamp) is a more powerful (and convenient) alternative.

This is a remarkably smart conversion, as it will find all instances of the desired structure, even if there are multiple pairs of sine/cosine functions in the mix. It's much more powerful than using solve/identity, which fails in many instances: For example, if the trig functions are multiplied by a common exponential, or the coefficients are symbolic, not numeric, etc.

## non-orthogonal coordinates...

RJL Maplesoft

By design, the VectorCalculus package computes the differential operators Divergence, Curl, Gradient, and Laplacian only in orthogonal coordinates.  It uses scale factors, and that works only with orthogonal systems.  However, Maple's plot package can draw graphs for non-orthogonal systems, so there is this option in VectorCalculus to add a non-orthogonal system for the purpose of graphing, but not for computing.

To obtain the gradient in non-orthogonal systems, you would need the Tensor subpackage of the DifferentialGeometry package. In essence, such a gradient must be computed via the covariant derivative, which is the generalization of the directional derivative. In multivariate calculus, one meets the directional derivative of a scalar. When this derivative exists, it can be computed by taking the dot product of the gradient vector with the direction vector. Well, when you ask for a directional derivative of a vector field, you first need to generalize the gradient vector. This generalization is the "covariant derivative." Dotting the covariant derivative with the direction vector then produces the directional deriavtive of the vector field.

So, what does a covariant derivative look like? In this case it would be a rank-2 tensor. This object can be represented as a matrix - its components can be organized into a matrix format. Then, matrix multiplication with a vector can be used to compute the equivalent of the summation process that's lurking in the tensor calculus.

If you really need to learn this stuff, I suggest you read the Reporter Article "Classroom Tips and Techniques: Tensor Calculus with the Differential Geometry Package" that's now in the Maple Application Center at the end of the following link.

http://www.maplesoft.com/applications/view.aspx?SID=33840

Alternatively, go to the Application Center, and search for articles by Robert Lopez. There are at least 50, but the one I'm suggesting is in the list.

## RJL Maplesoft The file...

The file 11412_eigenvector.mw does not contain a 3x3 matrix.  I tried writing a matrix of the coefficients of u[1],v[1],w[1] in the vector given in that file, but the eigenvalues of the resulting matrix do not match the -6.908 value in the file.

Essentially, the question is pretty opaque, and should be further clarified by the proposer.

RJL Maplesoft

## One Advantage of Worksheet Mode...

RJL Maplesoft One advantage of the worksheet is that you can single-step through a sequence of Maple commands, with the cursor moving automatically to the next prompt. This does not happen in Document mode. In fact, after hitting the Enter key to execute a command in document mode, the cursor moves to the next blank document block. Further use of the Enter key just generates new empty document blocks, so if you are in class working through a sequence of calculations, you have to use the mouse to move to the next executable command in Document mode. One blend of the technologies is to use a worksheet, but to capture the commands in 2D math. These commands can either be written in 2D math, or converted to 2D math from 1D. In fact, experienced users of Maple who demonstrate sequential calculations for students can write a worksheet much as they would have done in earlier versions of Maple, then convert the 1D input to 2D input for the mathematical clarity that such input often permits. In my 15 years of using Maple in the classroom, I was in worksheet mode with 1D math. After my retirement, it took a bit of time, but I morphed my style to worksheet with 1D for creation, with converson to 2D for a better view of the mathematics being expressed by the command. A student who wants to see the underlying 1D math input can revert the change via context menu. I haven't yet used the Document mode to write a mathematical paragraph that captures live calculations within the sentences of the paragraph. That's what I see as one of the two basic functionalities of the Document mode. The other is as a workspace for free-form drag-and-drop point-and-click syntax-free calculations. This can be done in a worksheet, too, but it feels more efficient to me done in a Document.

## Help with Graphing "Directional Derivati...

RJL Maplesoft The following commands will result in a graph of the surface, its tangent plane at (1,1,1), and the normal line through (1,1,1). However, this isn't a "directional derivative" issue per se. It might arise while studying the meaning of the directional derivative, but in itself, the construction does not require the concept of "directional derivative." with(VectorCalculus): BasisFormat(false): with(plots): q := x*y+y*z+z*x-3; V := Gradient(q,cartesian[x,y,z]); N := evalVF(V,<1,1,1>); L := <1,1,1>+t*N; Z := solve(q,z); TPZ := mtaylor(Z,[x=1,y=1],2); p1 := implicitplot3d(q=0,x=-1..3,y=-1..3,z=-1..3): p2 := plot3d(TPZ, x=0..2,y=0..2): p3 := spacecurve(L,t=-1/2..1/2, color=black, thickness=2): display([p||(1..3)], scaling=constrained, axes=box);

## For example, to apply the...

For example, to apply the ratio test to the series Sum(1/2^n, n=0..infinity), define > a := n -> 1/2^n: > 'a'[n] = a(n); then compute > r = limit(a(n+1)/a(n), n=infinity); We suggest two lines to define a[n]. The first defines it as a functin of n, the second displays it more naturally. The left side of the output of the second line appears as a[n], whereas the right side appears as 1/2^n. Similar computations apply to the nth-root test, etc. There is no single command for determining the convergence or divergence of a series. If the whole series is entered as > S := Sum(1/2^n, n=0..infinity); then the command > value(S); will produce a finite result, in which case it's clear the series converged. If Maple can determine the series diverges, it will return the symbol "infinity" or -infinity. If Maple returns unevaluated, it means that Maple could not determine a limit for the partial sums, but that does not mean such a limit does not exist. It only means that Maple couldn't determine that limit. There is no single command in Maple for writing the general term in a series. The taylor (or series) commands produce a partial sum, with the terms written out (not in in sigma-notation). However, the nth derivative of an expression can be computed. Hence, it is possible to build the general form of a series expansion. For example, to obtain the general expansion of sin(x) at x = 0, implement the following commands. > q := eval(diff(sin(x),x\$n)/n!, x=0); > q1 := simplify(eval(q, n=2*k+1)) assuming k::posint; The first command produces sin(n*Pi/2)/n! whereas the second produces (-1)^k/(2*k+1)!. User insight and intervention is definitely needed here! The requisite Maclaurin expansion is then obtained with > Sum(q1*x^(2*k+1), k=0..infinity); The Share Library, a repository for code contributed by users, contained the FPS package with its FormalPowerSeries command. This command would return the formal power series in sigma notation. However, the Share Library is no longer available.
 First 19 20 21 Page 21 of 21
﻿