3728 Reputation

17 Badges

6 years, 67 days

MaplePrimes Activity

These are replies submitted by mmcdara


You opened my eyes.
I don't know where my head was when I see the stupidity of what I wrote.



Thanks, effectively 


As a rule I use 10.0^(-Digits), but I sometimes get screwed by writing 1e-(Digits) bu distraction


Yes, I know that, but I'm interesting to know why 1e-Digits doesn't do the job

@Joe Riel 

Thanks Joe.

I agree that "selection" is a more adequate word than "extraction" in Maple's world..
Why did I use the this latter then? Probably because it seemed more natural to me, at least in everiday language.
See here search to see I'm not the only one to use such a word in the same context.

Eventually, you interpreted my confusing question correctly, so let me ask you a favor: how would you have formulated it so that no one here might misinterpret it?

About "extraction":

the use of this term seems consistent with Merriam Webster' dictionnary, see here extracting  definition 1.a (also def. 4 and def. 5 wich introduces "select" as a synonym.


"Why post this followup query...
Mainly, I don't know how to "add a question to a previous one "
Moreover it seemed likely that if I had gone here to complete my original question with this new one I would have had little chance of getting an answer. Unless the people involved in a thread have explicitly said that they want to be notified by any evolution of the thread a contribution beyond 2 or  3 dys has little chance, if any, to be read.

"So which do you want here"
If expr = T1 +... + Tnis my original expression, I want to

  1. display the terms of a given form (let's call them Ti and Tj),
  2. check visually if there are correct,
  3. if not replace them by other terms Si and Sj,
    that is write expr := expr - Ti - Tj + Si +Sj.
    A sort of subsop in fact

The problem is that the potentially suspect terms do not always correspond to the same operator numbers. Thus using subsop is not a good idea.
More of this the visual checking of the whole expression is difficult (which can be even more complicated than the one I gave); thus my need of something to "extract" (even if this term seems ambiguous to you) these potentially suspect terms.

If you want to know more about this:

A few years ago we developed a Maple code to simulate the behavior of micro-mechanical systems.
This code is still evolving and on the occasion of one of them
a coding error has been detected in a differential equation.
We must therefore replay the simulations of the systems potentially concerned by this error. 
Unfortunately, the code was not versioned from the beginning and the traceability is therefore only partial.
Fortunately, the system of equations that is solved is saved in an m-file, which means that one can read it, isolate the potentially incorrect equation and (the point of my question) check if it contains incorrect terms.


Thank you Tom.
I like your second way, with type definitions


Maple : 226219-A-Sphere-Is-Inscribed-In-A-Tetrahedron 
Mathematica insphere-for-irregular-tetrahedron

There is always a sphere inscribed in an arbitrary tetrahedron (an "insphere"), which means there exists at least one "inellipsoid" .
If you have find an inellipsoid which is not a sphere, this means there are at least 2 inellipsoids in yout tetrahedron.

Is it always true that for any tetrahedron there is more than a single inellipsoid?
My guess is yes, from the fact there are an infinity of ellipses inscribed in a triangle (the one with maximum area is the Steiner's ellipse).

I guess uou should find therotical results about this on the web


Thanks, these are very interesting counterexamples.
For the last one: a remedy  and a few strange results

f := Heaviside(1-x^2-y^2):
int(f, [x=-1..1, y=-1..1])

g := simplify(Heaviside(1-x^2-y^2));
add(map(u -> int(u, [x=-1..1, y=-1..1]), [op(g)]))

add(map(u -> int(u, [x=-a..a, y=-a..a]), [op(g)])) assuming a > 0;
eval(%, a=1);
a := 2:
add(map(u -> int(u, [x=-a..a, y=-a..a]), [op(g)])) assuming a > 0; 
                               -8  ????

@Joe Riel 

Of course!
The piece of code I wrote in the code snippet region was just notional and wasn't the result of a copy-paste of something from a true real worksheet.
Which is no excuse for not being more careful.

@Carl Love 



I had completely forgotten that eval could contain the evaluation level

@Joe Riel 

Thanks, but the difference remains subtle and I'm not sure I caught it.
Basically my purpose is input simplification, for instance in something like that

macro(ST = StringTools):
ST:-Trim( ST:-Split( ST:-Split(..., "/")[1], ".")[-1])

or even, if I correctly understand what you said, only StringTools:-StringSplit is loaded when I write macro(STS = StringTools:-StringSplit)

macro(STS = StringTools:-StringSplit):
macro(STT = StringTools:-Trim):
STT( STS( STSt(..., "/")[1], ".")[-1])

So I will take your advice and use preferentially macro

PS : another concern: I sometime face conflicting situations where I load 2 packages and use a procedure whose name exists in both; tipically convexhull belongs simplex and geometry.
This is a reason why I have to mention explicitely what package convexhull comes from, so the short form:

macro(GM = geometry):
macro(SX = simplex):



I didn't say that my scenario could represent the OP's case. 
Also, it was the OP who mentioned the "point probe", not me, which means he may have an interest in using it.
Forget it


You're one hundred percent right if S is the power set of { {}, a1, ..., an } , and also probaly right if nops(S) is large enough.

I even feel that your guess could reduce to nops(S) > n given the "the generators (are) to be mutually disjoint" requirement  that @Christian Wolinski just came to indicate.

Reverse problem:
Let G(N) = {an, n=1..N} the set of generators, PG(N) the power set of G(N) (empty set discarded) and S(N, K) a subset of cardinal K of elements of PG(N).
Let T(N, K) the set of all pairwise intersections of elements of S(N, K).
Let T(N, K) the set of all T(N, K) obtained for all the combinat:-numbcomb(2^N-1, K) different sets S(N,K).
Question : What how sets in T(N, K) contain the set {{}, {a1}, ..., {aN}} ?

This number is the an inferior bound if the number of times your hypothesis is verified.
As I use Maple 2015 I can't use the Iterator package to do an exhaustive computation, so I did the things statistically (I had in mind to do this for higher values of N and I used this strategy in the example below even if it is stupid).

G  := N -> {seq(a__||n, n=1..N)}:
PG := N -> combinat:-powerset(G(N)) minus {{}}:
S  := (N, K) -> { combinat:-randperm(PG(N))[1..K][] }:
n     := 3: 
k     := 5:
count := table([]):
for rep from 1 to 10^4 do
  s := S(n, k);
  T := {}:
  for n1 from 1 to nops(s) do
    for n2 from n1+1 to nops(s) do
        T := T union {`intersect`(s[n1], s[n2])}
    end do:
  end do:
  nt := nops~([T[]]);
  if member(nt, {indices(count, nolist)}) then
    count[%] := count[%] +1:
    count[%] := 1:
  end if:
end do:

for i in {indices(count, nolist)} do
  printf(cat("%", 6*n+3, "a : %d\n"), i, count[i])
end do:
         [0, 1, 1, 1] : 2862
      [0, 1, 1, 1, 2] : 1434
      [0, 1, 1, 2, 2] : 2828
   [0, 1, 1, 1, 2, 2] : 1423
[0, 1, 1, 1, 2, 2, 2] : 1453

add(map(u -> if ListTools:-Occurrences(1, u)=n then count[u] end if, [indices(count, nolist)]))

Your hypothesis is verified at least 7172 times (plus probably some more time for some [0, 1, 1, 2, 2] configurations can be generated by {{}, {a1}, ..., {aN}}  (Christian Wolinski's problem).

Here are a few other results (P is the inferior bound for the the number of times your hypothesis is verified)

n   k   P
5,  6, 383;
5,  6, 1001;
5,  8, 2285;
5,  9, 3636;
5, 10, 5111;

n   k   P
6,  7, 191;
6,  8, 563;
6,  9, 1108;
6, 10, 1987;
6, 11, 2885;
6, 12, 3937;
6, 13, 4966

Inference: there is at least 50% of chances that a "good candidate" (as you said) is {{}, {a1}, ..., {aN}}  as soon as K > 2*N
(or nops(S) > n with your notations)

Introducing the procedure that Christian Wolinski just delivered;


#Christian Wolinski's procedure
F := proc ()
local S, E, L, Lexc, Linc, i, s;
E, S := selectremove(type, {args}, identical({}));
L := [op](S);
S := NULL;
for i to nops(L) do
   Linc, Lexc := selectremove(member, L[i], `union`(S));
   if Linc = {} then S := S, Lexc
      else S := seq(
         proc ()
            local X;
            X := [`intersect`, `minus`](s, Linc);
            if X[1] = {} then E := {{}} end if;
            op(remove(type, X, identical({})))
         end proc(),
         s = [S]), `if`(Lexc <> {}, Lexc, NULL)
   end if
end do;
end proc:

G  := N -> {$1..N}:
PG := N -> combinat:-powerset(G(N)) minus {{}}:
S  := (N, K) -> { combinat:-randperm(PG(N))[1..K][] }:

HypothesisVerified := proc(n, k, REP)
  local count, rep, s, T, nt:
  count := table([]):
  for rep from 1 to REP do
    s  := S(n, k);
    T  := F(op(s));
    nt := nops~([T[]]);
    if member(nt, {indices(count, nolist)}) then
      count[%] := count[%] +1:
      count[%] := 1:
    end if:
  end do:
  add(map(u -> if ListTools:-Occurrences(1, u)=n then count[u] end if, [indices(count, nolist)]))
end proc:
HypothesisVerified(6, 8, 10^4);
HypothesisVerified(8, 10, 10^4);
HypothesisVerified(15, 16, 10^4);

A statistical hypothesis:
Given S(N,K) randomly choosen, the probability that {{}, {a1}, ..., {aN}} is a good candidate for F(S(N, K)) goes to 1 when n -> +oo and K/N -> 1+.


I'm curious: How long did it take to calculate the solution?
(I did a few attempts to eliminate some unknowns but none of them were able to satisfy my impatience)

First 13 14 15 16 17 18 19 Last Page 15 of 86