Carl Love

Carl Love

28085 Reputation

25 Badges

13 years, 99 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are answers submitted by Carl Love

Put your cursor in the cell (or paragraph or execution group or output region) that you want to delete and press Ctrl-Delete. It  doesn't matter whether or not the cell is empty.

Actually, in Maple you can usually do away with do-nothing or pass-along parameters such as the u and v in your Question. Then the issue raised by Tom is less of an issue. The following produces identical final results to all of the previous Answers:

g:= alpha*beta:
h:= alpha+beta:
f:= D[1](g)*h:
f(u,v);

The u and v in the final line are arguments, not parameters. (Roughly speaking, they are "global" and not "local"---but arguments and parameters are the precise terms.)

The lines where you defined m and n have not been executed because you didn't press Enter after entering them.

Your PLOT commands work in this case, but like Rouben says, it'd be better to use display or plots:-display. PLOT (all uppercase letters) is an expert-level command. This is not to be confused with plot (all lowercase letters), which is a regular command.

The problem is that rational is both a type and a proper property. By proper, I mean that it has its own definition as a property independent of its definition as a type. Properties are about the mathematical natures of abstract objects; whereas types are about the internal structures of actual objects exactly as they are stored in Maple's memory.

  • Your command is(.5, rational) is using rational as a property. It correctly states that the mathematical object .5 is a rational number, using the usual mathematical definition of such.
  • Your command type(.5, rational) is using rational as a type (the type command can only be used with types). It correctly states that .5 is not stored in a format using the Maple-specific definition of  rational (which is specifically an integer or a fraction, the latter being specifically a pair of integers (with common factors removed) combined with a tag (or 0th operand) "Fraction").
  • Your command is([.5], list(rational)) is using list(rational) as a type, and hence using rational as a type.
  • Your command is(sin(1)^2 + cos(1)^2, rational) incorrectly returns false. This is a bug---is should at least try a simplify before reaching a conclusion.

Acer said in a recent related thread that all types were valid properties. I don't fully agree with that. It's true in the sense that all commands that expect a property will (unfortunately) accept a type instead---at least all that I've checked. But the commands is, coulditbe, etc., can't do anything interesting with those unless they are proper properties.

 

You need to change the last line from

end do;

to

end do:

I can do it in under 7 seconds, using a completely different algorithm:

restart:
gc():
st:= time():
n:= 6:
N:= [$1..n]:
Sn:= combinat:-permute(n):
Id:= Matrix((n$2), (i,j)-> `if`(i=j, 1, 0)):
MF:= {seq(Id+Id[d,..], d= remove(p-> ormap(evalb, p =~ N), Sn))}:
MA:= {seq(seq(convert(M[p,..], listlist), M= MF), p= Sn)}:
Ones:= Matrix((n$2), fill= 1):
MA:= {seq(Ones - Matrix(M), M= MA)}:
time() - st;

The algorithm is

  1. Construct all permutations of [1..6].
  2. Select those permuations that are derangements.
  3. Construct all matrices of the form I+I[d], where I is the identity matrix and I[d] is the permutation matrix constructed from derangement d.
  4. Multiply every matrix by every permutation matrix. To save time, this is done with indexing rather than actual multiplication.
  5. Remove all duplicates from the list of matrices by converting to listlist form and using Maple's set constructor.
  6. Subtract each matrix from a matrix of ones.

On every system on which I've ever used Maple, the smallest reportable unit of computation time has been 1/64 of a second, which is about 16 milliseconds. I once saw a credible report of a system---Linux I believe---where the unit was 1/256 of a second.

To get accurate time measurements on a finer scale, you must do a large number of computations and average the time.

There's a difference between recursion and a recursive assignment. A recursive assignment is an assignment statement such as

x:= x + 1;

where x has not been initialized. Such an assignment is never allowed, whether it's in startup code or other code.

The Determinant command is part of a "package" that's not loaded when you initially load Maple. You simply need to do

with(LinearAlgebra):

in each session before using Determinant. An alternative is to use the package prefix whenever you use the command, as in LinearAlgebra:-Determinant(M). This can also be written LinearAlgebra[Determinant] (although there's a slight difference in the semantics). Finally, there's

use LinearAlgebra in Determinant(M) end use;

Of the four methods, I strongly prefer the second, LinearAlgebra:-Determinant, and I consider use of the others as substandard coding practices. Of the four, only the second unequivocally informs the reader that Determinant is a fixed identifier whose definition is hard coded in package LinearAlgebra. However, the with method is by far the most commonly used.


 

restart:

z:= x+y*I:

P||(1..3):= (1, z, 1+z^2):

P||(1..3):= (`<,>`@evalc@[Re,Im])~([P||(1..3)])[];

P1, P2, P3 := Vector(2, {(1) = 1, (2) = 0}), Vector(2, {(1) = x, (2) = y}), Vector(2, {(1) = x^2-y^2+1, (2) = 2*x*y})

(1)

The points are collinear (or aligned) if the direction vectors between any two distinct pairs are parallel. That corresponds to the following determinant being 0.

C:= LinearAlgebra:-Determinant(<P2-P1 | P3-P1 >);

x^2*y+y^3-2*x*y

(2)

algcurves[plot_real_curve](C, x, y, axes= boxed);

 

The blue part is the solution. Any three points on the real axis are collinear, so the solution obviously includes that. We guess that the rest of the solution is the circle of radius 1 centered at [1,0]. The following confirms that guess:

simplify(C, {(x-1)^2 + y^2 = 1});

0

(3)

 


 

Download Complex_locus.mw

As may have occurred to you already, the coefficient 14 is irrelevant to solving the 90% problem. Then the problem becomes finding the 90% quantile of a statistical gamma distribution (with parameters 3 and 2 in this case).

G:= Statistics:-RandomVariable(Gamma(3,2)):
Statistics:-PDF(G, t);

    

Statistics:-Quantile(G, .9);

     11.6691605096023

This is an ideal situation to use a key sort. The key in this case is mu. I have assumed that your Vector does contain the backquotes as you presented it, hence the use of parse.

sort(A, key= (r-> -eval(parse(rhs(r))):-mu));

The minus sign makes it the descending sort that you want.

You need to change Subgroup(lc) to :-Subgroup(lc), or else avoid loading the GroupTheory package with with and rather access its procedures using the GroupTheory:- prefix

Oh boy, that's a very subtle distinction in this case, and I foresee that this type of thing will be a huge source of confusion with the new object modules. The documentation at ?LeftCoset says

  • The data structures representing (left or right) cosets respond to the following methods.
  • ...
  • Subgroup( c ) returns the subgroup of the coset c.

 

What tipped me off to use :- was the word "methods". That implies that the cosets are represented as objects with the "method" Subgroup being coded in that object's own module. So, this does not refer to that other procedure named Subgroup, the one whose code is in the GroupTheory module. Since you used with(GroupTheory), the name Subgroup (with no prefix) refers to GroupTheory:-Subgroup.

The confusion is compounded by it being very difficult (perhaps impossible) to find the name of the module where the "method" Subgroup for cosets is encoded. All you're given is that code number _m917...many digits..., that number being a memory address generated on the fly.

I avoid these problems by not using with! I only use it when the package overloads non-name operators that I want to use. For example, GroupTheory overloads (or overrides; I'm not sure which in this case), the vector constructor <...| ...>. If I'd wanted to use that as an operator rather than in the prefix form `<|>`(...), then I'd need with(GroupTheory).

What exactly do you mean by garbled? I see that the line breaks often occur in hideous, inappropriate places (depending on your screen width), but that's just the standard practice of Maple's so-called Standard GUI. Did you mean the line breaks, or something else?

Yes, it's easy. Right click on the plot to bring up its context menu. Select Manipulator -> Point Probe. Right click again. Select Probe Info -> Nearest Point on Line. Then left click on the plot.

Try replacing simplify with evalf and sum with Sum (both occurences). This is the standard Maple approach, but I can't test that it'll work without knowing the values of your constants (including sigma). If this doesn't work, try (additionally) replacing infinity (both occurences) with a large integer. Then use a larger integer and see how much difference there is.

First 189 190 191 192 193 194 195 Last Page 191 of 395