acer

32385 Reputation

29 Badges

19 years, 335 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

I was able to open a .mws file in the MaplePlayer 2015 on 64bit Linux, simply by pasting the name of the .mws file into the input line in the File->Open dialog.

And then the Player displayed the contents of the opened .mws worksheet, including plots previously computed and displayed when I ran the worksheet in a session of the Maple GUI proper.

Note that the MaplePlayer is only designed to execute commands that are in the so-called "action code" behind Embedded Components, and the results of such are then dynamically viewable within embedded PlotComponents and MathContainers. That's how the degree of interactivity in the MaplePlayer is designed. The MaplePlayer will not execute input commands in the sheet that lie outside of Embedded Components.

The .mws format does not support Embedded Components, so there can be no interactive computation if you open a .mws file in the Player. You can however view the contents of such worksheets, including output that was generated in a Maple GUI session.

acer

If you load the MTM package then when you call just subs(...) it will invoke the command MTM:-subs which has a different syntax than the global subs command. You can read about it in the help pages.

restart;
F:=MTM:-fourier(f,x,y):
g:=z^2:
MTM:-subs(F,y,g);
                                    / 2\
                        2 f Pi Dirac\z /

restart;
F:=MTM:-fourier(f,x,y):
g:=z^2:
:-subs(y=g,F);
                                    / 2\
                        2 f Pi Dirac\z /

restart;
with(MTM):
F:=fourier(f,x,y): # will call MTM:-fourier
g:=z^2:
:-subs(y=g,F);
                                    / 2\
                        2 f Pi Dirac\z /

restart;
F:=inttrans[fourier](f,x,y):
g:=z^2:
:-subs(y=g,F);
                                    / 2\
                        2 f Pi Dirac\z /

acer

patient: "Doctor, it hurts when I move my arm like this."
doctor: "Don't move your arm like that."

It's not clear to what degree you want the students to be able to interact with the application, apart from manually rotating them. I'm going to guess that you also want them to be able somehow to specify what plot they are viewing.

It seems as if you are trying to use Embedded Plot Components, from which I surmise that you want to offer a choice of plot for the student to view, in one or more such components. Naturally, if you only ever wanted each Plot Component to hold as its value just its own single 3D plot then you could just zoom then all in by hand, and save the document. By virtue of your asking your question I infer that you want the choice of displayed plot to be changed.

If you want the students to be able to view and manually rotate in the Cloud/Player some plots dynamically constructed with some arbitrary properties (the nature of the spacecurves or underlying equations) then you may be out of luck as far as zooming goes. The zoom quality of a 3D Plot inside a Plot Component is not a property which can be set programmatically. It's also not a property of the plot structure either (in the Maple kernel sense). The zoom level of a plot is, alas, a property of only the plot itself and only in the sense of its internal representation by the GUI/Player/client -- and this is reflected in the XML of a saved .mw file.

Moreover, unlike a plot displayed as regular output in a worksheet/document, the properties of zoom and pan (horiz. or vert. offset)  are not persistent qualities of an Embedded Plot Component. By this I mean that if you use the Plot Component manipulator to zoom or pan, and then you set the `value` of that component to be another plot, then the zoom and pan are reset to default.

So the only way I know to get an effect close to what (I believe) you're after is to pre-assemble a Table cell with multiple Plot Components each containing its own pre-zoomed 3D plot. By using buttons or radio buttons or other Action Code of components you can then selectively toggle on and off the `visible` property of these Plot Components. By only ever having one visible at a time you can mimic the effect of replacing the plot in view. Of course this is only workable if you have only a finite set of such plots that you want view in the same spot.

Here's a simple example, with just two Plot Components inserted from the Embedded Component palette into the same single Table cell. You could of course augment this by inserting even more Plot Components into that cell and then adjusting the code such as I put inside the RadioButtons. It works for me in the MapleCloud, or the Maple Player 2015. Notice that the pre-zoomed quality of the "Plot 1" is retained, each time that particular component is again made visible. I made this using the palettes and right-click menus to edit the button's action code. plotchoice.mw

So, as I mentioned, if you want to have the student be able to view a zoomed 3D plot which is constructed on the fly (according to something arbitrary such as the underlying math, etc) then I suspect it is not currently possible.

In the Maple 2015 GUI (not the Cloud or Player) it is possible to view a 3D plot in a programmatically zoomed state, even if it is generated on the fly. I realize that may not be your students' situation, but I mention it for two reasons. 1) It may be of interest to others reading this, and 2) it allows you to specify a particular numeric value for the amount of zoom (or offset).

This might possibly be of some value to you, if you want to be able to make a collection of 3D plots (inside pre-formed Plot Components, or not) with the exact same degree of zoom.

Here is an example that either embeds a Plot Component containing your pre-zoomd 3D plot into the running worksheet or launches it in a new sheet. You should be able to copy and paste the Plot Component and have its plot retain the zoomed quality. This might help if you want to force a specific numeric zoom level. makescaledplot3d.mw

For fun I'll include another example of embedding into a running Maple GUI worksheet a 3D plot whose view is pre-zoomed (so to speak). This one is an animation. makescalledanim3d.mw

I hope this helps.

BTW, all 3D plots inside Plot Components are not working for me in the Maple Cloud at present when I view with Chrome, although they has worked in the past. They are working for me right now if I use Internet Explorer.

I have previously made Software Change Requests that Plot Components get all of zoom, pan offsets, theta-psi-phi rotation angles, and perspective as properties which can be changed using the SetProperty command.

acer

See the second Calling Sequence example collect(a, x, form, func) on the help page for the collect command, and the paragraph in the Description of that page which mentions it. The option func is applied to the coefficents after collecting is done.

ee := expand( A1*cos(s+t) + A2*sin(s+t) ):

ee;

    A1 cos(s) cos(t) - A1 sin(s) sin(t) + A2 sin(s) cos(t) + A2 cos(s) sin(t)

collect(ee, [A1,A2]);
  
     (cos(s) cos(t) - sin(s) sin(t)) A1 + (sin(s) cos(t) + cos(s) sin(t)) A2

collect(ee, [A1,A2], combine);

                          A1 cos(s + t) + A2 sin(s + t)

acer

@Shinjitm You could also unload only the MTM:-sum and leave the rest of the package members' status the same, by issuing unwith(MTM,sum) . That might help with your wish to use the 2D Input summation symbol.

Note that any other command in MTM which makes use of MTM:-sum should function regardless of whether that individual command is loaded.

"Loading" packages or individual commands just binds the names, for convenient (terser) use. You can call individual command exports using the syntax like MTM:-acos regardless of whether the name acos is bound to a package export (ie. loaded from a package).

You can bind (load) what you wish, or not, either wholesale or piecemeal. In any case you can always access both global commands like :-sum or package exports like MTM:-sum.

Optimization:-Maximize(f, x = 0 .. 1, method = branchandbound);

                [0.829528033419476, [x = 0.535545765963319]]

That x value is a few ulps off I think, correct to 9 decimals, given your original expression f computed with floating-point coefficents. You can set Digits higher (say, 30 or higher) and pick up more accurate digits on that x value, for that given f, if you need it. I doubt that higher accuracy has much meaning here, since it doesn't look like you care that the coefficients in your f are being computed coarsely up front.

Consider the power of exact computing here,



a := 1:

f := A*x^(b*alpha)*(alpha*A*x^(b*alpha)/(a+w0*h0+(x-h0)*w1))^(alpha/(1-alpha))-(alpha*A*x^(b*alpha)/(a+w0*h0+(x-h0)*w1))^(1/(1-alpha)):``

NULL

NULL

`assuming`([simplify(combine(f))], [x > 0]);

(2646/625)*x^(7/5)*525^(1/3)*(-1+15*x)/(1+6*x)^(10/3)

max(solve(diff(%, x)));

17/60+(1/60)*229^(1/2)

evalf[20](%);

.53554576584035926545

``

Download maximum_exact.mw

You could also have used the `location` option of the `maximize` command. maximum_fl.mw

And with those exact rational parameters you can also evaluate at the found maximum (or use `maximize`). maximum_exact2.mw

acer

Is this helpful?


restart

assume(varepsilon > 0)

H := Matrix(3, 3, {(1, 1) = 0, (1, 2) = -epsilon, (1, 3) = epsilon, (2, 1) = -epsilon, (2, 2) = 2-2*epsilon, (2, 3) = 0, (3, 1) = epsilon, (3, 2) = 0, (3, 3) = 2+2*epsilon})

H := Matrix(3, 3, {(1, 1) = 0, (1, 2) = -varepsilon, (1, 3) = varepsilon, (2, 1) = -varepsilon, (2, 2) = 2-2*varepsilon, (2, 3) = 0, (3, 1) = varepsilon, (3, 2) = 0, (3, 3) = 2+2*varepsilon})

with(LinearAlgebra):

evals, evecs := Eigenvectors(H):

e1 := convert(simplify(series(evals[1], varepsilon = 0, 4)), polynom)

2+2*varepsilon+(1/2)*varepsilon^2-(7/16)*varepsilon^3

e2 := convert(simplify(series(evals[2], varepsilon = 0, 4)), polynom)

-varepsilon^2

e3 := convert(simplify(series(evals[3], varepsilon = 0, 4)), polynom)

2-2*varepsilon+(1/2)*varepsilon^2+(7/16)*varepsilon^3

K:=map(z->radnormal(convert(MultiSeries:-series(z, varepsilon = 0, 10),polynom)), evecs);

K := Matrix(3, 3, {(1, 1) = -(1/4194304)*`ϵ`*(548197*`ϵ`^7+786432*`ϵ`^6-1389696*`ϵ`^5+1048576*`ϵ`^4-61440*`ϵ`^3-1048576*`ϵ`^2+1835008*`ϵ`-2097152), (1, 2) = (1/2)*(`ϵ`^6-`ϵ`^4-2*`ϵ`^2-4*`ϵ`-4)/`ϵ`, (1, 3) = -(15/1024)*`ϵ`^4+(1/4)*`ϵ`^3+(7/16)*`ϵ`^2+(1/2)*`ϵ`-4, (2, 1) = (1/2097152)*`ϵ`*(165669*`ϵ`^6-183168*`ϵ`^5+86912*`ϵ`^4+61440*`ϵ`^3-192512*`ϵ`^2+262144*`ϵ`-262144), (2, 2) = -(7/4)*`ϵ`^9-(1/2)*`ϵ`^8+(3/4)*`ϵ`^7+(3/2)*`ϵ`^6+`ϵ`^5-`ϵ`^3-2*`ϵ`^2-2*`ϵ`-1, (2, 3) = (1/512)*(559*`ϵ`^4+960*`ϵ`^3+1088*`ϵ`^2-4096*`ϵ`+4096)/`ϵ`, (3, 1) = 1, (3, 2) = 1, (3, 3) = 1})

eval(evecs,varepsilon=1/10):
simplify(combine(simplify(%)),size):
simplify(map(fnormal,evalf[100](%)));

Matrix([[0.4587427651e-1, -22.10049496, -3.945379313], [-0.1133853238e-1, -1.220988432, 72.23232696], [1., 1., 1.]])

eval(K,varepsilon=1/10):
evalf[100](%): evalf(%);

Matrix([[0.4587427612e-1, -22.10049500, -3.945376465], [-0.1133853220e-1, -1.220988432, 72.23234180], [1., 1., 1.]])

#Digits:=100:
#map(plot,map(Re,evecs),varepsilon=1/100..1/10);
#Digits:=10:

#Digits:=100:
#map(plot,K,varepsilon=1/100..1/10);
#Digits:=10:

 


Download someseries.mw

acer

In the attached example the first set of four radio buttons all share the same action code.

radiostuff.mw

The second set of four radio buttons each make a call to the same procedure that is defined in the Startup Code of the worksheet. (Use the main menubar item Edit->Startup Code to see or alter that code). This set won't do anything unless you alloow the Startup Code to run when you open the worksheet or do a restart.

I've deliberately made the examples very simple. There are lots of possible variations. You could use GetProperty and SetProperty (which I prefer) instead of Do. It's not strictly necessary to write if blah = true then when you could write it more tersely as if blah then , but I wanted to make things clear. What I'm trying to convery in the example is how you can utilize values of component properties alongside Maple's usual if..then..else.. conditional programming..

Of course you may not want to have all the actions use exactly the same code. But if you do then, as shown in the lower set of four, you may find it easier to centralize any commonly used code to the Startup Code region.

Another variation, which I have not shown, is one in which the action code calls a procedure and passes to it the name of the current component (and any other that's relevent).

I don't know exactly what you want to do with your components, but hopefully this will help you sort out some of it.

You should also be able to see, at this point, that it is sensible to rename your buttons so that you can make better sense of the code.

acer

The evaluation of the name dim inside the type can be accomplished for createModule2 (using a local dim to hold the value) using the depends parameter modifier.

Since this involves evaluation of the type specification it is then necessary to quote Matrix (so that it doesn't call the Matrix constructor command).

restart;

with(LinearAlgebra):

createModule1 := proc(dim::posint)

    module()

        export det;

        det := (x::Matrix(1..dim,1..dim)) -> Determinant(x);

    end module

end proc:

createModule2 := proc(A::Matrix(square))

    local dim;

    dim := RowDimension(A);

    module()

        export det;

        det := (x::depends('Matrix'(1..dim,1..dim))) -> Determinant(x);

    end module

end proc:

createModule1(       2 ):-det(IdentityMatrix(2));

1

createModule2(Matrix(2)):-det(IdentityMatrix(2));

1

 

Download paramdep.mw

I should have thought of this earlier.

See the help page for topic parameter_modifiers .

acer

Is this what you want to obtain?


restart;

f2 := (diff(y(a, b), a)-(-(1/2)*x-1/2+(1/2)*sqrt(-3*x^2-2*x-3))/x^2)
      *(diff(y(a, b), b)-(-(1/2)*x-1/2-(1/2)*sqrt(-3*x^2-2*x-3))/x^2):

ans := subs(dab=diff(y(a,b),a)*diff(y(a,b),b),
            collect(algsubs(diff(y(a,b),a)*diff(y(a,b),b)=dab, expand(f2)),
                    [diff(y(a,b),a), diff(y(a,b),b), dab]));

(1/2)*(x+1+(-3*x^2-2*x-3)^(1/2))*(diff(y(a, b), a))/x^2-(1/2)*(-x-1+(-3*x^2-2*x-3)^(1/2))*(diff(y(a, b), b))/x^2+(diff(y(a, b), a))*(diff(y(a, b), b))+(x^2+x+1)/x^4

simplify(ans - f2);

0

 


Download coll.mw

acer

One of the important things to remember is the the right-click menu is context sensitive, which means that the various options that appear will vary with the type of thing upon which you click.

For example, you'll see quite a few differences if you bring it up for the output of the command

  Matrix(3,3,(i,j)->1/(1.0+i+j));

versus the output of a scalar like, say,

  sin(2*x)

For example, issue the Matrix command above and right-click on the displayed output. Instead of selecting some action just take note of what you see, and investigate what items appear within the submenus (some of which are Matrix-specific).

In modern Maple the context-menus get augmented or otherwise altered by loading subpackages of the Student package. All the following information may or may not be relevant or useful to you.

You can load these either using the with command, or with the main menubar choice Tools->Load Package .

Execute one or more of the following commands, and notice how new submenus appear near the bottom of the context-menu after you right-click again on that same Matrix output. These new submenus are entitled according to the loaded packages.

  with(Student:-LinearAlgebra):
  with(Student:-Statistics):
  with(Student:-NumericalAnalysis):
  with(Student:-VectorCalculus):

Now notice that not all of those appear when you right-click again on the scalar sin(2*x) output, because not all the commands from those packages are appropriate for scalar arguments.

Now load one or more of these packages,

  with(Student:-Calculus1):
  with(Student:-Basics):
  with(Student:-Precalculus):
  with(Student:-MultivariateCalculus):

Again, right click on the displayed output sin(2*x) and notice the appearance of new submenus for that. Not all of those second set will appear when you right-click on that Matrix output example, because some of this set are mostly appropriate for scalar arguments.

Notice also that these Student package exports (commands) will replace some context-menu items. For example when you load Student:-LinearAlgebra you'll see that the location in the menus of the item for computing Eigenvalues has moved -- the upper submenu item that would previously invoked LinearAlgebra:-Eigenvalues has been removed and the new submenu (at bottom) which invokes Student:-LinearAlgebra:-Eigenvalues is now available.

You can also unload these packages using either the unwith command, or using the menubar Tools item. Issuing the restart command should clear all the loaded packages.

You should take note that some common command names are exported from more than one package,  and that loading a package will rebind the name of the command. If you load the VectorCalculus or Student:-VectorCalculus packages then you rebind the name Vector, and the exported package version of some commands behave slightly differently than do the default global command names. Even when a package is loaded you can still access the global command name, eg. by calling it like :-Vector( ) .

If two packages export the same name as a command then the last one loaded is the one that is currently bound. You can always get at them individually, however. For example :-LinearAlgebra:-DotProduct( ) will call the version from the LinearAlgebra package, even if Student:-LinearAlgebra was loaded last.

The items from those new context-submenus should be hard-coded to get the command that they each appear to be, so you shouldn't have to worry about such name clashes when you use those submenus after loading many packages. But when you type in the commands as code then the order in which the packages were loaded can sometimes make a difference (in the case of a command name that appears in more than one package).

acer

In Maple 2015 this is made simpler by the Units:-UseUnit command.


restart;

simplify( [ Unit(J)/Unit(s), Unit(volt)*Unit(ampere), Unit(W), 1/Unit(W) ] );

[Units:-Unit('W'), Units:-Unit('W'), Units:-Unit('W'), Units:-Unit(1/('W'))]

with(Units:-Standard):

Unit(J)/Unit(s), Unit(1/J)/Unit(1/s);

Units:-Unit('W'), Units:-Unit(1/('W'))

restart;

Units:-UseUnit(volt*ampere):

simplify( [ Unit(J)/Unit(s), Unit(volt)*Unit(ampere), Unit(W), 1/Unit(W) ] );

[Units:-Unit(('V')*('A')), Units:-Unit(('V')*('A')), Units:-Unit(('V')*('A')), Units:-Unit(1/(('V')*('A')))]

with(Units:-Standard):

Unit(J)/Unit(s), Unit(1/J)/Unit(1/s);

Units:-Unit(('V')*('A')), Units:-Unit(1/(('V')*('A')))

 


Download voltampere.mw

An alternative way involves creating a custom system of units by augmenting the SI system with some unit of choice, using a combination of all of the GetSystem, AddSystem and UsingSystem commands from the Units package.

acer

It seems that you want to get a visual display of the progress being made.

One simple way is to use a command such as print, or printf, or userinfo. One drawback to those is that it clutters the worksheet with all the printed values. You can mitigate that by printing only a select number of values (using irem or mod, say) but then you lose the granularity and still have some clutter. Another drawback is that it doesn't work in a Document Block -- the values are only display (all at once), after the whole computation in that Block completes.

If you're using the Standard GUI then read on, for ways that work even if you call the procedure or loop code from within a Document Block.

You can use Embedded Components for this. One way to do it consists of manually inserting say a TextArea or Slider component into the worksheet and then at each iteration of the loop calling DocumentTools:-SetProperty to update the component using the current value of the loop index variable. A drawback of this approach is that if you insert the component from the palette then its position in the worksheet is not dynamic. The location of the component may not always be convenient if you want to re-use it from several places in your worksheet.

One simple alternative available in Maple 2015 is to use DocumentTools:-Tabulate to inform you of the current loop status. Here is an example.

p := proc()
  uses DocumentTools;
  local i, N;

  N := 5;

  for i from 1 to N do

    Tabulate([sprintf("Doing iteration %a of %a",i,N)],
             ':-widthmode'=':-pixels', ':-width'=150);

    Threads:-Sleep(1); # replace with your own computations

  end do;

  InsertContent(Layout:-Worksheet()); # empty

  return i-1; # or whatever you want
end proc:

So now if you call procedure p you can see the effect.

  p();

tab.mw

The above example can be easily modified to show more intermediate results. The first argument passed to Tabulate doesn't have to be a list with only single formatted string -- you could make it a list with a formatted string as well as some math expression and a plot, etc.

If your loop index takes all values from 1 to 10000 then I suggest that you only display some values. For example, using irem to update the display every 500th iteration:

tab2.mw

There are other interesting alternatives, including programmatic insertion of a Slider component (or other sliding component) for use as a progress indicator, instead of the GUI Table that Tabulate inserts. (I have examples, if people are interested...)

acer

Look at the help page for ComboBox components.

Suppose that your ComboBox component has identity "ComboBox0". Then you can do it with the following commands,

L := [m, n, c, k]; # Get a list of parameter names

Ls := map(convert,L,string); # convert them to strings

DocumentTools:-SetProperty("ComboBox0", ':-itemList', Ls, ':-refresh');

acer

This scalar is not zero.

restart;

ee := (-3/186591314-(2/13327951)*I)*(-((28412308*I)*3^(1/2)+44068556*3^(1/2)
      +(-76328978-49211561*I))/(((4*I)*3^(1/2)+4*3^(1/2)+(-7-9*I))^2
      *((-3-4*I)+2*3^(1/2)+(2*I)*3^(1/2))^6))^(1/2);

       /      3          2      \ /  /            (1/2)
       |- --------- - -------- I| |- \28412308 I 3     
       \  186591314   13327951  / \                    

                      (1/2)                           \//
          + 44068556 3      + (-76328978 - 49211561 I)/ |
                                                        \

                                             2 
         /     (1/2)      (1/2)             \  
         \4 I 3      + 4 3      + (-7 - 9 I)/  

                                             6\\      
         /                (1/2)        (1/2)\ ||^(1/2)
         \(-3 - 4 I) + 2 3      + 2 I 3     / //      

simplify(ee);

                               0

evalf[10000](ee): evalf[10](%);

                            -9                 -8  
             -2.481288046 10   - 2.748412826 10   I

acer

First 213 214 215 216 217 218 219 Last Page 215 of 336