acer

32348 Reputation

29 Badges

19 years, 330 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@das1404 You can multiply Matrices and Vectors (even without loading the LinearAlgebra package) using `.` which is a noncommutative multiplication command. For example, and note the absence of executing any statement like with(LinearAlgebra) below,

restart:

M:=n->Matrix(n, (i,j)->binomial(n, i-j mod n)):

LinearAlgebra:-Determinant(M(2));

-3

B:=n->Matrix(n, (i,j)->binomial(n+j, i+j mod n)):

C:=M(2).B(2);

C := Matrix(2, 2, {(1, 1) = 7, (1, 2) = 6, (2, 1) = 5, (2, 2) = 9})

E:=B(2) . M(2);

E := Matrix(2, 2, {(1, 1) = 9, (1, 2) = 6, (2, 1) = 5, (2, 2) = 7})

E^(-1);

Matrix([[7/33, -2/11], [-5/33, 3/11]])

C . E;

Matrix([[93, 84], [90, 93]])

E.C;

Matrix([[93, 108], [70, 93]])

 

 

When I was making wild guesses about your earlier code went astray when re-executed, I suggested unassigning u and s. Note that I used single right-quotes (aka unevaluation quotes) for that. One uses single left-quotes (aka name quotes) in order to use a language keyword like union in a prefix function call, as you did. But these two kinds of quotes serve different purposes. The unevaluation quotes act to delay evaluation, so that you can refer to an assigned name and get at its name rather than its assigned value. Here are two ways to unassign,

s:={a,b,c};       # now assigned a value
                           {a, b, c}

s:='s';           # single right-quotes
                               s

s;                # no longer assigned
                               s

s:={a,b,c};       # now assigned a value
                           {a, b, c}

unassign('s');    # single right-quotes

s;                # no longer assigned
                               s

Next, for a Matrix M the syntax M[1,..] refers to the first row. In very old Maple versions that did not support that syntax an equivalent would be M[1,1..-1] or even M[1,1..n] where n is the number of columns.

Moving on... If you are a student then you can purchase the latest Maple version for some relatively low cost (like $150 or something). You might even be able to find someone who'd sell you a used copy of a version less than 5 years old. There have been a lot of improvements since Maple 7.

It's just my opinion but I'd say that Maple's programming language and functionality are its jewel in the crown. The introductory User Manual of modern Maple has unfortunately had a great deal of its basic 1D Maple language information removed. But modern Maple's Programming Manual contains a lot of good information, though it may be a difficult first read for a Maple beginner.

A reasonably good introductory text on basic Maple, suitable for older versions, is the Learning Guide. That link is to the Maple 9 version of it. The oldest online version I'm aware of is the Maple 8 version available from under here. A good older book on Maple programming, suitable also for beginners, is Andre Heck's book. A good modern book on Maple programming, suitable also for beginners, is Ian Thompson's recent book.

If the topic is of interest to you, another way to compute these determinants is:

restart;

det := proc(n) local x; resultant(x^n-1,(x+1)^n-1,x); end proc:

seq( det(k), k=1..10 );

    1, -3, 28, -375, 3751, 0, 6835648, -1343091375,

    364668913756, -210736858987743

@das1404 You could try the command,

interface(rtablesize=20):

to allow Matrices of dimension up to 20x20 to be displayed in full. Otherwise they just print in the short form. This relates only to how they get printed -- tersely, or in full. Accessing them should work regardless of this setting. I am not 100% sure whether that interface call worked the same in Maple 7, or what the default setting was. My memories of the year 2001 are not that clear.

I believe you'll find that the one-line code I gave to construct the Matrix does produce it as expected, invoked like M(12), M(13), etc.

The oldest version to which I have access to the commandline interface is Maple 9, and the oldest version to which I have access to the GUI is Maple 11 (I think).

In very old versions of Maple it is true the sets were ordered and stored internally according to memory address. That was still true in Maple 9 too, but in that version I have not been able to reproduce the erratic behavior you described.

When you say that you ran the code "again" does that mean that you did a restart between them, or otherwise unassigned both s and u?  You would need to do that because of the way your code assigns to s using table references to s itself (and similalrly for u). If s and u are not first unassigned and have their previous run's values then the code will not work properly (producing an error message in modern Maple and possibly your stated problems in your version). If you don't do a restart then at least put  s:='s': and u:='u':  at the top of your computational code. Better yet put the Matrix construction code all into a procedure where s and u are declared local variables.

@mbras On the help page for sum there is a clear Note about using add instead of sum for adding up up a finite number of terms.

On the help page for topic sum,details there is more mention of this, and a discussion in the later part of the Examples, titled "Comparing sum and add". That explains quite a bit of the differences, and what's going on.

Reading the help pages for a command with which you're having difficulty is often a good place to start.

 

@exality The inability to protect to the name sqrt happens regardless of whether Units:-Standard is loaded or not, ie. regardless of whether the name is bound to the package export name Units:-Standard:-sqrt or to the global :-sqrt .

Both of those are protected names, which is Maple's way of ensuring that you don't clobber the system names.

But as you now know, you can just apply sqrt~(...) and don't need to first make any assignment to the name.

In my 2nd usage example I used a custom, anonymous operator only because it let me utilize the pretty 2D radical symbol.

@rlopez 

The problem occurs because Component action code picks up current name bindings when executing. The key item here is that when `=` is rebound to Units:-Standard:-`=` then DocumentTools:-Do does not interpret a first argument like %Plot0=P as intended.

IMO the DocumentTools:-Do command is ill-designed, and people should always use DocumentTools:-SetProperty and DocumentTools:-SetProperty instead.

Here is a worksheet that exhibits the problem. It fails with DocumentTools:-Do when Units:-Standard is loaded, but works with DocumentTools:-SetProperty.   Do_equals.mw

I notice other problems in this and several other Task Templates. Their action code is generally not mint clean, in the sense that unprotected global names are used without proper protection against evaluation or misidentification as locals.

For example, color=red instead of 'color'=':-red'. If the global name red gets assigned a value then the code no longer works.  (Most plotting command optional keyword values can be supplied as strings, so 'color'="red" also works.)

Another misuse of global names is in referenced commands in the form Student[Precalculus][Distance] , which also suffers because that involves unprotected references to names (as if global, but not denoted as global). If the user assigns a value to the unprotected global name Precalculus then the code no longer works. More robust would be either Student[':-Precalculus'][':-Distance'] or Student:-Precalculus:-Distance . See the help page for topic colondash for more.

In the Bezier curve Task Template I see about a dozen instances of these issues.

As I mentioned, you haven't uploaded a Worksheet or Document that contains code to reproduce the problem, ie. code that constructs such a Matrix as well as the way the command is being called. Without that the best we can do is guess at the cause.

You can attach a worksheet to a response here using the green up-arrow in the Mapleprimes editor.

@vv It seems to be an undocumented kernel thing, only working for symbols (which it does not evaluate).

restart;
kernelopts(version);
        Maple 2017.3, X86 64 LINUX, Sep 27 2017, Build ID 1265877

T:=table([eleventeen=P]):
eleventeen:=37:

T['eleventeen'];
                              P

T[eleventeen];
                            T[37]

T:-eleventeen;
                              P
I suppose it might be convenient when using table-based packages whose members' names might not all be protected names. (It might have made more sense in Maple 6, IMO, so that help pages for both kinds of package could have been made consistent and without the subscripting that appears in Examples. Deprecation of the indexed name package member reference in the year 2000 would be forgotten by now, and the explanations on ?colondash less convoluted. IMO.)

@MDD Try replacing simplex:-minimize by simplex[minimize] .

Adjustment to spacing (though not really more robust or general purpose...)

restart

kernelopts(version)

`Maple 2015.2, X86 64 LINUX, Dec 20 2015, Build ID 1097895`

H3:=proc()
  local oldlevel, temp;
  uses Typesetting;
  try
    oldlevel:=interface('typesetting'=':-extended');
    temp:=Typeset(EV(args));
    temp:=eval(temp,[mo(",")=NULL,ms=mn,
          mstyle(mo("and"),'mathvariant'="bold")=NULL,
          mo("∧",msemantics="inert")=mn("and"),
          mspace=(u->NULL),mi("``")=NULL]);
    temp:=subsindets(temp,And('specfunc'(mfenced),
                              satisfies(u->member(msemantics="realrange",
                                                  [op(u)]))),
                     u->mfenced(mrow(op(1,u),mo(";"),op(2,u)),
                                op(3..,u)));
  catch:
    return NULL;
  finally
    interface('typesetting'=oldlevel);
  end try;
  return temp;
end proc:

ct1 := 0 < x and x < (1/2)*Pi; ct2 := f(x) = x-sin(x); ct3 := `%>`(``, f(0)); ct4 := `` = 0; ct5 := `%>`(x, sin(x)); ct6 := RealRange(Open(0), Open((1/2)*Pi))

0 < x and x < (1/2)*Pi

f(x) = x-sin(x)

`%>`(``, f(0))

`` = 0

`%>`(x, sin(x))

RealRange(Open(0), Open((1/2)*Pi))

H3("So, for ", ct1, " we have ", `and`(`and`(ct2, ct3), ct4), ", or ", ct5, ", on the interval ", ct6)

"So, for 0<x<Pi/2 we have f(x)=x-sin(x)`%>`(f(0))=0, or `%>`(x,sin(x)), on the interval (0;Pi/2)"

 

Download typeset_math_text_2.mw

Perhaps the problem is not so much that `eliminate/recursive` is allowed to call itself with the empty set {} as its first argument, but that in such a case it returns {} rather than a set of trivial identities/equalities involving the passed elimination variable(s).

For example, the following returns {} the empty list, whereas perhaps it could more usefully return something like {[{x[4] = x[4]}, {}]} . Or something like that.

`eliminate/recursive`({}, {x[4], x[5], x[6], x[7], x[5]*x[6]*x[7]+2*x[7]+1}, {x[4]});

I will test out this idea. It might involve just a couple of changes in lines 18-34 of `eliminate/recursive`. If things look good after testing I might even be able to post a FromInert/ToInert hotfix here as a comment...

showstat(`eliminate/recursive`,18..34);

@vv In Maple 13.01 and earlier I receive NULL for that.

The cause of this seems unrelated to the above bug in eliminate (but I could be wrong). It seems to be related to how solve (and/or SolveTools) is handling (or accidentally not carrying along) the restrictions it figures out.

We could probably write you a Maple procedure which could:
1) Take as argument the filename of your worksheet.
2) Rip it apart and put it back together using XMLTools, etc, such that all "top-level" Tables are sorted accordind to the first text string appearing in the first cell.
3) Write the result out to a new, supplied filename, or open in a new GUI tab.

Optionally, it'd probably be not much more difficult to have the new .mw file contain a Table of Contents with hyperlinks to the individual Tables.  (I've previously done this kind of thing for Sections in a Worksheet).

Is that the kind of thing that'd be useful to you?

I don't know how the GUI's print-export mechanism works, sorry. 

But suppose that you absolutely cannot get the ease of use you want from the combination of mouse-selection and the GUI's print-export, for printing the Tables individually. In that case it should still be possible to augment the sorted, new .mw file to also contain a ComboBox Component, such that selection of any Table's preamble string in that ComboBox would open only the named Table in a new GUI tab, which you could then print-export stand-alone.

@minhhieuh2003 It is a bug the the RealRange constructor always turns Open(infinity) into just infinity, which has the effect that you cannot easily pretty-print the open semi-infinite real-range.

I can think of a few workarounds to allow you to get what you want displayed. Some of them would be over-complicated for a new user, I think. And some would affect printing of all semi-infinite real-ranges. So for now I'll make the following suggestion, whose drawback is just that the displayed object is transient -- ie. it is for a single display only, and any subsequent evaluation of it would revert to the closed interval display.

restart;

interface(typesetting=extended):

openfix:=R->subsindets(R,specfunc(RealRange),
                       u->subs([infinity=Open(infinity),
                                -infinity=Open(-infinity)],u)):

S1:=`union`( solve( x^2-3*x+2 <= 0, x ) ):

S2:=`union`( solve( x^2-3*x+2 >= 0, x ) ):

openfix( S1 );

RealRange(1, 2)

openfix( S2 );

`union`(RealRange(2, Open(infinity)), RealRange(Open(-infinity), 1))

 

Download RealRange_openinf.mw

 

@tomleslie Thanks, corrected now.

First 260 261 262 263 264 265 266 Last Page 262 of 592