acer

9 years, 80 days


These are answers submitted by acer

2D Plot?

22 hours ago acer 10668

For a single 3D plot you can put it into a PlotComponent and then resize that component by adjusting its properties.

For a single 2D plot (including multiple curves, etc, all shown together using plots:-display) you could also put into a PlotComponent and adjust its width and height properties.

But for such a 2D plot, perhaps it's even easier to pass the additional option size=[k,p] to the plots:-display comamnd, where k and p are positive integers representing the width and height in pixels at normal magnification. I am guessing that of all the suggestions I'm making this might be the most suitable for your situation.

For case of an Array of plots (plots:-display(Array([...])), say) the plots are shown in cells of a worksheet "table", which sizing properties of which are available through right-click context-menu (Table Properties).

acer

PlotComponent

December 19 2014 acer 10668

If you have assigned a PLOT3D structure to a name (eg, `myplot`) then such changes will not be retrofitted to the structure assigned to that name when you do right-click context-menu actions on the inlined plot.

But if you create a PlotComponent and use DocumentTools:-SetProperty to set that plot as the `value` of the component, then after such context-menu actions on the plot shown in the component you can subsequently extract a modified structure using the DocumentTools:-GetProperty command.

For example, in the attached worksheet I first created a zgrayscale plot. Then, after putting it into the PlotComponent I used the right-click menus to implment a custom "user" lighting. Then when I extract it from the component I pick off the LIGHT and AMBIENTLIGHT substructures and turn them into the syntax for the plot3d or plots:-display commands.

Note that the PlotComponent seems to retain the options set via the right-click. So if you re-rerun the worksheet the zgrayscale plot (or any 3D plot) will show with that same custom lighting inside the component.

restart:

P:=plot3d(x+y^2,x=-1..1,y=-1..1,shading=zgrayscale,grid=[4,4]):

DocumentTools:-SetProperty(Plot0,value,P);

G:=DocumentTools:-GetProperty(Plot0,value):

alopts:=proc(t) if nops(t)>0 then
                  '':-ambientlight''=[op(t[1])];
                else NULL; end if;
        end proc(indets(G,'specfunc(:-AMBIENTLIGHT)'));

'ambientlight' = [.2, .6, .4]

lopts:=proc(t) if nops(t)>0 then
                  ':-light'=[op(t[1])];
                else NULL; end if;
        end proc(indets(G,'specfunc(:-LIGHT)'));

light = [45.0, 90.0, .5019608, 0., .5019608]

plots:-display(P,lopts,alopts);

 


Download lightstuff.mw

acer

DAE method

December 17 2014 acer 10668

It works for me if I use the method=rkf45_dae or method=rosenbrock_dae options to dsolve(...,numeric), as well as supply another initial condition.

I used Maple 14.01 for 64bit Linux.

For example, it works with the same IC D(h)(0)=Pi/2 used by Dr Subramanian.

ODE := A*(diff(h(t), t))^2+B*(diff(h(t), t))*(h(t)+C)+E*h(t)
       = F*cos(diff(h(t), t)):
ODE_SOLUTION := dsolve({ODE, h(0) = 0,D(h)(0)=Pi/2}, numeric, 
                       method=rosenbrock_dae, range = 0 .. 10, 
                       parameters = [A, B, C, E, F]):
ODE_SOLUTION('parameters'=[0,0,1,1,1]):
with(plots):
odeplot(ODE_SOLUTION,[t,h(t)],0..3);
odeplot(ODE_SOLUTION,[t,D(h)(t)],0..1);

acer

Change

December 16 2014 acer 10668

It would be nice if `int` would try more changes-of-variable by itself.

restart:

f := Int( ln(x+1)/(1+x^2), x=0..1 ):

simplify( value( IntegrationTools:-Change(f, x=sin(v)/cos(v)) ) );

                                 1         
                                 - Pi ln(2)
                                 8         

acer

unapply

December 15 2014 acer 10668

Using Maple 13.01,

fsolve(unapply(.956^2-PpRM(s, .185)-PkRM(s, .895), s), 0 .. 1);

                                0.7739453931

acer

premature evaluation?

December 15 2014 acer 10668

If your procedure sumESQtotal is not written to return unevaluated for nonnumeric inputs then you could try it instead as,

  Minimize( 'sumESQtotal'(A,B) );

with unevaluation quotes. Otherwise Maple will evaluate sumESQtotal at unassigned names A and B.

acer

context-menu

December 14 2014 acer 10668

You could try this: Select with the mouse pointer everything you want converted, then use the right-click context-menu action 2-D Math -> Convert To -> 1-D Math Input.

Another way to do the same thing: from the main menubar choose Edit->Select All (keystrokes Ctrl-a). and then from the menubar Format->Convert To->1D Math Input (keystrokes Alt-r v i)

The above doesn't change document blocks to pairs of execution groups, or insert "> " prompts, and so on. So it doesn't really reformat a Document as a Worksheet.

Maybe I should think about what it would take to write a procedure which does such a conversion, nicely!?

acer

print

December 14 2014 acer 10668

Yes, that's right. A call to the print statement prints.

That allows a way to force a print even when a for-do loop is full color terminated (say, to suppress an avalanche of other results). It is very deliberate and useful behaviour.

It would terrible if issuing the restart statement cleared all output from a worksheet.

The easiest way to clear a whole block of previous output in one fell swoop is to make it all the result of a single function call.

Suppose that your have a procedure such as `f` below.

f:=proc()
     readline();
     print(plot(sin));
     printf("hey!\n");
     print("more");
     return "foo";
end proc:

Now, in a new Document Block or Execution Group issue the command,

  f();

The readline call pops up a dialogue, fine. Click ok, and a few various things are printed to the output of the block/group. Now place the cursor on that same call to f() and hit Enter/Return once again. The very first thing that will happen, even before the popup reappears, is that all the old output of that block/section will vanish. Hence I suggest that your "program" be implemented with an entry point which is a procedure or appliable module.

acer

You haven't shared the worksheet/document with us, but it sounds as if there are some fundamental misunderstandings -- perhaps on both sides here.

Quite often people prepare worksheets/documents with many executable paragraphs (document blocks) or execution groups. It is on purpose that re-executing just one of these will not wipe output of all the others. Some results are very time-consuming to compute, and it would be a much weaker GUI that would always require all output be tied together. I don't see the GUI being at fault in what you've described. It sounds to me more as if you're not using the GUI in the most suitable way for your own task.

It also sounds to me as if you might have spread the various inputs and outputs of your game across several or even many blocks/groups. That doesn't seem like a good idea to me, and if that is the case then I suspect you might be best off doing it otherwise.

My surmise could be wrong, but then you haven't really described the way in which your sheet is currently doing output.

How about making a run of the application (game) cover just one or two blocks/groups? Is the code for the game within procedures? If so, then why not have the procedure print carefully only what must be printed (because function call "output" done within an execution group is in fact replaced in one shot)? Why use multiple readline calls instead of maplets or embedded components which could be easily re-used for both input and output (and be easily cleared)?

acer

something

December 14 2014 acer 10668

These two versions contain as much as I see in the file you uploaded originally (which abruptly ended in the middle of a deep subsection.)

I attach two variants, the second where I just closed up all the outstanding subsections, and the other the same except I expanded all sections before saving. And I also attached a zip file containing both.

FHPBedited.mw

FHPBexpandededited.mw

FHPBedited.zip

Your uploaded worksheet appears to have been last saved with Maple 13.02, so I used that to save the one with all-sections-expanded.

acer

map2

December 14 2014 acer 10668

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

Alt-v l

December 13 2014 acer 10668

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

something

December 12 2014 acer 10668

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.

0.5 .. 2.0

December 11 2014 acer 10668

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

seq

December 11 2014 acer 10668

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

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