acer

32405 Reputation

29 Badges

19 years, 346 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@Kitonum Until the OP responds we don't for sure whether he just wants a random sample from some Normal(a,b), or whether he wants a Matrix of random variable placeholders.

Here is one (slightly crazy) way to produce Matrix of sample values from that.

M := Matrix(2,3,(i, j)->Statistics:-RandomVariable(Normal(0,1))):

map(`?[]`,map(Statistics:-Sample,M,1),[1]);

         [-0.531692519958605  1.99932940923732   0.105259473657208]
         [                                                        ]
         [ 0.127790495266725  1.37115530221358  0.0925191256937789]

Slightly less crazy might be,

map(c->Statistics:-Sample(c,1)[1],M);

          [0.342696098518556  0.837118218825433  -1.10381342439977]
          [                                                       ]
          [ 1.39898388585646   1.87933504556442  0.477078415677388]

@nm Well, that free MaplePlayer already exists, and your proposed way of doing things is already possible (and, I agree, results in a more responsive and robust experience). And that free player also provides direct access to download directly from the Maple Cloud.

 

@erik10 Sorry to belabour it, but just to make sure:

1) You can share private access to a Maple Could group with 1 or more other people. So once that is done you no longer need to send them URLs -- each party knows where to deposit or find something new.

2) The material on the MapleCloud can be downloaded from a brower and then opened in the MaplePlayer. Or it can be accessed from the cloud and opened directly from within the Player. Or it can be accessed and opened and interacted with in a (html5 conforming) browser, without the Player. And if you login at maplecloud.maplesoft.com then you get access to your own private groups, in your browser.

The browser support for all interactive aspect of a Document (via Embedded Components) seems to be still being polished. But it seems to me that point 2) speaks to your original Question.

@lemelinm It's up to you, I'd say. If you use poundforce then you might get asked to define a slug.

1 lbf = 1 slug*ft/s^2

while,

1 pdl = 1 lb*ft/s^2

I'm not 100% sure which is used more regularly, in the USA, but I've seen indications that they might use lbf ie. pound-force. (I live in a country that uses kg and N.)

We can also make wrapper around DirectSearch:-SolveEquations which rejects spurious solutions which do not meet the residual tolerance.

Not surprisingly it can detect (depending on the specified tolerance) similar inaccurate candidate solutions that fsolve baulks (with all defaults as before).


restart:

VP := Vector[row](16, {(1) = 10, (2) = 177.9780267, (3) = 355.9560534,
                       (4) = 533.9340801, (5) = 711.9121068, (6) = 889.8901335,
                       (7) = 1067.868160, (8) = 1245.846187, (9) = 1423.824214,
                       (10) = 1601.802240, (11) = 1779.780267, (12) = 1957.758294,
                       (13) = 2135.736320, (14) = 2313.714347, (15) = 2491.692374,
                       (16) = 2669.670400}):

VE := Vector[row](16, {(1) = 5.444193931, (2) = .4793595141, (3) = .3166653569,
                       (4) = .2522053489, (5) = .2123038784, (6) = .1822258228,
                       (7) = .1544240625, (8) = .1277082078, (9) = .1055351619,
                       (10) = 0.8639065510e-1, (11) = 0.6936612570e-1,
                       (12) = 0.5388339810e-1, (13) = 0.3955702170e-1,
                       (14) = 0.2612014630e-1, (15) = 0.1338216460e-1,
                       (16) = 0.1203297900e-2}):

oldDigits,Digits := Digits,10:
forget(evalf);
for i to 15 do
  p[i] := VE[i+1] < x and x <= VE[i],
          (VP[i+1]-VP[i])*(x-VE[i])/(VE[i+1]-VE[i])+VP[i] end do:
Digits := oldDigits:
forget(evalf);

g := unapply(piecewise(seq(p[i], i = 1 .. 15)), x):

for i to 15 do
  forget(evalf);
  print(proc(j) local res;
                res:=fsolve(g(x) = VP[j]);
                if res::numeric then res else j end if;
        end proc(i));
end do;
forget(evalf);

                                 5.444193930
                                0.4793595141
                                0.3166653569
                                      4
                                0.2123038784
                                0.1822258228
                                      7
                                0.1277082078
                                      9
                                0.08639065507
                                     11
                                0.05388339812
                                0.03955702173
                                     14
                                0.01338216464

StrictSE:=proc({tols::[numeric,numeric]:=[1e-6,1e-6]} )
  local res;
  res:=DirectSearch:-SolveEquations( _rest,
                     ':-tolerances'=tols );
  if max(map(abs,res[2]))<=tols[2] then
    res;
  else
    NULL;
  end if;
end proc:

for i to 15 do
  forget(evalf);
  print(proc(j) local res;
                res:=StrictSE(g(x) = VP[j], tols=[1e-10,1e-7]);
                if res::list then eval(x,res[3]) else j end if;
        end proc(i));
end do;
forget(evalf);

                              5.44419392993762
                              0.479359514097377
                              0.316665356905805
                                      4
                              0.212303878414364
                              0.182225822810105
                                      7
                              0.127708207765792
                                      9
                             0.0863906550747353
                                     11
                             0.0538833981179015
                             0.0395570217241483
                                     14
                             0.0133821646309684

for i to 15 do
  forget(evalf);
  print(proc(j) local res;
                res:=StrictSE(g(x) = VP[j], tols=[1e-14,1e-10]);
                if res::list then eval(x,res[3]) else j end if;
        end proc(i));
end do;
forget(evalf);

                              5.44419392993762
                                      2
                              0.316665356908418
                                      4
                              0.212303878418517
                              0.182225822750651
                                      7
                              0.127708207763479
                                      9
                             0.0863906550708061
                                     11
                             0.0538833981170618
                             0.0395570217254968
                                     14
                             0.0133821646366919

 


Download DSrej.mw

@Markiyan Hirnyk The DirectSearch:-SolveEquations command accepts a tolerance option similar to that of DirectSearch:-Search.

   tolerances =[positive, positive], [positive], or positive -- Set the absolute
   tolerances for the extremum point (tolerances[1]) and minimum (or maximum) value
   (tolerances[2]). The search is stoped when the following exit conditions are met
   several times:  ||Xmin-Xold ||<=tolerances[1] and |fmin-fold |<=tolerances[2].
   The default value is [10^(-6), 10^(-6)]. If tolerances contains one value
   this value corresponds to both the extremum point and minimum (or maximum) value.

Note that the help-page for DirectSearch:-SolveEquations also says, as a last Note before its Examples, "...If the residuals too large then the solution is not exact solution but it is only solution that minimizes the residuals."

That last sentence is the key. It surely means that SolveEquations is going to return a result even if it does not meet the criteria of being a root. And that is just what it does. Let's call DirectSearch:-SolveEquations and specify tolerances.

DirectSearch:-SolveEquations( g(x)=VP[14], tolerances=[1e-10,1e-10] );

    [                   -16  [                    -8]                               ]
    [2.24381757423686 10   , [-1.49793777382001 10  ], [x = 0.0261201463011024], 40 ]

The middle value -1.49793777382001e-8 is documented on that help-page as meaning the residual. (The first value in the returned result is just the square of that, because, as documented, the objective used is f[1](x)^2 by default.) So the returned result does not meet the second passed tolerence value which specifies the acceptance target for the residual.

So in the sense that DirectSearch:-SolveEquations considers the matter, the returned value is not a (exact, its word) root. But the result is returned anyway, as per that cited Note.

It's not returning what it considers to be a root. It's returning a value that minimizes the sum of the squares of the residuals. The absolute value of the residual (what I call the forward error) exceeds the tolerance supplied for the residuals, so it is not deemed to be an actual root.

@erik10 I am submitting a bug report that there are no cross-references in the help-pages plots,polyhedraplot and plots,polyhedra_supported to the help-page geom3d,polyhedra .

Alternatively, you could pay closer attention to what Kitonum wrote [implying under Digits=10 or higher, and correct at the default Digits=10 of your sheet], "Because  x= 0.02612014634  does not belong to  0.01338216460 < x and x <= 0.02612014630."

Note that increasing working precision to higher than Digits=10 will not make 0.02612014634 <= 0.02612014630, although lowering it will.

restart:
Digits := 10:
evalb( 0.02612014634 <= 0.02612014630 );
                                    false

restart:
Digits := 20:
evalb( 0.02612014634 <= 0.02612014630 );
                                    false

restart:
Digits := 9:
evalb( 0.02612014634 <= 0.02612014630 );
                                    true

@Markiyan Hirnyk The expression p[14][2] is not the part of the piecewise that matters when x=0.02612014634, when Digits=10.

When you call g(0.02612014634) the piecewise takes p[13][2] as the formula that gets computed, if g has been created with Digits=10 and if that is still the current working precision.



restart:

VP := Vector[row](16, {(1) = 10, (2) = 177.9780267, (3) = 355.9560534,
                       (4) = 533.9340801, (5) = 711.9121068, (6) = 889.8901335,
                       (7) = 1067.868160, (8) = 1245.846187, (9) = 1423.824214,
                       (10) = 1601.802240, (11) = 1779.780267, (12) = 1957.758294,
                       (13) = 2135.736320, (14) = 2313.714347, (15) = 2491.692374,
                       (16) = 2669.670400}):

VE := Vector[row](16, {(1) = 5.444193931, (2) = .4793595141, (3) = .3166653569,
                       (4) = .2522053489, (5) = .2123038784, (6) = .1822258228,
                       (7) = .1544240625, (8) = .1277082078, (9) = .1055351619,
                       (10) = 0.8639065510e-1, (11) = 0.6936612570e-1,
                       (12) = 0.5388339810e-1, (13) = 0.3955702170e-1,
                       (14) = 0.2612014630e-1, (15) = 0.1338216460e-1,
                       (16) = 0.1203297900e-2}):

oldDigits,Digits := Digits,10:
forget(evalf);
for i to 15 do
  p[i] := VE[i+1] < x and x <= VE[i],
          subs(x=xx,(VP[i+1]-VP[i])*(x-VE[i])/(VE[i+1]-VE[i])+VP[i]) end do:
Digits := oldDigits:
forget(evalf);

g := unapply(piecewise(seq(p[i], i = 1 .. 15)), x):

g(0.02612014634);

                        -13245.49210 xx + 2659.688538

p[14][2];

                        -13972.23133 xx + 2678.671074

p[13][2];

                        -13245.49210 xx + 2659.688538

forget(evalf):
trace(g):
oldDigits,Digits:=Digits,9;
g(0.02612014634);
untrace(g):
forget(evalf);
Digits:=oldDigits;

                         oldDigits, Digits := 10, 9

{--> enter g, args = 0.2612014634e-1

                        -13972.23133 xx + 2678.671074

<-- exit g (now at top level) = -13972.23133*xx+2678.671074}

                        -13972.23133 xx + 2678.671074
                                Digits := 10

forget(evalf):
trace(g):
oldDigits,Digits:=Digits,10;
g(0.02612014634);
untrace(g):
forget(evalf);
Digits:=oldDigits;

                         oldDigits, Digits := 10, 10

{--> enter g, args = 0.2612014634e-1

                        -13245.49210 xx + 2659.688538

<-- exit g (now at top level) = -13245.49210*xx+2659.688538}

                        -13245.49210 xx + 2659.688538
                                Digits := 10

 



Download fsolvexx.mw

@madagascar Please upload your actual worksheet (big green arrow in the editor here) in a new Comment to your Question.

Right now your post consists on just images of statements, and few if any people would want to retype that all by hand.

You'll need to make that lowercase display instead of Display.

Maple is a case-sensitive language.

acer

@Preben Alsholm Nice work.

I'd noticed that there was nothing `local`, for convert/global to change, even when it caused an example to work. I'd formed a few odd &under procedures which made the examples work (even though they ought not have affected anything). And this had made me consider that something wrong was happening inside `indets`.

Your `cg4` make a strong case for the internal state being in a mess, inside indets.

Has anyone submitted the bug report?

 

@Melvin Brown Having your module inside a .mla archive will not, in and of itself, prevent its contents from being inspected.

@Melvin Brown I suggest that you read my earlier suggestion more carefully. I had suggested that you put the source code which defines the module into the Startup Code Region. I didn't suggest augmenting libname in a effort to try and pick up the module from a .mla archive.

The MaplePlayer has its own security settings, which different from those of Maple (including the Std GUI interface) by default, and are quite tight.

It might be possible to use a custom .mla archive with the MaplePlayer 2015, but why even bother? If you burn the module source into the "App" .mw file then you only have one file to distribute to your end-user.

Why not put the source code that defines the module in the Startup Code Region of the Worksheet or Document that you intend to become an interactive application that can run in either Maple or the MaplePlayer?

See this Answer to a recent question about authoring so-called MathApps.

We haven't been told what kind of inputs your module might have, Marvin. But if the commands it provides can be run using the Explore [1, 2, 3] command to obtain an interactive application that you deem suitable then you could have a look at this or this. So another idea is that you can build some kinds of simple interactive applications that have just one kind of output (math expression, or plot, or image), in standalone worksheets, without having to first learn all the ins and outs of programming with Embedded Components. Of course you can build it all from scratch yourself, using Embedded Components, but in that case you might find the StartUp Code Region to be useful.

acer

First 327 328 329 330 331 332 333 Last Page 329 of 593