acer

32353 Reputation

29 Badges

19 years, 331 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

The GUI will run out of memory or blow the java heap before it can display all of your 200,000 plots.

But this looks like 2D Math input, inside a paragraph in a Document (as opposed to being in an execution group or a Worksheet, say). If that's right then you won't see any results displayed for that as a collapsed Document Block, from either print or printf, until the entire outer loop completes. And then it'll try to render them all, in one shot.

How many of these do you really want to be able to view at any one time? One? Ten? I suggest you figure that out and then we could suggest other methodologies such as using Embedded Components, smaller sequence of plots as displayed as animation(s), using Explore, etc.

acer

@jbuddenh Sorry, I meant to say Shift-Enter, not Ctl-Enter. I'm in a Friday afternoon fog.

@taro No his original problem was with creation of an operator, to pick up the right instance of x. And as you too showed unapply provides the desired functionality for that aspect.

Assignment to f(x) is not key to resolving this, and is an unnecessary complication that muddies the issues. It also gets in the way of `f` also being made an operator.

restart;                                                                       

sol:=dsolve({f(0) = 12, diff(f(x), x) = 2*x+6});                               
                                                               2
                                                sol := f(x) = x  + 6 x + 12

rhs(sol);  # reasonable                                                        
                                                        2
                                                       x  + 6 x + 12

eval(f(x), sol); # reasonable                                                  
                                                        2
                                                       x  + 6 x + 12

assign(sol): f(x); # unreasonably unnecessary assignment to remember table of f
                                                        2
                                                       x  + 6 x + 12

@Doug Meade In the 64bit Linux version of each of Maple 17.00, 2015.2, and 2016.0 I am seeing,

seq( int( abs( cos(n*x) ), x=0..Pi ), n=1..24 );

                2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2

Nasser Abbasi's website contains his 3rd party runs of suites of examples of symbolic integration and symbolic differential equation solving, and may be of general interest to members of this community.

He has assembled results and compared performance of various recent versions of Maple and Mathematica, including timing and memory use as well as general pass-fail results. Source code is provided for the various problems.

For differential equations I find Nasser's results interesting in several respects. One such aspect is that he provides at least two full two comparison sets, one with Maple 18.02 and Mathematica 10.0.2, and another with Maple 2015.2 and Mathematica 10.3.1. Another is that he provides both mean and total computation times and leaf-counts (size). And another aspect I find useful is that he provides individual problem results, as well as source code. The 1940 different examples are taken from Kamke's book, Differential Gleichungen, 3rd ed., and the tables and examples listed on Nasser's site make it clear that this is a significantly broad collection of problems in multiple classes. I find it remarkable that not only does Maple outperform Mathematica on the pass-fail success rate (92% vs 76%) and compactness (size) of results but Maple is reported as doing it much faster on average with a mean CPU time of 0.5 sec for Maple 2015.2 vs 28.3 sec for Mathematica 10.3.1.

For integration Nasser has used several collections of problems. One the one hand his results comparing Maple 2015.1 and Mathematica 10.1 show only pass-fail numbers rather than the optimal/non-optimal/fail numbers that Albert Rich has shown (for older versions). But here too Nasser has assembled mean and total values for both computation time and leaf-count (size). According to these sites Maple's combine optimal/non-optimal pass rate has increased slightly from 85.1% in Maple 18 (A.Rich) to a total pass rate of 88.3% in Maple 2015.2 (Nasser). The Mathematica total pass rate was reported by both at approximately 97%. The average size of the Maple results (Nasser) is much larger than those of Mathematica, while Maple computes them much faster. This all indicates to me that Maple can afford to use some additonal computation time to work harder (change-of-variables attempts, say) to find solutions as well as to simplify results (w.r.t size, at if not via combine).

Nasser recently wrote that he would try to find time to repeat these comparisons using Maple 2016. Full results using Mathematica 10.4.x would be interesting.

acer

@PsiSquared You only need a single call to randomize(), outside of the loop, after restart.

If you call dice() multiple times (I did it twice) you will get different random runs in the same session (with no restart). This will happen regardless of whether you call randomize(), so there is no need for it inside the procedure dice.

The purpose of the randomize() call is to change the initial random seed. The effect is that after restart the sequence of random runs differ from the full session before.

You can see the effect by commenting out the call to randomize() and then restarting and re-executing the whole sheet (using the menubar's !!! icon, say). Without the call to randomize() then the whole sequence of runs will be the same from session to session, though they differ individually amongst themselves.

I don't understand you comment about obtaining count+xxxx as returned result, as long as you have the earlier line inside dice to initialize count to 0. See the following:


restart;

randomize():

r := rand(1..2):

r(), r(), r(), r(), r();

2, 1, 1, 2, 2

dice:=proc()

local count, i, roll;

  count:=0:

  for i from 1 to 10000 do

    roll:=r();

    if (roll=1) then count:=count+1 end if;

  end do;

  return count;  

end proc:

dice();

5077

dice();

4992

kernelopts(version);

`Maple 11.02, IBM INTEL NT, Nov 9 2007 Build ID 330022`

 


Download randloop11.mw

@Mac Dude I was asking whether you are seeing the buggy behaviour which you reported against Maple 2015 as being fixed in Maple 2016 (if you have it).

I am seeing the following in Maple 2016.0.

Mac Dude, is it ok for you in Maple 2016.0 on your OS X?

restart;
UseHardwareFloats:=true:
fr = 1.64*10^6*E[k]^2*exp(-8.5/E[k]):
solve(fr = 1.64*10^6*E[k]^2*exp(-8.5/E[k]),E[k]);

                     4.250000000             4.250000000     
               -----------------------, ---------------------
                       /  5442.655602\          /5442.655602\
               LambertW|- -----------|  LambertW|-----------|
                       |      (1/2)  |          |    (1/2)  |
                       \    fr       /          \  fr       /

restart:
UseHardwareFloats:=true:
evalf(LambertW(3));

                             1.04990889496403983

restart;
UseHardwareFloats:=true:
evalf( BesselY(0, 2/3*x) );

                         BesselY(0., 0.6666666667 x)

kernelopts(version);
          Maple 2016.0, X86 64 LINUX, Feb 16 2016, Build ID 1113130

 

acer

@Kitonum If I may, I'll add another example if only to illustrate that it can be tricky (esp. for the new user) to come up with a satisfactory test to use if only sieving (all) results with select, say.

solve( x^3+3*x^2-1, useassumptions ) assuming real, positive;

                                                  1/2 1/3
                                        (-4 + 4 I 3   )              2
                                        ------------------ + ------------------ - 1
                                                2                       1/2 1/3
                                                             (-4 + 4 I 3   )

That result seems ok. Which is why this approach is useful to know about.

Establising that solution as being purely real (exactly) may be a challenge for some users. So for some examples it can be a challenge to find a strong enough predicate to use with select or selectremove. if trying to extract the purely real  and positive solutions from just this:

S:=solve( x^3+3*x^2-1 );

By "challenge" I mean that one can go astray.

restart:
K:=solve( x^3+3*x^2-1, useassumptions ) assuming real, positive:

simplify(combine(rationalize(K))): is(%,real);

                                                           false

simplify(convert(simplify(combine(rationalize(K))),expln)): is(%,real);

                                                            true

simplify(evalc(evala(simplify(convert(simplify(combine(rationalize(K))),expln)))));

                                               2 Pi             Pi         4 Pi
                                           cos(----) - 1 + cos(----) - cos(----)
                                                9               9           9

kernelopts(version);

                                 Maple 2015.2, X86 64 LINUX, Dec 20 2015, Build ID 1097895

# Sure we might happen to obtain the following, more simply. What's key is that
# it *could* be harder. And we can go wrong. And Maple can go wrong.

simplify(evalc(K));

                                                            2 Pi
                                                      2 cos(----) - 1
                                                             9

Note: Maple 2016.0 might return FAIL instead of those `false` and `true` results. But the key thing to keep in mind is that we can always construct even more difficult and challenging examples.

We know that there is an inherent risk when using floating-point approximations as part of the sieving selection, due to round-off error and the possibility of misinterpreting small imaginary components (as either being mere artefact, or not).

For any stated approach we could find examples that present difficulties. So it is useful to be aware of the methods suggest by both Kitonum and Doug.

@Majmaj Apart from not handling distribution across sums, the rough prototype overload I showed would also need special handling to map over rtables (Vector,Matrix, Array) and other data-structures.

If you want exact handling of floats then perhaps you'd be better off using the convert command to first turn the floats into exact rationals. That might be done up front, on initial expressions containing subexpressions of type float, via the subsindets command. Just an idea.

@Honigmelone You may use applyrule across the elements of a Vector (or Matrix or Array) with the map2 command.

So, as an alternative to converting to and from list, and using your code above,

map2(applyrule,[rule,rule2],f_symbol);

What would you hope to see as the results for the following examples?

a:=.123456789:

1.0 * a;
1.00 * a;

0.10 * a;
0.100 * a;

acer

In such a numeric computation environment as you are envisioning what result would be produced for the calculation of 0.1 * 1/3 ? Note that the second multiplicand is the exact rational one-third.

How many decimal digits would you hope to see in the floating-point result of that, if it were not to simply use the current Digits value? To what would it dynamically adjust the working precision?

acer

@Markiyan Hirnyk 

1) It is nicer to get just the last result from those you obtained from solve. Your taking the last of the multiple solutions you obtained is very much only done "by hand". It is neater to add the n>0 assumption and get just the single, desired result.

2) actually what I showed works with the `abs` as well.

solve( {abs(1 - n^2/(n^2+31*n+228)) < eps}, n, useassumptions )
  assuming eps>0, eps<1, n>0;

                                               2                  1/2
                         -31 eps + 31 + (49 eps  - 1010 eps + 961)
                        {-------------------------------------------- < n}
                                            2 eps

 

@Markiyan Hirnyk  Perhaps that approach can work out, if modified somewhat. We can get rid of the `abs` since n^2/(n^2+31*n+228) is approaching 1 from below.

restart;

sol := solve( {1 - n^2/(n^2+31*n+228) < eps}, n, useassumptions )
         assuming eps>0, eps<1, n>0;

                                                      2                  1/2
                                -31 eps + 31 + (49 eps  - 1010 eps + 961)
                        sol := {-------------------------------------------- < n}
                                                   2 eps

eval(sol, eps=9*10.0^(-2));

                                            {320.6343580 < n}

eval( abs(1 - n^2/(n^2+31*n+228)), n=320.0);

                                              0.0901659736

eval( abs(1 - n^2/(n^2+31*n+228)), n=321.0);

                                               0.0899046105

[edit] I saw your followup only after I submitted this. I've given a looser restriction on positive epsilon, and the additional assumption n>0 gets only the single result from `solve` (ie. the one we want).

First 308 309 310 311 312 313 314 Last Page 310 of 592