Adri van der Meer

Adri vanderMeer

1420 Reputation

19 Badges

21 years, 154 days
University of Twente (retired)
Enschede, Netherlands

MaplePrimes Activity


These are answers submitted by Adri van der Meer

use exp(...) instead of e^(...)
use parentheses (...) instead of square backets [...] because square brackets are used for ?lists

The most efficient way is to create a sequence S by a for loop

r := 0.8: x := 0.9:  # parameters
S := 1: # initialization of the sequence
for i to 99 do
  x := r*x*(1-x):# calculate x[i]
  S := S,x       # append to the sequence
end do:
X := [S];  # make a list

You will find it easy to make a procedure of this algorithm.

Firstly, I recommend to use Maple notation for input display to get full control over your input:
Choose: Tools → Options → Display → Input Display: Maple Notation

Now you can consistently use a[1], a[n], etc for indexed variables. These will (nearly!) always be displayed as a1 , an, etc.
But you must realize that by using the names a[1] etc. automatically a ?table named a is created. This is nearly never harmful, except if you want to use the name a (without subscript):

a[1],a[2] := 3,5;

      a1, a2:= 3, 5

a := 4: a[1];

      41

Another way to use "litaral subscripted" names, is mathML code. Perhaps you will better use a macro as an abbreviation:

macro(a1 = `#msub(mi("a"),mi("1"))`):

Whenever you type a1, the output will be a1

Many times you use a multinlication sign in an intended function application. For example:

cos*alpha
Mh*(V, alpha)

where

cos(alpha)
Mh(V, alpha)

is meant.

See the ?VectorCalculus package (it uses ex, ey, ez for i, j, k).

If you calculate

S,U,V := SmithForm(A, output=['S','U','V']);

then V is the matriof the column operations (and U the matrix of row operations)

B := <A[..,2..-1]|A[..,1]>;

The problem is that maple tries to evaluate the piecewise function before the variables have a value.
You can avoid this by

f := (x,y,z) -> piecewise( (x>=0 and y>=0 and z>= 0), 2*x+3*y+z, undefined ):
implicitplot3d( f(x,y,z) = 6, x = -3 .. 3, y = -3 .. 3, z = -1 .. 7, color = red, 
   axes = normal, scaling = constrained, style = surface);
(f@op)~(S);

By the way, do you realize the difference between a set and a list? See ?set.
Try for example

f := (x,y) -> x^2+y^2:
S := {[3,4],[4,3],[0,5],[5,0]};  # set

or

S := [[3,4],[4,3],[0,5],[5,0]];   # list

Perhaps more general:

eqs := {x-lambda*p=0, y-lambda=0}:
solve( eqs, {x,y} ): eq := x/y = subs(%, x/y);


Because this isn't true if x<0

a := (x*ln(x)-ln(1/(1+x))-x*ln(x/(1+x)))/((1+x)*ln(1+x)):
simplify(a) assuming x>0;

(If x < 0 the expression is complex)

I am afraid that you have to plot the right angle symbol explicitly by connecting three (calculated) points.

with(plots):
p1 := plot( x, x=-1..3, color=blue ):
a,b := [1,2], [2,1]:  # two points
p2 := plot ( [a,b], thickness= 3 ):
c := 3/2:  # [c,c] is the intersection point
h := 0.1:  # size of the right angle symbol
ra := plot( [[c-h,c+h], [c,c+2*h], [c+h,c+h]], color=black ): 
display( {p1,p2, ra} );
A := Matrix( 12, (i,j) -> (i-1)^(j-1) );

Why not Export the worksheet as HTML or as PDF?

See the "note" in ?sum

 s := x -> piecewise(x = 1, 1, 1 < x, add(s(i), i = 1 .. x-1));

will do what you want.

First 19 20 21 22 23 24 25 Page 21 of 27