acer

32510 Reputation

29 Badges

20 years, 13 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

Another mechanism for this is map2 (or map[2]).

L1 := [25,5,1,10,4,20];
                         L1 := [25, 5, 1, 10, 4, 20]

L2 := evalf( map( log10, L1 ) );
    L2 := [1.397940008, 0.6989700041, 0., 1., 0.6020599914, 1.301029996]

L2 := map( log10@evalf, L1 );
    L2 := [1.397940009, 0.6989700043, 0., 1., 0.6020599913, 1.301029996]

map2( `^`, 10, L2 );
        [25.00000002, 5.000000000, 1., 10., 4.000000000, 20.00000002]

map2( round@`^`, 10, L2 );
                            [25, 5, 1, 10, 4, 20]

You haven't said anything about precision/accuracy/efficiency needs, so it's not possible to be definitive about what would be best for you. But avoiding custom procs, using kernel builtins, leveraging evalhf, etc, etc, are aspects that might possibly matter to you.

acer

The keysrokes Alt-v l (lowercase l) collapse all sections and subsections, also available from the menubar choice

View->Collapse All Sections.

I don't know of any way to collapse just the outermost sections.

acer

Using Maple 18.02 in Windows 7 64bit, the closet I could get was to use densityplot instead of listdensityplot (so the "grid" lines appear thinner in the GUI, since the latter produces a bunch of polygons...).

restart:

export_plot_options:=font=[TIMES, roman, 30],
                     axis=[thickness=4, location=origin],
                     size=[850,850]:

P:=plots:-densityplot(exp(-(x^2+y^2)*(1/100)),
                      x = -10.0 .. 10.0, y = -10.0 .. 10.0,
                      export_plot_options,
                      grid=[21,21], scaling=constrained):

subsop([1,1]=0..21.5, subsop([1,2]=0..21.5, P));

[edited] I posted the above in the early morning. I now realize that the obscure double subsop step could be replaced by a single call to plots:-translate. Ie,

restart:
export_plot_options:=font=[TIMES, roman, 30],
                     axis=[thickness=4, location=origin],
                     size=[850,850]:
P:=plots:-densityplot(exp(-(x^2+y^2)*(1/100)),
                      x = -10.0 .. 10.0, y = -10.0 .. 10.0,
                      export_plot_options,
                      grid=[21,21], scaling=constrained):
plottools:-translate(P, 10.5, 10.5);

Having done that, I now reazlie that the originally posted example can be handled the same way, using location=origin and a translation. Ie,

restart:
export_plot_options:=font=[TIMES, roman, 30], axis=[thickness=4, location=origin], size=[850,850]:
points := [seq([seq(exp(-(x^2+y^2)*(1/100)), x = -10.0 .. 10.0)], y = -10.0 .. 10.0)]:
P:=plots:-listdensityplot(points, export_plot_options):
plottools:-translate(P, -0.5, -0.5);

Of course, if you don't like the ranges 0..21 then you could adjust to taste. I'm not really sure whether you wanted axes' ranges from -10..10, or 0..21, or 0..21.5, etc.  Or you might ecen want go with densitplot and no translation, as it produces a nicer looking (to me) plot with less obtrusive gridding, and contains an efficient float[8] rtable rather than many list data polygons.

What about using 0.5 .. 2.0 instead of 1..nB as the third argument to surfdata?

If that isn't what you're after then I'm having trouble understanding.

It might also be that you can use a combination of a modified 3rd (or 2nd) argument to surfdata combined with custom tickmarks (possibly using an alternate syntax to what Tom L showed, where the list contains equations of the form value=targetvalue...). I think we just need to understand what you're after.

acer

The step option (increment or decement) is described on the help page for seq.

seq(i,i=5..1,-1);

                         5, 4, 3, 2, 1

Note that 5.-1.2 is parsed as 5. - 1.2 which is a subtraction of two floats, giving 3.8. Your second example is asking for the sequence of operands of the float expression 3.8 (where "operands" means what the op command returns, and where the operands of a float relate to how Maple stores it as mantissa and radix-10 exponent).

5.-1.2;

                                     3.8

5. - 1.2;

                                     3.8

op(0,3.8);

                                    Float

op(3.8);

                                   38, -1

Float(38, -1);

                                     3.8

seq(i, i in Float(38, -1));

                                   38, -1

seq(i, i=Float(38, -1));

                                   38, -1

seq(i, i=3.8);

                                   38, -1

acer

Try adding the file as "maple.ini" to the location that is returned after issuing the Maple command,

  kernelopts(homedir);

Make sure that you're not inadvertantly saving the file as "maple.ini.txt".

Also, it's probably a better idea to just issue the command and not always load the `plots` package. Ie,

  plots:-setcolors("Spring"):

acer

coeff(convert(ggg,polynom),t,-1);

The point is not so much to get something of type polynom as much as it is to remove the `O` term.

acer

The command,

Typesetting:-Settings(functionassign=false):

will cause subsequent occurences of that bit of 2D Math input syntax to be parsed as a remember table assignments. You could put that inside the Startup Code Region of your Document/Worksheet. This is better than leaving it as a popup query since you may wish to pass your document along to someone else unfamiliar with your intention.

Or switch to using 1D Maple Notation input mode in execution groups, where the syntax in question is unambiguous and always parsed as a remember table assignment. See Preben's response for a way to do that session-wide or even cross-session.

You could then still create operators using the superior, unambiguous syntax which works in both 1D Maple Notation and and 2D Math input modes,

BG := (i,j) -> stuff

acer

The runtime redistributables of some MKL v11.x exist in Maple 18.01 for 64 bit Linux and OSX. I have obtained some performance results for the cited Matrix float[8] Rank test using Maple 18.02 that are pretty much identical to those of Mathematica 9 and 10, on those two platforms. I tried up until about size 2500x2500. (See also this post and comment.)

The version of MKL used in Maple 18.x on 32 and 64bit Windows appears to be some v10.x, which series dates from about 2008-2009. And on the 64bit Windows platform (which is what Nasser used in the first link you've cited) there is still a discrepancy. A quoted timing of 0.35 sec for computing all the singular values of a 1000x1000 float[8] Matrix is pretty fast, but not as fast as the quoted timing for Mathematica as 0.16 sec.

The author of the pages in the first link you gave posted in the Wolfram Community forum a while back. He encountered new out-of-memory problems when running his test at larger sizes in Mathematica 10. He apparently resolved that by setting a preference to disable the new multi-undo feature.

acer

One way is to use a customized system. Eg, compare the before and after.

restart:

Unit(m^2*kg/(s^4*A));

simplify( Unit(m^2*kg) / Unit(s^4*A) );

simplify( 1/Unit(s) );

with(Units):
AddSystem( MySI, GetSystem(SI), volt/microsecond, hertz );
UseSystem( MySI );

Unit(m^2*kg/(s^4*A));

simplify( Unit(m^2*kg) / Unit(s^4*A) );

simplify( 1/Unit(s) );

This should also work with Units[Standard] functionality, combine(..,units), etc.

Note that other poswers of these dimensions are not necessarily affected. To get 1/second^2 to come out as Hz^2 you'd need to also include hertz^2 in the additional arguments, when defining the new system. Etc.

Another way is to just compute with some stock system like SI, and then convert final results. Eg,

restart:
convert( 55*Unit(mm^2*g/(ms^4*A)), units, volt/microsecond );

acer

add(x, x in A);

or,

convert(A,`+`);

or, (essentialy like the last one),

`+`(A[]);

acer

If you are not using high precision (ie, Digits > evalhf(Digits) ) then you may as well just use method=LU. And that is the default method for such float data.

Below, I set the infolevel so that some additional details about the computation are shown.

restart;
with(LinearAlgebra):

infolevel[LinearAlgebra]:=2:

A:=Matrix([[1,3],[2,5]],datatype=float):
b:=Vector([1,1],datatype=float):
LinearSolve(A,b);

LinearSolve: using method LU
LinearSolve: calling external function
LinearSolve: NAG hw_f07adf
LinearSolve: NAG hw_f07aef
                                    [-2.]
                                    [   ]
                                    [ 1.]

acer

The display command is part of the plots package. So either load that package first, by issuing,

with(plots):

or call it by its long-form names plots:-display or plots[display].

I edited your code a bit. As a general rule, don't try and use a non-indexed name such as x alongside its indexed form such as x[i]. Check that I didn't mess it up.

restart:

h := .1;
x[0] := 0;
y[0] := 1;
xf := 3;
n := floor(xf/h);
f:= (x,y)->1/(3*y-x-2);

for i from 0 to n do
k1 := f(x[i], y[i]);
k2 := f(x[i]+(1/2)*h, y[i]+(1/2)*h*k1);
k3 := f(x[i]+(1/2)*h, y[i]+(1/2)*h*k2);
k4 := f(x[i]+h, h*k3+y[i]);
k := (k1+2*k2+2*k3+k4)*(1/6);
y[i+1] := h*k+y[i];
x[i+1] := x[i]+h
end do:

data := [seq([x[n], y[n]], n = 0 .. 30)]:

p[2] := plot(data, style = point, color = blue):
p[3] := plot(data, style = line, color = blue):

exact := dsolve( { diff(Y(X),X)=1/(3*Y(X)-X-2), D(Y)(0)=1 } ):

Pexact := plot( eval(Y(X), exact), X=0..3, style=point,
                symbol=cross, symbolsize=20,
                adaptive=false, numpoints=20 ):

plots:-display(seq(p[n], n = 2 .. 3), Pexact);

acer

What you see at the end of the AiryBiZeros procedure is an unevaluated return. Notice the single right-quotes in that function call, which will be a return value.

It just means that, when argument n is something for which the procedure cannot compute a result then the procedure returns an unevaluated function call to itself.

acer

In your example eq is of type `=` and lhs(eq) is of type `+`.

The op command allows you to pick off specific operands (addends of the sum), by position.

restart:

act := proc(eqn)
  if type(eqn,`=`) and type(lhs(eqn),`+`) then
    eqn - op(2, lhs(eqn));
  end if;
end proc:

act( a + b = 0 );

                             a = -b

act( a + b + c = 0 );

                           a + c = -b

acer

First 233 234 235 236 237 238 239 Last Page 235 of 337