acer

10 years, 215 days


These are answers submitted by acer

tool

19 hours ago acer 12441

RootFinding:-Isolate may be considered as a lower-level tool. It is also in use by fsolve for the univariate case.

acer

ctrl-r

22 hours ago acer 12441

It is ctrl-r .

See the help, for more.

acer

map

April 30 2016 acer 12441
A := [ [2,3], [4,5] ,[6,7]]:

map( `/`@op, A );
                                  [2  4  6]
                                  [-, -, -]
                                  [3  5  7]

In current Maple this can be shortened to,

(`/`@op)~(A);

acer

verticalasymptoteoptions

April 30 2016 acer 12441

Just change the verticalasymptoteoptions option to be,

'verticalasymptoteoptions' = ['color' = "Black", 'linestyle' = 'spacedash']

acer

characteristic matrix

April 28 2016 acer 12441

For floating-point Matrices the LinearAlgebra:-Eigenvectors command computes the eigenvectors using something like the qr/qz algorithm implemented in compiled external libraries.

For symbolic Matrices the LinearAlgebra:-Eigenvectors command calls LinearAlgebra:-NullSpace on the characteristic matrix for lambda as each of the computed eigenvalues. Note that in this case the initial solving for the eigenvalues explicitly can itself be difficult since the characteristic polynomial (in unknown lambda) may be difficult or impossible to fully factor.

And the coefficient domain can also throw a wrench in the works, in the symbolic case. For example the special case of Matrices with entries being algebaric expressions with floating-point coefficients may be problematic. It's not difficult to come up with such a Matrix, for which manual eigenvector computation (via NullSpace of the the Characteristic Matrix instantiated at each computed explicit eigenvalue) is achievable even though LinearAlgebra:-Eigenvectors baulks... (should it refuse to attempt a problem from a class for which it may miscompute?).

acer

Matrix, not matrix

April 24 2016 acer 12441

Use the capitalized command name Matrix to create your d and Phi for use with the LinearAlgebra[Generic] package, not matrix.

acer

To answer your questions:

1) The evalf command uses remember tables to store computed results, so that it can quickly look them up instead of recomputing if given the same input at the same (or lower) Digits. But, in order to keep the amount of stored results manageable, the stored results may be cleared when a garbage collection is done.

This is similar to the behaviour you can get on your own procedures, when re-passing previous inputs, if your procedure has option remember,system . Well, the remember table behaviour can be similar, though the interplay with Digits is a special finesse that evalf gets from the kernel.

So the second time your example runs some results may be remembered and thus appear to be computed more quickly (because they are not all being recomputed!). But there is also the possibility that a garbage collection will occur, wiping out that benefit (and in older Maple versions causing a separate delay while it collects).

2) These floating point computations are done by default using software representations of floating point numbers. This is what allows Maple to do floating-point computations at high precision. There are several ways to make Maple use hardware double-precision floating-point numbers for this instead. See here for a brief read.

One of the key things worth noting in Axel's good Answer is that it can also be significantly better to run a whole procedure under a single call to evalhf than to make repeated calls to evalhf inside a loop.

acer

grid explorations

April 23 2016 acer 12441

You cannot use Tabulate and Explore in the same paragraph or execution group as in that case they both write to the same Task region. The same goes for ImageTools:-Embed or anything else that uses DocumentTools:-InsertContent. 

This is a known limitation, documented to some extent in Maple 2016.

The above relates to making separate calls to Explore and Tabulate in the same execution group. Your particular example of a nested csll also cannot work (as is, at present) because Tabulate returns NULL and merely displays results. Tabulate is not returning a result which can be passed to Explore programmatically.

I give your question an up-vote because I like the implications that 1) Explore should be able to handle a grid of "explorations" (which might not all need to be plots), and 2) there should finer control over how plots:-display(Array(...)) or _ARRAYPLOT render, and with in Table Cells should at very least be sensibly aligned and respect PLOT sizes.

As things stand right now you can Explore a plots:-display(Array(...)) call, as you've suggested. But handling of sized plots doesn't work so well in that, and individual cell coloring is not supported, and cell alignment is wonky. Also, all cells get updated upon changed value of any exploration parameter. It would be more useful if the Explore command syntax allowed one to specify a grid (listlist?) of items to explore, including any of plots/expressions/images, each updatable only when only its own dependent parameters changed, and fully supporting individual cell alignment/shading.

acer

combine(...,power)

April 21 2016 acer 12441

If your expression is assigned to name expr then try the command combine(expr, power) .

You might also take a look at simplify(expr, power) which does some additonal work (eg, grouping).

The commands combine(expr) and simplify(expr) will also work, for your particular example. But they can do more work in general, changing some other example in an additional way that might not be desired. The command combine(expr, power) might help get just the change you've described.

acer

phasors

April 20 2016 acer 12441

In this previous answer I gave some code that allows you to enter phasors using 2D Math, and do some arithmetic with them.

In the following example I used the angle symbol from Maple's "Operators" palette, to enter the phasors in 2D Input mode. You could also put the red code that defines the angle object in your worksheet's Startup Code region (or load it into a .mla Library using the commands in the LibraryTools package).

As it stands here the code would also return a floating-point result (without having to invoke evalf) if both angles were given as floats such as 30.0 and 60.0. (I might improve that, to go all floating-point if all the arguments are numeric and any of them is a float...)

restart;

module `∠`()
  option object, `Copyright (c) 2015 by R. Acer. All rights reserved.`;
  local ModulePrint, larg, labs;
  export ModuleApply::static:=proc()
    Object(`∠`, _passed);
  end;
  export ModuleCopy::static:=proc(new::`∠`,proto::`∠`,
                                  v::scalar)
    if nargs=3 then (new:-labs,new:-larg):=1,v;
    elif nargs=4 then (new:-labs,new:-larg):=args[3],args[4];
    else error "invalid arguments"; end if;
  end proc;
  export argument::static:=proc(a) a:-larg; end proc;
  export abs::static:=proc(a) a:-labs; end proc;
  export `+`::static:=proc()
    local a,o,R,z;
    (a,o):=selectremove(type,[args],`∠`);
    if nargs=1 then return args[1];
    else
      R:=add(abs(z)*exp(argument(z)*Pi*I/180),z=a) + add(z,z=o);
      `∠`(simplify(radnormal(:-abs(R)),size),
                simplify(radnormal(:-argument(R)*180/Pi),size));
    end if;
  end proc;
  export `*`::static:=proc()
    local a,o,R,z;
    (a,o):=selectremove(type,[args],`∠`);
    R:=mul(abs(z)*exp(argument(z)*Pi*I/180),z=a) * mul(z,z=o);
      `∠`(simplify(radnormal(:-abs(R)),size),
                simplify(radnormal(:-argument(R)*180/Pi),size));
  end proc;
  export evalf::static:=proc(a)
    `∠`(:-evalf(a:-labs,_rest),:-evalf(a:-larg,_rest));
  end proc;
  ModulePrint:=proc(a)
    '`∠`'(a:-labs,a:-larg);
  end proc:
end module:

`∠`(5, 30)+`∠`(4, 60)

module `∠` () local ModulePrint, larg, labs; option object, `Copyright (c) 2015 by R. Acer. All rights reserved.`; end module

evalf(%);

module `∠` () local ModulePrint, larg, labs; option object, `Copyright (c) 2015 by R. Acer. All rights reserved.`; end module

 

 

Download phasorex1.mw

Does anyone think that I should beautify this and put it on the Application Center?

acer

Rotate, CharacterMap

April 20 2016 acer 12441

Something simple to get you started. You can make it more sophisticated, or efficient. For example you have a number of choices about how to handle lowercase versus uppercase.

restart;

CP:=proc(s::string,n::posint)
  local a1, a2;
  uses StringTools;
  a1:="abcdefghijklmnopqrstuvwxyz";
  a2:="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  CharacterMap(a2,Rotate(a2,26-n),CharacterMap(a1,Rotate(a1,26-n),s));
end proc:

CP("The quick brown fox jumps over the lazy dog", 23);

                             "Qeb nrfzh yoltk clu grjmp lsbo qeb ixwv ald"

CP(%, 3);
                             "The quick brown fox jumps over the lazy dog"

I edited the code above. Originally I had it so that you could pass your own alphabets, optionally, but hard-coded 26 instead of using length. Upon reflection I figure I'll let you make your own enhancements, since you write that it's a project. You should be able to make it more automatic and flexible. A module might be nice.

acer

something

April 20 2016 acer 12441

You may be able to get lucky. If you assume that lambda3 and lambda4 are real and that polynomial P below is always nonnegative then it seems that you can show that the imaginary part of the eigenvalues is 0 as well as convert the eigenvalues to a form that does not contain I explicitly. Would that be enough for you? You may also try to establish that P>=0.

Note that just because I does not explicitly occur in an expression does not mean that under floating-point evaluation (with real values for the parameters) the computed imaginary part will be identically zero. You can still get imaginary float artefacts due to numerical round-off error.

I used 64bit Maple 13.01 for Linux here.

restart;

M1:=Matrix([

 [lambda3+lambda4,0,0,0,0,0,lambda4/sqrt(2),0,0,I*lambda4/sqrt(2)],

 [0,lambda3/4,0,0,0,0,0,0,0,0],

 [0,0,lambda3/4,0,0,0,0,0,0,0],

 [0,0,0,lambda3/4,0,0,0,0,0,0],

 [0,0,0,0,lambda3/4,0,0,0,0,0],

 [0,0,0,0,0,lambda3,0,0,0,0],

 [lambda4/sqrt(2),0,0,0,0,0,lambda3/2,0,0,0],

 [0,0,0,0,0,0,0,lambda2,0,0],

 [0,0,0,0,0,0,0,0,lambda2,0],

 [-I*lambda4/sqrt(2),0,0,0,0,0,0,0,0,lambda4/2]

 ]):

with(LinearAlgebra):

ar:=simplify(radnormal~(Eigenvalues(M1))) assuming real:

P:=1176*lambda4^6-72*lambda4^5*lambda3+27*lambda4^4*lambda3^2
   -114*lambda4^3*lambda3^3+135*lambda4^2*lambda3^4
   +36*lambda3^5*lambda4+12*lambda3^6;

1176*lambda4^6-72*lambda4^5*lambda3+27*lambda4^4*lambda3^2-114*lambda4^3*lambda3^3+135*lambda4^2*lambda3^4+36*lambda3^5*lambda4+12*lambda3^6

(1)

map(u->simplify(simplify(radnormal(combine(evalc(Im(u))))),size),ar^%T)
  assuming lambda2::real, lambda3::real, lambda4::real, P>=0;

Vector[row]([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])

(2)

new:=map(proc(u)
           if not has(u,I) then
             u;
           else
             simplify(simplify(radnormal(combine(evalc((u))))),size)
               assuming lambda3::real, lambda4::real, P>=0;
           end if;
         end proc,
         ar):

map(has,new^%T,I);

Vector[row]([false, false, false, false, false, false, false, false, false, false])

(3)

#plot3d(P,lambda3=-0.1..0.1,lambda4=-0.1..0.1,axes=box,view=-0.001..0.001);

 

 

Download evalsreal.mw

acer

series acceleration

April 19 2016 acer 12441

The series of floats from those BesselJ calls is not converging fast enough for the Levin's U method (internal to evalf/Sum) to accept it as converging.

For this example a crude additional acceleration -- consisting merely of accumulating terms in groups/chunks -- may tip the scales.

Here's the short story version:

restart;

evalf(Sum(Sum(BesselJ(0,(2*N-1)*Pi/4)^2/(2*N-1),
              N=10*(n-1)+1 .. 10*n),n=1..infinity));

                          0.7858522509

evalf[30](Sum(Sum(BesselJ(0,(2*N-1)*Pi/4)^2/(2*N-1),
                  N=10*(n-1)+1 .. 10*n),n=1..infinity));

                0.785852250894067175089762442407

Here it is with a procedure and a little more flexibility. The following was run on 64bit Maple 2016.0 for Windows 7. Mileage may vary by platform/release.

restart;

F:=proc(n, {chunksize::posint:=10})
  add( BesselJ(0,(2*N-1)*Pi/4)^2/(2*N-1),
       N=chunksize*(n-1)+1 .. chunksize*n);
end proc:

F(1,chunksize=3);
evalf(%);

BesselJ(0, (1/4)*Pi)^2+(1/3)*BesselJ(0, (3/4)*Pi)^2+(1/5)*BesselJ(0, (5/4)*Pi)^2

.7576453321

evalf(Sum('F'(n),n=1..infinity));

.7858522509

evalf(Sum('F'(n,chunksize=7),n=1..infinity));

Sum(F(n, chunksize = 7), n = 1 .. infinity)

evalf(Sum('F'(n,chunksize=8),n=1..infinity));

.7858522509

evalf[20](Sum('F'(n),n=1..infinity));

.78585225089406717509

 

Download crudeaccel.mw

acer

GetProperty

April 19 2016 acer 12441

You can use DocumentTools:-GetProperty instead of DocumentTools:-Do, to extract from a TextArea Component without having to use quotes in the TextArea Component.

The result from GetProperty will be a string, but it's simple enough to convert that to a name programatically. In this way the user of the interactive interface does not have to type in any name quotes.

(You could also guard against the user of your interactive interface inadvertantly typing it in it with extra quotes. But if the user typed it in with extra string-quotes then you'd also have to deal with that too if you wanted a name, even if using Do.)

with(DocumentTools):

Do(teksbiasa=%txtTeksBiasa);

Error, (in unknown) incorrect syntax in parse: missing operator or `;` (near 10th character of parsed string)

teksbiasa:=GetProperty("txtTeksBiasa",value);

"Hello! Bob"

lprint(teksbiasa);

"Hello! Bob"

teksbiasa:=convert(GetProperty("txtTeksBiasa",value),name);

`Hello! Bob`

lprint(teksbiasa);

`Hello! Bob`

 


Download text_extraction.mw

acer

GenerateMatrix

April 19 2016 acer 12441

Look at the help page for the LinearAlgebra:-GenerateMatrix command.

acer

1 2 3 4 5 6 7 Last Page 1 of 126