1429 Reputation

18 Badges

14 years, 62 days

Social Networks and Content at

Maple Application Center
I am the manager of the Mathematical Software Group, working mostly on the Maple library. I have been working at Maplesoft since 2007, mostly on the Statistics and Units packages and on contract work with industry users. My background is in abstract algebra, in which I completed a PhD at Eindhoven University of Technology. During my studies I was always searching for interesting questions at the crossroads of math and computer science. When I came to Canada in 2007, I had nothing but a work permit, some contacts at Maplesoft (whom I had met at a computer algebra conference a year earlier), and a plan to travel around beautiful Canada for a few months. Since Maplesoft is a company that solves more interesting math and computer science related questions than just about anywhere else, I was quite eager to join them, and after about three months, I could start.

MaplePrimes Activity

These are replies submitted by epostma

@Carl Love @Angelo Melino  Thank you for finding this! I just submitted a fix for the main development version of Maple; it should make it into the next major version (which might be released next spring).

Erik Postma
Manager, mathematical software group

@Anthrazit The 'eval' should be done when reading from the data table; when you write it, the unit expressions will hopefully be valid -- otherwise you would get errors at that point, anyway, whenever you do anything with them -- so then the eval is not necessary.

@vv Thank you for this request for high performance, high precision evaluation of the Zeta function. That'll help us prioritize where we focus our efforts. If we hear this from more people, that would be a strong indicator to help redirect effort to this project.

Erik Postma
Manager, mathematical software group.

@Axel Vogt - one doesn't, in this case. It was me who suggested this to the support team, and I thought the `in` operator was defined in the PolynomialIdeals[Operator] subpackage, but it's actually in the PolynomialIdeals package itself.

Yes, that works for the Bootstrap command, thanks for pointing that out!

The focus of the user's question was on generating samples, so I answered that question initially. I believe they wanted to roll their own bootstrap-like mechanism. For just generating (large) samples, EmpiricalDistribution works well enough, and efficiently.

I figured I could show that you can use Maple's Bootstrap command, too, and because I had already constructed the EmpiricalDistribution object, that's where my mind went, and I didn't think about the fact that Bootstrap accepts the plain data sample, too.

By the way -- I think we can probably speed Bootstrap up a lot by having it sample into a larger buffer. It currently just uses the sample size for the buffer, so it fills a size-4 buffer 10000 times. It would be much more efficient to fill a size-10000 buffer 4 times, and then slice it into 2500 samples with ArrayTools:-Alias. I expect you would get performance very close to the calling sequence  you show in that case.

Thanks Robert, I enjoyed reading this account.

Two notes, one mathematical and one Maple-related. First the mathematical one: I think you would expect 3 degrees of freedom, right? There are 10 equations, but there is a dependency between them: all four row-sums must needs sum to the same as all four column-sums. So there are really only 9 independent equations.

The Maple point is that the combinatorial question you raise is solved by the Iterator package, in particular the BoundedComposition command. You supply it with a k-tuple of bounds (b1, ..., bk), and a sum s, all nonnegative integers. It then finds all k-tuples (a1, ..., ak) of nonnegative integers with ai <= bi that sum to s. This raises one problem: we want integers from 1-9, and  BoundedComposition will also give us zeroes -- but that's easily dealt with: we just use integers from 0-8 instead, adjust the requested sum (by subtracting k=4), and presto. For example:

k := 4;
B := BoundedComposition([8 $ k], 25-k):
Number(B); # result: 324
Print(B, 'showrank');

tells us that there are 324 such tuples with sum 25, and will print all of them. To do a computation with them, you would use:

for b in BoundedComposition([8 $ k], 25 - k) do
  tup := b +~ 1;
  # Now use the tuple, tup, which will contain suitable integers 1-9. (It's an Array.)
end do;

Of course, if one number is given already, you could generate 3-tuples.

@C_R If this is what you want, the best option is probably to use convert/system to convert every unit to one consistent system, and then use Carl's solution below:

expr := sin(t * Unit(1/min)) * Unit(mm);
to_SI := evalindets(expr, specfunc(Units:-Unit), e -> convert(e, 'system', 'SI'));
result := eval(to_SI, Units:-Unit = 1);
# result is now sin(t/60) / 1000

@C_R For what it's worth, here is another teaser screenshot...

Hi everyone,

I think Tom and Carl have already answered the actual question, so I won't add an answer... but I will add a little teaser image of what the current in-development version of Maple looks like when applied to this worksheet:

If everything goes as expected, you can expect this to work without any tinkering being necessary, in the next major release of Maple.

@mike7944 You're welcome!

Hi Mike,

I should have mentioned explicitly - this was written to work in Maple 2021. Over the last couple of years we've made some additions to the Maple syntax. One of them is allowing full if statements (including arbitrary substatements) inside expressions; it looks like that's what you're running into. If you need to use this code in an older version, you can replace this fragment:

 local result := add(nonconst) + (
    if is(const = 0) then
      const := evalf(const);
      if type(const, ':-float') then
        frem(const, 2.*Pi);
        frem(Re(const), 2.*Pi) + I*Im(const);
      end if;
    end if);

with the following:

 local result := add(nonconst);
    if is(const <> 0) then
      const := evalf(const);
      if type(const, ':-float') then
        result := result + frem(const, 2.*Pi);
        result := result + frem(Re(const), 2.*Pi) + I*Im(const);
      end if;
    end if;

You may also need to move all local declarations to the top of the procedure and module; for example, the module would start with a line saying local ModuleApply, process_trig; and the word local would be removed from the lines assigning to ModuleApply and process_trig.

Please let me know if you're still having trouble -- I don't have Maple 2017 handy so I can't easily check right now, but I'll dig it out if needed.

@Carl Love Yeah, the change should be in 2020.0 and later.


@vs140580 Another option would be to use the command Iterator:-CartesianProduct. If you want to deal with the results one by one, you can use it like this:

m := 4; # or more
S := {0, 1, 2}; # or something else
for v in Iterator:-CartesianProduct(S $ m) do
  print(v); # v will be an Array with one result
end do;

Note that the Array in v will be reused between iterations; only its contents will change.

@Carl Love Thanks again, Carl, for all your time on this.


One more thing that I meant to add: I also looked up who introduced this bug. As is so often the case with these sorts of things, I found it was introduced in a change made more than a few years ago that rewrote some working code unnecessarily... submitted by one Erik Postma :(

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