acer

10 years, 271 days


These are answers submitted by acer

Ctl-m, Ctl-t, and F5

Yesterday at 11:01 PM acer 12515

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 acer 12515
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 acer 12515

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^`*` attempt.

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

 

kernelopts(version);

`Maple 2015.2, X86 64 WINDOWS, Nov 13 2015, Build ID 1087698`

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];

diff(y(t), t) = 2.0-.1*y(t)

20

.1

[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]):

 



Download ast.mw

acer

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 );

res1 := Vector(3, {(1) = -0.428571428400000e-5+0.*I, (2) = 0.142857142860000e-4+0.*I, (3) = -0.428571428400000e-5+0.*I}), Matrix(3, 3, {(1, 1) = -.816496580927726+0.*I, (1, 2) = .577350269189626+0.*I, (1, 3) = -.347191979943471+0.*I, (2, 1) = .408248290463863+0.*I, (2, 2) = .577350269189626+0.*I, (2, 3) = -.466398773129650+0.*I, (3, 1) = .408248290463863+0.*I, (3, 2) = .577350269189626+0.*I, (3, 3) = .813590753073122+0.*I})

 

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 );

complex[8]

res1[1][1];

-0.428571428400000e-5+0.*I

 

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 );

-0.4285714284e-5

 

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

true

interface( display_zero_complex_part = false ): # toggle it off

res1;

Vector(3, {(1) = -0.428571428400000e-5, (2) = 0.142857142860000e-4, (3) = -0.428571428400000e-5}), Matrix(3, 3, {(1, 1) = -.816496580927726, (1, 2) = .577350269189626, (1, 3) = -.347191979943471, (2, 1) = .408248290463863, (2, 2) = .577350269189626, (2, 3) = -.466398773129650, (3, 1) = .408248290463863, (3, 2) = .577350269189626, (3, 3) = .813590753073122})

res1[1][1];

-0.428571428400000e-5

 

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 );

0.

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

0.

 

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 ) );

res2 := Vector(3, {(1) = -0.428571428400000e-5, (2) = -0.428571428400000e-5, (3) = 0.142857142860000e-4}), Matrix(3, 3, {(1, 1) = .408248290463863, (1, 2) = .707106781186548, (1, 3) = .577350269189626, (2, 1) = .408248290463863, (2, 2) = -.707106781186547, (2, 3) = .577350269189626, (3, 1) = -.816496580927726, (3, 2) = 0., (3, 3) = .577350269189626})

 

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 );

float[8]

res1;

Vector(3, {(1) = -0.428571428400000e-5+0.*I, (2) = 0.142857142860000e-4+0.*I, (3) = -0.428571428400000e-5+0.*I}), Matrix(3, 3, {(1, 1) = -.816496580927726+0.*I, (1, 2) = .577350269189626+0.*I, (1, 3) = -.347191979943471+0.*I, (2, 1) = .408248290463863+0.*I, (2, 2) = .577350269189626+0.*I, (2, 3) = -.466398773129650+0.*I, (3, 1) = .408248290463863+0.*I, (3, 2) = .577350269189626+0.*I, (3, 3) = .813590753073122+0.*I})

res2;

Vector(3, {(1) = -0.428571428400000e-5, (2) = -0.428571428400000e-5, (3) = 0.142857142860000e-4}), Matrix(3, 3, {(1, 1) = .408248290463863, (1, 2) = .707106781186548, (1, 3) = .577350269189626, (2, 1) = .408248290463863, (2, 2) = -.707106781186547, (2, 3) = .577350269189626, (3, 1) = -.816496580927726, (3, 2) = 0., (3, 3) = .577350269189626})

res1[1][1];

-0.428571428400000e-5+0.*I

res2[1][1];

HFloat(-4.285714284000001e-6)

 

 

Download cmplxzero.mw

acer

another approach

June 16 2016 acer 12515

Here is a quick shot at an alternate (less sophisticated) approach of weighted averaging of nearby pixels.

fiximg.mw

The timing are from a run using 64bit Maple 2016.1 for Linux on a quad-core i5. I made no attempt to parallelize (though I expect it would be easy to do by splitting one of the outer loops into pieces and using Threads:-Task (like for those escape-fractals...).

I don't do anything to correct the edge pxels (which require only a slightly different scheme).

The crude proc which applies the damage could be improved, so that the final percentage of damaged pixels could be supplied as target (and respected).

 

Here is a version with 35% pixels "damaged" (set to white),

And here is the fixed image.

acer

rand

June 14 2016 acer 12515
f:=rand(0..255):

[seq([seq(f(),j=1..3)], i=1..5)]; 
                  
      [[220, 141, 49], [122, 174, 7], [105, 173, 171], [136, 76, 186], [143, 128, 197]]

You could also wrap those inner lists of triples in call to ColorTools:-Color, etc. Eg,

[seq(ColorTools:-Color([seq(f(),j=1..3)]), i=1..5)];

acer

greater care

June 14 2016 acer 12515

You may have made the mistake of interpreting x=y^(1/3) (outside of the RealDomain context) as being purely real-valued for y::real.

Consider which of the results in s1 below will evaluate to x=-2 when y=-8 . Notice that it is not the result of x=y^(1/3) .

restart;

s1 := [solve( {y-x^3}, x)];

   [ /     (1/3)\    /      1  (1/3)   1    (1/2)  (1/3)\   
   [{ x = y      }, { x = - - y      + - I 3      y      }, 
   [ \          /    \      2          2                /   

      /      1  (1/3)   1    (1/2)  (1/3)\ ]
     { x = - - y      - - I 3      y      }]
      \      2          2                / ]

for s in s1 do
  print( s, radnormal(eval(s, y=-8)), evalf[5](evalf(eval(s, y=-8))) );
end do:

  /     (1/3)\    /            (1/2)\                          
 { x = y      }, { x = 1 + (-3)      }, {x = 1.0000 + 1.7321 I}
  \          /    \                 /     
                     
  /      1  (1/3)   1    (1/2)  (1/3)\             
 { x = - - y      + - I 3      y      }, {x = -2}, {x = -2.0001 + 0. I}
  \      2          2                /             

  /      1  (1/3)   1    (1/2)  (1/3)\    /           (1/2)\   
 { x = - - y      - - I 3      y      }, { x = 1 - I 3      }, {x = 1.0001 - 1.7321 I}
  \      2          2                /    \                /   

But you do want x=y^(1/3) when y>0. So (outside of using RealDomain) a purely real-valued solution might be expressed as a piecewise, using the first item in s1 when y>=0 and the second item in s1 when y<0 . For example,

s2 := piecewise( y>=0, y^(1/3), y<0, -(-y)^(1/3) ):

plot( s2, y=-8..8, size=[200,200] );

Does anyone see a nice way to get :-solve to return something like that piecewise?

An alternative is to get solve to return an implicit RootOf (Maple 2015.2 used here) which evaluates to a real for real numeric y. For example,

s3 := solve( y-x^3, x, parametric, real );

            [[          /  3                     \]]
            [[x = RootOf\_Z  - y, index = real[1]/]]

s := s3[1];

             [          /  3                     \]
             [x = RootOf\_Z  - y, index = real[1]/]

evalf(eval(s,y=-8));

                           [x = -2.]

Unfortunately this is slower to plot, as it evaluates to floats internally using `evalf/RootOf` which I suspect has to go through fsolve or some numeric root-finder.

plot( eval(x,s), y=-8..8, size=[200,200] );

pr.mw

equations

June 13 2016 acer 12515

You have a sequence separated by a comma instead of an equation using `=`, for each of your eq1, eq2, eq3.

restart:

eq1 := x^2+y^2+z^2-134*x+800*y-360*z+31489=2:
eq2 := x^2+y^2+z^2-934*x+900*y-370*z+321789=2:
eq3 := x^2+y^2+z^2-614*x+1350*y-1110*z+70048=97:

sols:=[solve({eq1, eq2, eq3}, {x, y, z}, explicit, allsolutions)]:

nops(sols);
    
                                                             2

for s in sols do simplify(map(rhs-lhs,eval([eq1, eq2, eq3],s))); end do;

                                                         [0, 0, 0]

                                                         [0, 0, 0]

acer

Maple 2015

June 09 2016 acer 12515

Indeed, in Maple 2016 the examples in vv's Answer work, due to enhanced resolution by Explore of assigned names. (See the section "Name resolution" here.)

In Maple 2015.2 I could get the following modified examples to work (by working around the special-evaluation rules of Explore on its first argument).

restart;
N  := 2:
F  := add(P||k * x^k, k=0..N):
G := [seq(P||k=-1.0 .. 1.0, k=0..N)]:
eval('Explore'('plot'(F, x=0..1), parameters=G));

and,

restart;
F := a*x:
eval('Explore'('plot'(F, x=0..1), parameters = [a=0.0..1.0]));

something

June 08 2016 acer 12515

There seemed to be some combination of tags like <Font> ... <TextField> ... </Font> ... </Text-field> which may be closed out of order. Or similar things like that with Font tags. After trying to sort those out I get this.

Why1.mw

Does that contain most or all of what you expected? There appear to be one or two places where assignment statements inlined in text are unexpected, upon re-execution with the !!! from the main menubar. Hopefully you could cut and paste to sort those out.

acer

works for me

June 01 2016 acer 12515

It works for me using 64bit Maple 2016.1 on 64bit Windows 7 Pro.

But I had to define n, which I did using a new integer[4] local. Otherwise it still compiled but did not run. It also worked if I assigned a suitable value to global n.

For a concrete example it worked whether I used the autocompile step or the explictly compiled proc which I assigned to name cstep and ran.

Have you tried it with n declared local and assigned? And without the option autocompile?

In Maple 2016 Compiler:-Compile will used the external llvm compiler that is bundled with Maple. That compiles to an object in memory and runs it directly on the stack, I believe. If it fails to compile for you (but does for others) then you might get joy by passing the option inmem=false to Compiler:-Compile. although that might require you to have a working MSVC++ like for Maple 17(?) and older. That would revert to the older mechanism of compiling generated C code to temporary object file and dll. I have several of the "free" MSVC++/SDK for 64bit Windows installed, which is how my older Maple's also use Compile. For me it works with or without the inmem=false option.

acer

view

May 29 2016 acer 12515

You can supply a forcing view when using the draw command. (I am using Maple 2016, since that is listed as the product in question here.)

But if you don't want to figure out the pertinent ranges then it might just be easier to get rid of the VIEW substructure.

restart;

with(geometry):

point(P1,[47+(38+22/60)/60, -(122+(43+4/60)/60)]):
point(P2,coordinates(P1) +~ [cos(30*Pi/180),sin(30*Pi/180)]):
line(L1, [P1,P2], [x,y]):
Equation(L1);

-(1/2)*x+(1/2)*3^(1/2)*y+85751/3600+(55223/900)*3^(1/2) = 0

# First way is irritating because you need to know and supply
# useful ranges.
# plots:-implicitplot is often also irritiating in that fashion.

draw([L1], ':-view'=[-10..10,-160..-140]);

subsindets(draw(L1),specfunc(VIEW),z->NULL):

plots:-display(%, scaling=unconstrained);

 

 

Download drawwithview.mw

acer

all I see

May 23 2016 acer 12515

Here is a link to a sheet (Document) with all that I can see as recoverable.

P3try1.mw

The sheet was prematurely curtailed with some XML tags unclosed. I've seen that kind of problem before. I don'tr know why the GUI is so poor at recovery in such situations.

The final bit, that was chopped, was an Image item. That did not seem recoverable. It was the only thing in a Group. So I excised the incomplate Image, its parent Group, and then closed its parent Section and the Worksheet.

Perhap someone else could see more..

acer

a? b?

May 18 2016 acer 12515

How do you expect anything to work if `a` and `b` are not numeric?

If they were then you could try it like so,

  Matrix([seq([seq(helper3(i,j),i=1..size_B)],j=1..size_B)],datatype=float);

acer

profile

May 18 2016 acer 12515

The more of your code you put within procedures the more you'd be able to profile. See the CodeTools:-Profile command. You could use it on your MyProc procedure, for example. There are also other older mechanisms for profiling (profile, exprofile, excallgraph, nprofile, etc).

Also, if your large expressions are assigned to locals within procedures (as much as possible) then you allow garbage collection to collect more of it automatically upon return -- as opposed to having to unassign names, say.

Calling forget(MyProc) probabaly won't do much for you, if that procedure itself does not have option remember or option cache.

I haven't used it in some time, but you might see whether Robert Israel's sniffmem procedure can reveal anything useful about which system procedures may be getting a lot of remember table clogging.

As a general rule, avoid as much assignment at the top level as possible. Try hard to not use use global names in your procedure.

Run `mint` against your code, as a general practice, which may provide some hints about use of globals but is otherwise not a bad idea in general. See here if you want to try running it in a worksheet instead of copying your MyProc code to a text file.

acer

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