acer

32313 Reputation

29 Badges

19 years, 315 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

The x on the Operators palette does LinearAlgebra:-CrossProduct on a pair of 3-Vectors. It also appears to do usual scalar multiplication on unassigned names, so I'm not exactly sure what was going on for you before.

It's very hard to tell how you entered the original, and got an empty plot. I don't quite see how it could have been 2D Math or 1D input (produces plot*something, or the t range is invalid syntax).

Using the correct range syntax of t=0..5, and without a space between plot and the ( left-bracket, the plot works fine for me as 2D Math input with the Operators palette cross (x, 5th from left, at end of second row in the palette) between the 4 and the t.

acer

You likely went wrong with that x in the t^2-4*x*t.

My guess is that either your x was not assigned a numeric value, or you didn't intend to put it in at all, or you used the x as a multiplication symbol to try and mean 4 x t = 4*t.

Did you mean something like this?

plot([1 + sqrt(t), t^2 - 4*t, t=0..5]);

acer

Try the "tip" in this comment if you are on MS-Windows, or its parent post for Linux.

Also, put outputoptions=[datatype=float[8]] in those RandomMatrix calls.

acer

It might be interesting to see how the output=list solution works out, if the Matrix has clusters of close but not "equal" floating-point eigenvalues. It might turn out that the list format output treats close eigenvalues as distinct, even though one might wish them to be considered as clustered. It might even happen that an eigenvalue with multiplicity greater than 1 (practically) could appear as several values whose difference is only on the order of 10^(-Digits) or so.

Perhaps a clustering approach could be devised (with a re-usable procedure, naturally). Given the Vector of eigenvalues along with a floating-point tolerance (tol), a result might be returned which consists of a list distinct index subranges. The criterion might be that the eigenvalues in each such index subrange all fall within 2*tol  of each other. Or some other averaging clustering scheme might do. Given that list of subranges, it would be very easy to split the Matrix of eigenvectors using the [] Matrix subindexing syntax.

ps. I've been looking at computing eigenvectors associated with selected eigenvalues, using clapack. It may be that the iblock and isplit parameters of clapack's dstebz and dstein could be useful, in the case of a real symmetric Matrix. Those two parameters relate to the blocks that occur in the reduced tridiagonal form of the Matrix. Each eigenvalue is associated with a block in the tridiagonal form, but until I brush up on theory I'm not sure sure what (if any) relationship this might have to clustering.

acer

If the Matrix is 3x1000 and has numeric entries then it (or its transpose) can be sent directly to pointplot3d.

m := LinearAlgebra:-RandomMatrix(3,1000,generator=0.0..1.0,
                   outputoptions=[datatype=float[8]]);

plots:-pointplot3d(m^%T);

acer

Sometimes the Optimization package can be used to find a root under certain constraints. A constant objective (such as 1) may be tried, so that success involves finding a feasible point.

> f:=3*x-y^2:
> g:=sin(x-1/4)*(y-3/4):

> Optimization:-Minimize(1,{f=0,g=0,x+y<=1},x=0..1,y=0..1);
          [1., [x = 0.187499999999996642, y = 0.749999999999993783]]
 
> eval(x+y,%[2]);
                                 0.9375000000

Optimization can also handle constrained problems with procedures rather than expressions.

acer

The multiplicands in the product returned by ifactor have to be prevented from automagically multiplying together, otherwise one would never get a chance to actually see the factored result. This is done by returning the factors as function calls to ``(). Besides preventing the re-multiplication, the ``() function calls have the useful property of being nicely (invisibly) typeset.

You can also get the contents using op() once more.

> sol := ifactor(3^43+1);
                                2
                     sol :=  (2)   (82064241848634269407)
 
> lprint(sol);
``(2)^2*``(82064241848634269407)

> lprint(op(2,sol));
``(82064241848634269407)

> op(op(2,sol));
                             82064241848634269407
 
> expand(op(2,sol));
                             82064241848634269407

> dismantle(%);
INTPOS(6): 82064241848634269407

acer

When I get a few moments I ought to be able to come up some calls to dstebz and dstein (or nonsymmetric equivalents) from clapack, to compute eigenvectors of only selected eigenvalues. Since double-precision clapack 3.0 is bundled with Maple, that sort of thing is often not hard to set up. (One could also use a wholly separate clapack 3.2.x, or arpack, but that requires building it with everything exported and with the right conventions).

The is nothing in Maple for sparse eigensolving, and the conversion ("exploding")  operation from sparse to dense is sometimes unfortunately slow. So you might be better off getting rid of the storage=sparse and stick with the dense 'rectangular' storage. Also, I notice that you have datatype=float so you may wish to ensure that Digits<=trunc(evalhf(Digits)) when those Matrices are created (so that it resolves float->float[8]).

acer

If I might try to clarify just one or two minor aspects of Robert and Alec's good responses:

It is not neceesary to "load" the entire package by issuing the with(LinearAlgebra) command. Even without having issued that command, the individual routines in the package are available using their long form. Eg,

LinearAlgebra:-SingularValues(M);

Given a Matrix, one can right-click on its output and get access to quite a few linear algebra operations using the so-called context-sensitive menus. This is the case even without "loading" the package using with(...).

The call to with(...) merely rebinds the package's exported routines' names, so that they can be called conveniently in their short form.

In 2D Math entry mode (the default for new users) LinearAlgebra:-Determinant may be invoked by placing single | bars around a Matrix, eg. |M| where M is assigned to be a Matrix.

acer

The length of Z and Ay must match. You have them with 18 and 19 elements respectively.

It's CurveFitting, not CureFitting.

acer

G := `#mi("\`The calculation was interrupted.\`",mathcolor = "red")`;

print(G);

acer

What do you want a 3D hypermatrix to be? Do you want an m by n by k Array, or a k-Array or m by n Matrices, or...? How do you want to be able to reference its entries or slices? Are you after something other than a tensor?

acer

Since you asked about how to do this here, you are presumably doing this for sin as an export of a module. And that is OK (others who replied here likely did not realize that you'd been shown how to do it in a module).

In Maple 13.02, in the commandline interface I get output that looks like this,

> m := module() option package; export sin;
> sin := proc(x):-sin(x*Pi/180);end proc:
> end module:
> with(m):
> sin(x);
                                       x Pi
                                   sin(----)
                                       180
 
> Eval(y=sin(x),x=30);
                            /        x Pi \|
                            |y = sin(----)||
                            \        180  /|x = 30

In the Standard GUI I also see similar 2D Math output. In particular, unlike in your post, the x*Pi/180 gets formatted as a visual 2D fraction. Was that what you objected to? (You used Eval rather than eval, so presumably your objection is not that it did not evaluate.)

acer

The first error message is indicating that it failed to write into any of the Library archives in Maple's own installed location. That's safe behaviour, preventing inadvertant permanent clobbering of anything in Maple itself. The second error message is due to the prior failure to save the module.

Try creating a Library archive (.mla file) that is owned and writable by yourself, in a personal folder of your own. See the help for LibraryTools,Create. Then adjust libname in subsequent (or restarted) sessions, so that it can be found.

acer

Try using the fflush command.

acer

First 293 294 295 296 297 298 299 Last Page 295 of 336