5565 Reputation

17 Badges

10 years, 1 days

MaplePrimes Activity

These are answers submitted by tomleslie

Two things about your code made this difficult for me

  1. What I consiider to be a confusing use of "subscripts" - sometimes you *seem* to want these to refer to indexed entries in a table/vector whatever, and other times the subscripts have no real programmatic meaning other than to provide a convenient naming convention. For example when you (glibly) use (for example) w[2], are you referring to the second entry in the table w, or do you just want a variable whose name happens to be 'w subscript 2' with no suggestion that this refers to any kind of indexable data structure
  2. Your use of 2-D math input - this just disguises/complicates the subscript problem given above - I'm not going to get into an argument on this issue (cos it would be pointless - too many entrenched positions)

Accepting the above, I  pretty much ignored your code other than trying to analyse what you were trying to achieve: if I am correct, then the following should do what you require

delta__1:= Vector[column](3, [1,0,0]):
delta__2:= Vector[column](3, [0,1,0]):
delta__3:= Vector[column](3, [0,0,1]):
Eq1 := add(nu__||k*delta__||k, k = 1 .. 3);
Eq2 := add(w__||k*delta__||k, k = 1 .. 3);


I must admit that I was surprised when I couldn't find an in-built Maple command for adding phasors. It would seem that the "other CAS systems" you refer to have such a builtin function.

However it is pretty trivial to get Maple do this. Just define the procedure

addphasor:= proc( a1, a2 )
                            local mySum,
                                   b1:= map2( convert, a1, float),
                                   b2:= map2( convert, a2, float),
                                  goPol:= x-> x[1]*exp(x[2]*Pi*I/180);
                            mySum:= goPol(b1)+goPol(b2);
                            return [ abs(mySum), argument(mySum)*360/(2*Pi)];
                   end proc:


addphasor([4, 45], [5,30]);

will return

[8.923958373, 36.66193394]

Note that the above procedure will work when the arguments are integers or floats: if you want to use symbolics, then I might want to think a liitle longer

The problem with sqrt(5) is that it is either 2.236067977 or -2.236067977: so when you ask - is 2<sqrt(5), what is the correct answer. You can generally circumvent this problem by using sqrt(5.0), when (by default) the positive square root will be returned - so


returns unevaluated, because sqrt(5) is ambiguous. However


returns 0

Since you choose to post unexecutable "pictures" of code, rather than the code itself, it is pretty much impossible to debug what you claim to get from your code - and some of it surprises me. However if you just want to check what sort of code actually works, then try the following

delta[1]:= Vector(3, [1,0,0]);
delta[2]:= Vector(3, [0,1,0]);
delta[3]:= Vector(3, [0,0,1]);
Eq3:= delta[1].delta[1], delta[1].delta[2], delta[1].delta[3],
          delta[2].delta[1], delta[2].delta[2], delta[2].delta[3],
          delta[3].delta[1], delta[3].delta[2], delta[3].delta[3];
Eq4:= add( add( delta[i].delta[j], j=1..3), i=1..3);

If you wish to debug your specific code, then I suggest you upload it using the big green up-arrow in the toolbar

There are lots and lots of very clever ways to make information/procedures/data etc available across multiple worksheets, but I am assuming that you want the simplest, which (I think) is

  1. understandable
  2. works

I have tried to keep the following as simple as possible - sophistication can come later!!!

Suppose you define a procedure to produce the square of its supplied argument, then you can define and save this procedure with the following code sequence

dosq:= proc( x)
                  return x*x;
           end proc;
save dosq, "C:/Users/TomLeslie/dosq.mpl";

In any new worksheet you can load this procedure with

read "C:/Users/TomLeslie/dosq.mpl";

and execute in the new worksheet with (for example)


which ought to return 16

Note that where I use the path "C:/Users/TomLeslie/", you should use something appropriate for your machine, and where you want ro store your Maple procedures - If you have a single-disk machine then


would be a reasonable choice

You make the statement

The collect command is supposed to rewrite the expression in terms of the variable descending order.

This is incorrect. The help page for the collect command states quite clearly (my highlighting)

The collect function views a as a general polynomial in x.  It collects all the coefficients with the same rational power of x.  This includes positive and negative powers, and fractional powers.  Note that the resulting expression is not necessarily sorted by powers of x.

As the help page for the collect command clearly states

To sort a polynomial see the sort function.

So try the following

p := expand((a^2+2*x)*(a^2+2*x));

to see the difference. Note that, for more complicated expressions

sort( collect(p, x), x)

may be useful


a1 := Matrix(3, [1, 2, 3, 7, 8, 9, 13, 14, 15]);
a2 := Matrix(3, 2, [5, 6, 11, 12, 17, 18]);
a3 := Matrix(2, [19, 20, 25, 26]);
a4 := Matrix(3, 2, [5, 6, 11, 12, 17, 18]);
A := eval(Matrix(2, 2, ['a1', 'a2', 'a3', 'a4']));

Seems to be a lot of confusion for such a simple problem?!?!

Simply execute either of the following code snippets to get the answer you want

evalf(Tangent(-ln(x)+exp(x), x=2));


evalf(Tangent(f(x), x=2));

and read the help page for Student[Calculus1])[Tangent] to understand why both/either work.

If you really want only three significant figures, then modify the above, using a second argument to the evalf() command, to

evalf(Tangent(-ln(x)+exp(x), x=2), 3);


evalf(Tangent(f(x), x=2), 3);

I mean, how hard can this be??????

You got really unlucky!!

There seem to be two commands for plotting a space curve (whihc surprised me!!

  1. plots[spacecurve]( [list of components], range=whatever )
  2. Student[VectorCalculus][SpaceCurve](<cos(t),sin(t),t>,t=1..5,axes=framed)

Note the differences in capitalisation of the term spacecurve between these two, and lso the fact that the first takes a list of components eg [cos(t), sin(t), t] and the second takes a vector of components <cos(t), sin(t), t>

You seem to have used the first of these - ie plots[spacecurve] but with the vector form for the corrdinates rather than the list!!

See that attached for both ways

It seems as if the default axes and colour option for these two commands are different

For future reference you can upload worksheets using the big green up-arrow in the toolbar.

Several syntax errors, and usages of deprecated structures,so  that I have difficulty working out what you actually want. Whilst making the minimum(?) number of changes to your original code, the following produces something - which may (or may not be) what you want.

Your code seems for complicated for what you are trying to achieve, but since I don't actually understand what you are trying to achieve.....

Go to Tools->Options->Display and set input display to Maple Notation,

followed by Apply to Session or Apply Globally

I think you have a problem with parentheses - your plot range 0..100 is included in a ist with functions to be plotted becuase of the positioning of your square brackets. The following is a trivial example of two plots, which does work

plot([Y2(t),-X2(t)], t=0...100, numpoints=100);

  1. You have missed the multiplication sign between 'p' and '(4x2+6)' - one of the perils of using 2D math input is that this sort of thing is difficult to spot
  2. Once you correct the above, your loop will only return non-zero values for n=1, because your 'polynomial' only contains terms in p^1

see attached

dsolve(eq, x(t));

cos it works for me

Try this


First 112 113 114 115 116 117 118 Last Page 114 of 122