# acer

10 years, 295 days

These are answers submitted by acer

### old polynomial data structure

10 hours ago
1 1

I believe it encodes univariate polynomials as if they were in the older internal format for such DAGs rather than the relatively new (couple of years) structure (ZPPOLY? ). The idea being that the Standard GUI only understands the older format.

acer

### some ideas

July 21 2016
1 0

Just a couple of ideas... perhaps you can turn one into something useful for you.

 > G1 := V = Pi*(d/2)^2*h;

1     2
G1 := V = - Pi d  h
4

 > StringTools:-Substitute( latex( algsubs( d/2=d/2, G1 ),                                 output=string),                          "d/2", "d/2" );

"V=\pi\,h{\mbox {{\tt d/2}}}^{2}"

 > StringTools:-Substitute( latex( eval( G1, d=2*d/2 ),                                 output=string ),                          "d/2", "d/2" );

"V=\pi\,h{\mbox {{\tt d/2}}}^{2}"

 > StringTools:-Substitute( latex( eval( G1, d=2*d/2 ),                                 output=string ),                          "d/2", "{\\frac {d}{2}}" );

"V=\pi\,h{\mbox {{\tt {\frac {d}{2}}}}}^{2}"

 > G2 := InertForm:-Display(V = Pi*( %/(d,2) )^2*h, 'inert' = false):
 > latex(G2);

V =\pi ~\frac{d }{2}^{2}~h

 >

acer

### printlevel

July 20 2016
2 1

See the help page for printlevel. (Note that the printlevel command is mentioned in this very regard on the help pages for both if and do.)

restart;

printlevel; # default
1

for i from 1 to 2 do for j from 1 to 2 do 'j'=j; end do; 'i'=i; end do;

i = 1

i = 2

printlevel:=2:

for i from 1 to 2 do for j from 1 to 2 do 'j'=j; end do; 'i'=i; end do;

j = 1

j = 2

i = 1

j = 1

j = 2

i = 2

acer

### something

July 08 2016
0 1

With a little effort you might make this more robust.

restart:

G:=proc(e::algebraic, x::name)
local o,alt,cands;
alt := eval(subsindets( e, identical(x), ()->'tools/genglobal(o)' ));
cands := indets(alt,name) minus indets(e,name) minus {x};
subs([seq(o=x,o=cands)], [seq(isolate(alt,nm),nm=cands)]);
end proc:

G( 2*x-tan(x), x );

[x = 1/2 tan(x), x = arctan(2 x)]

G( 2*x-tan(x*y), x );

arctan(2 x)
[x = 1/2 tan(x y), x = -----------]
y


acer

### not a bug

July 08 2016
1 1

It is not a bug. It is deliberate that procedure bodies are not evaluated at construction time. (For the most part procedure bodies are also not automatically simplified, but that's another matter...)

It would be less useful in general if the final statement in the following returned 3*x.

restart;

a:=3:

f:=x->a*x:

a:=5:

f(x);

5 x


Having said that, the following variant does do what you intended (without recourse to unapply).

restart;

seq(subs(a=aa, x->a*x), aa=1..3);

x -> x, x -> 2 x, x -> 3 x

restart;

f:=x->a*x;

f := x -> a x

seq(eval(subs(a=aa, eval(f))), aa=1..3);

x -> x, x -> 2 x, x -> 3 x

acer

### Typesetting:-Settings

July 07 2016
1 1

The Typesetting:-Settings command covers this.

 > restart;
 > interface(typesetting=extended):
 > Typesetting:-Settings(prime);

 > diff(f(x),x), diff(f(t1),t1);

 > Typesetting:-Settings(prime=t1):
 > diff(f(x),x), diff(f(t1),t1);

 >

acer

### purpose

July 07 2016
0 1

If you are trying to recreate an accented name that already appears elsewhere (outside a code-edit-region) in your Worksheet/Document then lprint it as Robert suggests.

If you want it to appear as the typeset accented name inside the code-edit-region then you are out of luck.

If you are trying to construct an accented name as non-typeset, plaintext Maple Notation code, then you can either do a Robert suggests (create it in a 2D Math input elsewhere, and lprint that) or you can experiment with constructing it with code. For example,

restart;

placehat:=proc(x::name,{italic::truefalse:=false})
cat(#mover(,
if(italic,"mi","mn"),
(",
x,
"),mo("&circ;")));
end proc:

placehat(UU);

placehat(x);

lprint(%);

placehat(x, italic);
lprint(%);


Note that the above code is 1D Maple Notation plaintext code. You can paste it into a code-edit-region or an execution group as 1D code and it should work. If you mistakenly paste it into a paragraph or execution group in 2D Input mode then it won't properly show you the &circ; thing.

On my Linux it seems to me that the &and; and &circ; and &Hat' identifiers all render the same. You could try each.

Using the placehat procedure above you can see the difference between mi and mn, in typesetting. The mn renders like the upright text that appears in the typeset rendering of a string.

I am not satisfied with how these accents get centered according to the bottom of an italic rendered name, rather than the top. To me the accent appears a little too far left, when over an italic symbol.

acer

### typesetting level

July 06 2016
1 1

The display you see is one consequence of having the typesetting level be extended rather than standard, That can be set via the interface command, or via the Tools->Options->Display preferences (main menubar).

 > restart;
 > kernelopts(version);

 > interface(typesetting=standard): 1. * Unit(m);

 > interface(typesetting=extended): 1. * Unit(m);

acer

### dividend

July 06 2016
1 0

This kind of manipulation comes up often enough that Alejandro Jakubi wrote a useful utility for it (and similar operations).

restart;

dividend:=proc(ex,f:=numer(ex),t:=[expand,expand])
local n,d;
n:=t[1](numer(ex)/f):
d:=t[2](denom(ex)/f);
n/d;
end proc:

e:= w^2/(w^4+2*w^2+1);

2
w
e := -------------
4      2
w  + 2 w  + 1

dividend(e, w^2);

1
-------------
2        1
w  + 2 + ----
2
w

dividend(e, numer(e));

1
-------------
2        1
w  + 2 + ----
2
w

The third argument defaults to [expand,expand] and designates the intermediate operations applied to numerator and denominator (before the final division). But it can also be useful when those intermediate operations are some other custom action.

That source definition of dividend can be put in an initialization file, or it can be assigned the name saved to a personal utility Library archive.

acer

### two ways

July 05 2016
1 3

One way (g below) involves having the original procedure be literal in the body of g.

Another way (which may not always work if your f is not set up to act like you intend when called with names as arguments) is to call f to obtain an expression, and then to unapply that to get your new procedure (G below).

restart;

f:=(x,y)->x+y:

g:=subs(_dummy=eval(f), x->_dummy(x,1)):

g(2);
3

G:=unapply(f(x,1),x);

G := x -> x + 1

G(2);

3

f:=(x,y)->x+2*y:

g(2);

3

G(2);

3

acer

### parameters

July 05 2016
0 17

You can make theta be a parameter of the dsolve/numeric procedures.

You do not need to produce an array of values in order to do the maximization. That would be crude and likely quite inaccurate, for this or for other similar "manipulations".

You could also use the events option to halt or trigger when y(t)=0. I haven't bothered to do that, and kept you fsolve.

It's not very good form to do that rhs(sol[4]) sort of thing, just to pick off the proc for y(t) say. That's not critical, though.

For some reason Optimization gets confused when trying to run the dsolve/numeric procedures under evalhf. Or something like that. So I have to set UseHardwareFloats to false, to get it to succeed.

acer

ps. I deleted your duplicate post of this question.

### Ctl-m, Ctl-t, and F5

June 27 2016
1 0

On MS-Windows the Ctrl-m keyboard shortcut will switch from text entry mode to math entry mode, and the Ctrl-t keyboard shortcut will switch from math entry mode to text entry mode.

If you are already in math entry mode in a Worksheet then the F5 key will toggle between 1D (plaintext) Maple Notation and 2D Input.

From your attached image I suspect that what you wanted was the F5 toggle rather than the Ctrl-m/Ctrl-t toggle. It looks to me as if you were already in math entry mode (the red code prompt if in a Worksheet) but were trying to get into 2D Input/2D Math mode.

See the help-pages for more (platform specific) details on keyboard shortcuts.

acer

### simplify,exp

June 23 2016
1 0
restart;

A:=y(x) = (1/3)*exp(x)+_C1/(exp(x))^2;

_C1
A := y(x) = 1/3 exp(x) + -------
2
exp(x)

simplify(A,exp);

y(x) = 1/3 exp(x) + _C1 exp(-2 x)


acer

### various

June 21 2016
0 3

These all seem to work (in the sense that the single backtick name-quotes are not displayed) in my 64bit Maple 2015.2 for Windows 7, including your earlier  y^&ast; attempt.

Of course you might prefer to not have the asterisk raised so high, as happens when it is an exponent.

 > kernelopts(version);

 > with(DEtools): NLC := diff(y(t), t) = k*(Am-y(t)); Am := 20; k := .1; ivs := [y(0) = 10, y(0) = 30, y(0) = 50];

 > DEplot(NLC, y(t), t = 0 .. 20, ivs,        tickmarks = [default,                     [10 = y*,                      30 = y*,                      40 = typeset(y^*),                      50 = y^* ]],        font = [default, default, 15]):
 >

acer

### zero imaginary components

June 19 2016
0 0

The worksheet below may help you manage the display or production of zero-imaginary-components during floating-point eigen-solving.

As for your second question, well, the eigen-space associated with a particular eigenvalue may have more than one linearly independent eigenvector in its basis.

 > restart;
 > with(LinearAlgebra):
 > strain_state := Matrix( [[0.000001904761906, 0.000006190476190, 0.000006190476190],                          [0.000006190476190, 0.000001904761906, 0.000006190476190],                          [0.000006190476190, 0.000006190476190, 0.000001904761906]] ):
 > res1 := Eigenvectors( strain_state );

The nonsymmetric floating-point eigen-solver returns results in a datatype=complex[8] Vector and Matrix, as complex double-precision width is needed in general.

 > VectorOptions( res1[1], datatype );

 > res1[1][1];

The floating-point zero imaginary component of the extracted scalar entries can be removed programmatically using either simplify(...) or simplify(...,zero).

 > simplify( res1[1][1], zero );

An interface setting controls whether floating-point zero components are printed. (It's unfortunate that the item is somewhat misnamed -- I'd prefer it as display_zero_imaginary_part for correctness.)

 > interface( display_zero_complex_part ); # default is true

 > interface( display_zero_complex_part = false ): # toggle it off
 > res1;

 > res1[1][1];

An alternate approach is to instruct Maple to use a floating-point algorithm specific to symmetric eigen-problems. This is done by constructing the Matrix using the shape=symmetric option.

The eigen-solving results are then purely real, the container happens to be a datatype=float[8] Vector and Matrix, and the eigenvalues are sorted. For large floating-point eigen-problems this is also faster.

 > Norm( strain_state - strain_state^%T );

 > Norm( strain_state - Matrix( strain_state, shape=symmetric ) );

I'll toggle the interface setting back, just so as to demonstrate that it does not affect the display of res2 below.

 > interface( display_zero_complex_part = true ):
 > res2 := Eigenvectors( Matrix( strain_state, shape=symmetric ) );

In contrast, the returned Vector and Matrix structures for res2 are both datatype=float[8] because in the symmetric floating-point algorithm purely real results are produced.

 > VectorOptions( res2[1], datatype );

 > res1;

 > res2;

 > res1[1][1];

 > res2[1][1];

 >