pagan

5147 Reputation

23 Badges

17 years, 122 days

 

 

"A map that tried to pin down a sheep trail was just credible,

 but it was an optimistic map that tried to fix a the path made by the wind,

 or a path made across the grass by the shadow of flying birds."

                                                                 - _A Walk through H_, Peter Greenaway

 

MaplePrimes Activity


These are replies submitted by pagan

Quote the m using single-right quotes in the pop-up, when doing that Units->Replace Units context-menu action.

You previously assigned to the global name m.

So if you want to use it elsewhere as a unit name, then you have to use so-called uneval quotes (single right-quotes. Otherwise it will get evaluated to whatever you previously assigned to it.

Eg, 'm'

 

As for the evalf question, things tend to break down when Digits is set to less than 4 or 5. We can investigate your example as a simple "atomic" operation -- a multiplication of e1 and e2 which are two floats. At very low Digits the computed result is not accurate to less than an ulp (let alone less than 1/2 an ulp).

> restart:
> e1:=evalf[20](Pi):
> e2:=evalf[20](4*(1391000/2)^2):
> T2:=evalf[20](e1*e2):

> for d from 1 to 10 do
>   forget(evalf);
>   T1:=evalf[d](e1*e2);
>   print([testfloat(T1,T2,1,test=1,digits=d)]);
> end do:
                             [true]
                      [[false, 2., ulps ]]
                      [[false, 2., ulps ]]
                             [true]
                             [true]
                             [true]
                             [true]
                             [true]
                             [true]
                             [true]

A lesson here is that evalf[d] isn't so useful for very small d (<5). If you want merely to get a shorter form of a floating-point coefficient of a final result then you could either apply evalf[2] to (only) the final value or use the elision settings in the Standard GUI to modify displayed floating-point values automatically (see Options->Precision from the toolbar).

@pepper4two It could also be done without need for the extra table T. But here is a simple reworking. Hopefully it is closer, and gives you more of an idea of what you can do.

restart:
with(Maplets:-Elements):

A:=Array(1..3,1..3,[["At 200 deg","At 375 deg","At 150 deg"],[d,e,f],[g,h,i]]):
T:=table(["At 150 deg"=3,"At 200 deg"=1, "At 375 deg"=2]):

f:=proc() local L,u;
        L:=convert(A[2..,T[Maplets:-Tools:-Get('colDDB')]],'list');
        Maplets:-Tools:-Set('myDDB'('itemlist')=map(u->convert(u,'string'),L));
        L; end proc:

mymaplet := Maplet([
   ["Update this drop box of column entries... ",
    DropDownBox['myDDB'](map(u->convert(u,string),
                         convert(A[2..,op(1,rtable_dims(A)[2])],'list')))],
   ["...by selecting a column from this drop box: ",
    DropDownBox['colDDB']([seq(A[1,i],i=rtable_dims(A)[2])],
                          'onchange'=Evaluate('TF'='f()'))],
   [TextField['TF']()],
   [Button("OK", Shutdown())]
                   ]):

Maplets:-Display(mymaplet);

Have you considered not having any dynamically updated drop-boxes at all? Just have two drop-boxes, one with the temperatures and one for the materials' names. Then when you re-select from either it would update something (return value or a text field) with the corresponding value from the data grid.

restart:
with(Maplets:-Elements):

A:=Array(1..3,1..3,[[a,b,c],[d,e,f],[g,h,i]]):
TT:=table(["At 150 deg"=3,"At 200 deg"=1, "At 375 deg"=2]):
TM:=table(["material C"=1,"material A"=2,"material B"=3]):

f:=proc()
   A[TM[Maplets:-Tools:-Get('rowDDB')],TT[Maplets:-Tools:-Get('colDDB')]];
   end proc:

mymaplet := Maplet([
   ["select a temperature: ",
    DropDownBox['colDDB'](op~([indices(TT)]),
                          'onchange'=Evaluate('TF'='f()'))],
   ["select a material: ",
    DropDownBox['rowDDB'](op~([indices(TM)]),
                          'onchange'=Evaluate('TF'='f()'))],
   [TextField['TF']()],
   [Button("OK", Shutdown())]
                   ]):

Maplets:-Display(mymaplet);

Note that whatever gets assigned (above) into a Text box you could alternatively make the return value that gets inserted into the worksheet when you press the OK button. (I just wasn't sure what you wanted to do with the values -- to return them or re-use them further on in a longer Maplet, etc. You could return individual values using an edit of the second code block above, or you could return whole columns using an edit of the first block.) For example.

restart:
with(Maplets:-Elements):

A:=Array(1..3,1..3,[[a,b,c],[d,e,f],[g,h,i]]):
T:=table(["At 150 deg"=3,"At 200 deg"=1, "At 375 deg"=2]):

f:=proc() local i;
        seq(A[i,T[Maplets:-Tools:-Get('colDDB')]],i=1..3);
       end proc:

mymaplet := Maplet([
   [DropDownBox['colDDB'](op~([indices(T)]),
                          'onchange'=Evaluate('TF'='f()'))],
   [TextField['TF']()],
   [Button("OK", Shutdown(['TF']))]
                   ]):

parse(op(Maplets:-Display(mymaplet)));

@pepper4two It could also be done without need for the extra table T. But here is a simple reworking. Hopefully it is closer, and gives you more of an idea of what you can do.

restart:
with(Maplets:-Elements):

A:=Array(1..3,1..3,[["At 200 deg","At 375 deg","At 150 deg"],[d,e,f],[g,h,i]]):
T:=table(["At 150 deg"=3,"At 200 deg"=1, "At 375 deg"=2]):

f:=proc() local L,u;
        L:=convert(A[2..,T[Maplets:-Tools:-Get('colDDB')]],'list');
        Maplets:-Tools:-Set('myDDB'('itemlist')=map(u->convert(u,'string'),L));
        L; end proc:

mymaplet := Maplet([
   ["Update this drop box of column entries... ",
    DropDownBox['myDDB'](map(u->convert(u,string),
                         convert(A[2..,op(1,rtable_dims(A)[2])],'list')))],
   ["...by selecting a column from this drop box: ",
    DropDownBox['colDDB']([seq(A[1,i],i=rtable_dims(A)[2])],
                          'onchange'=Evaluate('TF'='f()'))],
   [TextField['TF']()],
   [Button("OK", Shutdown())]
                   ]):

Maplets:-Display(mymaplet);

Have you considered not having any dynamically updated drop-boxes at all? Just have two drop-boxes, one with the temperatures and one for the materials' names. Then when you re-select from either it would update something (return value or a text field) with the corresponding value from the data grid.

restart:
with(Maplets:-Elements):

A:=Array(1..3,1..3,[[a,b,c],[d,e,f],[g,h,i]]):
TT:=table(["At 150 deg"=3,"At 200 deg"=1, "At 375 deg"=2]):
TM:=table(["material C"=1,"material A"=2,"material B"=3]):

f:=proc()
   A[TM[Maplets:-Tools:-Get('rowDDB')],TT[Maplets:-Tools:-Get('colDDB')]];
   end proc:

mymaplet := Maplet([
   ["select a temperature: ",
    DropDownBox['colDDB'](op~([indices(TT)]),
                          'onchange'=Evaluate('TF'='f()'))],
   ["select a material: ",
    DropDownBox['rowDDB'](op~([indices(TM)]),
                          'onchange'=Evaluate('TF'='f()'))],
   [TextField['TF']()],
   [Button("OK", Shutdown())]
                   ]):

Maplets:-Display(mymaplet);

Note that whatever gets assigned (above) into a Text box you could alternatively make the return value that gets inserted into the worksheet when you press the OK button. (I just wasn't sure what you wanted to do with the values -- to return them or re-use them further on in a longer Maplet, etc. You could return individual values using an edit of the second code block above, or you could return whole columns using an edit of the first block.) For example.

restart:
with(Maplets:-Elements):

A:=Array(1..3,1..3,[[a,b,c],[d,e,f],[g,h,i]]):
T:=table(["At 150 deg"=3,"At 200 deg"=1, "At 375 deg"=2]):

f:=proc() local i;
        seq(A[i,T[Maplets:-Tools:-Get('colDDB')]],i=1..3);
       end proc:

mymaplet := Maplet([
   [DropDownBox['colDDB'](op~([indices(T)]),
                          'onchange'=Evaluate('TF'='f()'))],
   [TextField['TF']()],
   [Button("OK", Shutdown(['TF']))]
                   ]):

parse(op(Maplets:-Display(mymaplet)));

The tilde is superfluous as multiplication by a scalar using * maps automatically into Matrices, Vectors, and Arrays. The OP mentioned multiplication by "one number", hence by a scalar.

So, it works with s*A[1] just as for s*~A[1], when s is not also a container object.

The suggested method hinges on indexed assignment into the Matrix (or Array), rather than on elementwise operators. See the "Modifying Elements: Assigning Subblocks" section of ?rtable_indexing

The tilde is superfluous as multiplication by a scalar using * maps automatically into Matrices, Vectors, and Arrays. The OP mentioned multiplication by "one number", hence by a scalar.

So, it works with s*A[1] just as for s*~A[1], when s is not also a container object.

The suggested method hinges on indexed assignment into the Matrix (or Array), rather than on elementwise operators. See the "Modifying Elements: Assigning Subblocks" section of ?rtable_indexing

The replacement by NULL only works if the quantity appears in a "simple" way. Otherwise, bizarre results are possible. (Of course, we don't know the class of input intended by the OP.)

> L:=[[3,sqrt(3)]]:

> eval(L,3=NULL);
                          [[  (1/2)]]
                          [[()     ]]

> map2(remove,`=`,L,3);
                           [[ (1/2)]]
                           [[3     ]]

The replacement by NULL only works if the quantity appears in a "simple" way. Otherwise, bizarre results are possible. (Of course, we don't know the class of input intended by the OP.)

> L:=[[3,sqrt(3)]]:

> eval(L,3=NULL);
                          [[  (1/2)]]
                          [[()     ]]

> map2(remove,`=`,L,3);
                           [[ (1/2)]]
                           [[3     ]]

It turns out that there are some 2D editing problems to be wary of.

Suppose that I enter these, and execute them, as two separate lines.

restart:

a:=3:

Then I place the cursor at the end of the restart line, right after the colon. And I hit the delete key just until the a:=3: line gets pulled up to appear on the same line as the restart:

Then I place the cursor right on the word restart, and hit Enter. The cursor drops down. But `a` is not assigned!

It just looks like both commands are in the same execution line. But they are not. If I walk the worksheet using Enter then `a` does not get assigned by the line that looks just like this

restart: a:=3:

(Weirdly, `a` does get assigned if I use the !!! to execute the whole worksheet.)

This is not good behaviour.

This looks to be fixed in Maple 14, when entered as 2D Math input

f:= x -> if x < 0 then a else b end if;

It's interesting; this post has over 21 responses, many not in disagreement, and no up-votes.

Is this in a Document? Using 2D Math input? If so, then could it be that you are trying something like the following? Put all of this below on a single 2D Math execution line. Place the cursor in the middle of the word "restart", and hit enter.

restart; a:=7; gc();

Then check what `a` equals. For my Maple 14 (32bit Windows XP) the name `a` does not get assigned a value of 7.

Maybe the gc() is not actually occuring for you too, in what you tried with the single input line? Maybe you are comparing different things.

Is it faster if you toggle into the raw HTML editor window (use "HTML" button in Editor menubar)? That way it would not try and display as wysiwyg.

It may be ok for jumps, but isdifferentiable doesn't do a good job for tan(x), 1/(x-3), etc.

It may be ok for jumps, but isdifferentiable doesn't do a good job for tan(x), 1/(x-3), etc.

Where is the assignment of an operator to the symbol `f` being done? Can it be made visible in that Qu.mw worksheet, using only simple GUI actions?

@Axel Vogt Maybe you can use the symbol `gsl_sf_bessel_J0` for GSL (so as to not collide with the j0 already declared in the Watcom compiler's math.h header file)?

If Maple's Compiler is trying to compile and link its own shared object, then maybe the 'library' option would have to refer to locations of stub libraries gsl.lib and gslcblas.lib (with the corresponding .dll's in your PATH so that it could then run).

So -- just guessing here: 'library'=" -L<path to GSL .libs> -lgsl -lgslcblas "

First 38 39 40 41 42 43 44 Last Page 40 of 81