acer

32480 Reputation

29 Badges

20 years, 6 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

plot(sin(x),labels=["my x-axis","my y-axis"],
     labeldirections=[horizontal,vertical]);

acer

If you are using 2D Math input mode (the default, so you likely are) then the "OverBarUnder" item in the Layout palette can do this.

Look for the Layout palette, as a panel at the left of the Standard Maple interface (GUI). Open it. One of the items appears as an A with a bar under it. In 2D Math mode, simply double-click on that. Doing so should insert the appropriate doubly-underlined template, for which you can overwrite the content A.

acer

The string "i" doesn't change just because you changed the value of i. It'll always be simply "i". That's no bug.

You can fix your code in several ways. In this first way below, your procedure test is unchanged while the way to call it using i is altered.

> restart:
> test:=proc(s::string)
> print( cat("Matrix_",s) );
> end proc:

> for i from 3 to 4 do
> test(convert(i,string));
> od;
                                  "Matrix_3"
 
                                  "Matrix_4"

In this next way, both the procedure `test` and the way it gets called are altered.

> restart:
> test:=proc(s)
> print( cat("Matrix_",s) );
> end proc:
>
> for i from 3 to 4 do
> test(i);
> od;
                                  "Matrix_3"
 
                                  "Matrix_4"

Notice that,in that last example, `cat` is automatically converting the integer s to a string so that it can concatenate with it. But that wouldn't work if s were 9.3 a float. So you could bolster it like so,

> restart:
> test:=proc(s)
> print( cat("Matrix_",convert(s,string)) );
> end proc:

> for i from 3 to 4 do
> test(i);
> od;
                                  "Matrix_3"
 
                                  "Matrix_4"
 
> test(9.3);
                                 "Matrix_9.3"

acer

Replace pi with Pi.

In Maple, lowercase pi doesn't mean anything special.

acer

Your integration range is being supplied as f=100..1000 where the range endpoints 100 and 1000 are exact integer (not floating-point) values. In that case, calling value() will bring about exact integration rather than numerical quadrature.

To get (here, much faster) numerical quadrature call evalf() instead of value(), or replace 100..1000 with 100.0..1000.0 as a floating-point range.

See the ?evalf,Int help-page.

acer

This has the advantage that it doesn't involve having to repeat actions with the mouse pointer (ie. is programmatic). And it is sometimes easier than using frontend (which can sometimes be trickier, when it freezes too much).

As mentioned elsewhere,

gdiff := (f,x)->thaw(value(subs(x=freeze(x),Diff(f,x)))): #
gdiff(5*x^2+y,x^2);

(The pre tag is acting up! It looks good in the editor, but is lost on submission.)

acer

First, you should lose the habit of loading a package using `with`, and then using its exports inside a proc.

Instead, either use the full name inside the proc, or use `uses` or `use.

For example you could put the line,

uses LinearAlgebra:-Modular;

at the beginning of your proc, and remove that `with` call altogether.

Next, avoid a mismatch in datatypes. Try changing the last argument of `Create` from ('integer')[] to simply 'integer'. Alternatively, insert datatype=integer[kernelopts(wordsize)/8] as a last argument to the Matrix call where TestMatrix is created.

acer

It looks as if you may be getting bitten by "premature evaluation".

You pass X(a,b) to Optimization:-Maximize. But, as is Maple's usual behaviour, that argument X(a,b) gets evaluated up front before a or b are assigned numeric values. Your routine X does not appear to be prepared for that symbolic input a,b. The unintended evaluation of X(a,b) prior to parameters a and b getting values (which happens only subsequently, inside the routine X), is premature.

There are a few ways to handle that. One is to have X return unevaluated if a and b are not both numeric.

X := proc(a,b)
local ...
  if not( type(a,numeric) and type(b,numeric) ) then
    return 'procname'(args);
  end if;
  ...
end proc:

Another way is to pass arguments to Maximize in so-called operator form. (See the ?Optimization,General,OperatorForm help-page, and in particular the last Example.) For that form, you'd be passing just X rather than X(a,b), and [.6,.2] rather than [a=.6,b=.2], etc. You'd also need to read the section on passing the constraints as a list of procedure(s).

Another way that might work better is to pass 'X'(a,b) so as to delay evaluation.

This also comes up with plot, fsolve, evalf/Int, etc.

acer

> fsolve(unapply(hite(t)-11853,t),0..1000);
                               33.00303938

> fsolve(t->hite(t)-11853);
                               33.00303938

In Maple 13, you could call dsolve/numeric using 'ground' as a 'parameter'. See ?dsolve,numeric,IVP for explanation of the parameters option.

You might also have a look at the ?dsolve,numeric,Events help-page. That might be what you'd call the "elegant" way to do this sort of thing.

acer

A flexible tool for this is verify,list.

See a recent usage example by Joe here (including for float entries)

acer

Yes, look at the module help-page. That's what you should use to create a package.

Look also at the Advanced Programming Manual (available here) which has material on this in section 2.3 and chapter 2 in general.

This comment might also be of some (lesser) use.

acer

By default you cannot write to the Maple system archives, so that you cannot inadvertantly clobber their contents.

First create a writable personal archive of your own, using LibraryTools:-Create or march. Then either prepend its location to libname, or set savelibname, so that your subsequent calls to savelib will use that new, personal archive.

If you are having problems with a routine such as savelib, you can try both reading its help-page as well as following some of the cross-references in its See Also section.

acer

The square-bracket subindexing notation provides this for Vectors, Matrices, and Arrays.

> A:=<1,2,3,4,5>:

> A[1..3];
                                      [1]
                                      [ ]
                                      [2]
                                      [ ]
                                      [3]
 
> A[..3];
                                      [1]
                                      [ ]
                                      [2]
                                      [ ]
                                      [3]
 
> A[1..-3];
                                      [1]
                                      [ ]
                                      [2]
                                      [ ]
                                      [3]

> A[2..4];
                                      [2]
                                      [ ]
                                      [3]
                                      [ ]
                                      [4]

acer

In Maple 13, you can use ~ to modify the minus (-) operator.

`#msub(mi("x"),mi("coord"))` -~ `#msub(mi("y"),mi("bar"))`;

In Maple 12 and earlier, you can use map instead.

map(`-`, `#msub(mi("x"),mi("coord"))`, `#msub(mi("y"),mi("bar"))` );

acer

Do you mean that you want all computations to be done modulo 26? If that means linear algebra computations then you can use LinearAlgebra:-Generic. I don't know a convenient way to get it automatically for all scalar arithmetic except by creating your own package with exported/overloaded operators.

acer

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