8 years, 71 days

## Why should Maple do this?...

Why not converting in seconds or days?
It seems quite natural to me for Maple to wait for your choice before making the corresponding conversion, doesn't it?

Suppose you were handling yards, feet and inches: would you have asked why Maple doesn't automatically convert to inches, or feet?

## @acer I'm going to do all these...

I'm going to do all these tests and see what is best for me.
Thanks again.

## @acer Your first solution based on ...

Your first solution based on evalhf and @dharr's idea is indeed a great improvement of what I did.

Concerning the use of Compile the result seems biased because the generation of the compile code is very lengthy:

```
t0 := time[real]():
cpattern:=Compiler:-Compile(pattern, 'inmem'=false):
time[real]()-t0;

t0 := time[real]():
cpattern(N,nC,M8,C4,P4):
time[real]()-t0;
5.912
0.009
```

Nevertheless, as I said in my initial question and detailed in my last reply to @dharr, I need do to this kind of "counting" for a large number of values of C and P. So the compilation time should indeed become marginal at last.

## @dharr Good idea! I thought ab...

@dharr

Good idea!

I thought about using some "embedded property" for instance:

• Let C and C' two sets of columns such that C is strictly included in C'.

• Let P a list of length |C| of  zeros and ones and P' a "completion" of P obtained by adding "in place" zeros or ones, for instance
```C  = [1, 3]
P  = [0, 1]
C' = [1, 2, 3, 5]
P' = [0, 1, 1, 1]```
• Let  M(P) is the submatrix of M whose columns C match the pattern P, then the submatrix M(P') of M whose columns C' match the pattern P', is a submatrix of M(P).
With L=5 and M built as I said in my initial question, M(P) has about N/4 rows and thus the search of the columns C' which match the pattern P', ia about 4 times faster when done with M(P).

In some sense it is the Reverse_Idea.mw of yours

By the way, in case you would wonder where this problem comes from, here is little explanation.
The true problemis that one; I have  L detectors, each sending a signal ("1") when some event occurs (each detector is assigned to record a particular event).
For any event Ei=1..L its probability of occurrence pi is constant over the whole record time.
Then the record history of detector Di can be modelled by a (stationary) Bernoulli random process with parameter pi.
One question is: are the events Ei=1..L mutually independent or not?

Generally one uses a restricted notion of independence named pairwise independence.
Let X, Y, Z three random variables: saying that they are pairwise independent means that X and Y are independent, X and Z are independent and Y and Z are independent.

Mutual independence is a stronger constraint: it states that any subset C of the proper powerset Q of {X, Y, Z} is independent of any other subset C' of P if C and C' are disjoint.
Obviously mutual independece implies pairwise independence while the reciprocal is generally false.

The independence of C and C' means that Prob(C = P | C' = P') = Prob(C = P) where P and P' are any of all the possible outcomes of C and C' respectively.
As I deal with Bernoulli random variables, such outcomes are sequences of 0 and 1. For instance, if C refers to detectors 2 and 3, P is one of {[0, 0], [0, 1], [1, 0],[1, 1]}. The same way, if C' refers to, lets say K detectors (detectors 2 and 3 excluded), there exists 2K possible outcomes for P'.
Checking for the independence of C and C' then means assessing if the 2K+2 conditions Prob(C = P | C' = P') = Prob(C = P) can be reasonnably accepted.

The number of conditions to check in order to assess the mutual independence is equal to 232 for L=4 detectors, and to 1320 for L=5 detectors. This explains why one usually check pairwise independence (L*(L-1)/2 conditions to check).

@C_R

## Sorry,...

@C_R

I had started to write a reply before you published yours, but I posted it after yours.
Sorry for the inconvenience and feel free to delete mine.

## @dharr  It's a good way to rea...

@dharr

It's a good way to react. I should follow your advice.

## Why...

do you systematically refuse to upload your worksheet while using the big green arrow?

## @JAMET No, I still don't unders...

No, I still don't understand but you don't help me while not giving substantial informations.
Has this something to do with what is persented here ?

I still wonder what your last reply has to do with your original question

Nevertheless there is a piece of code which does three things:

1. Build a Pythagorean Triple (PT) by applying a random composition of the three matrices given in the above reference to the primitive PT < 3, 4, 5>.

2. Build the the ternary tree of depth N of all PTs constructed from  < 3, 4, 5> by applying at most (N-1) of these three same matrices.

3. Find what matrices were applied to get a known pythagorean triple.

PTs.mw

PS: as I use Maple 2015.2 the graphic is quite poor but more recent Maple's version will enable you to do more beautiful things.

@acer

Thanks

## @JAMET I still don't understand...

@JAMET

I still don't understand.: where those 6 triples come from?
What is the triple you are starting from and what is the relations between them?

Finally, what does this question have in common with your first one?

## In simple words...

what do you want to achieve?
Q1: Do you want to find all Pythagorean Triples (PT) (a, b, c) such that a < A, b < B, c < C where (A, B, C) is a PT?

Q2: Is (A, B, C) a "reduced" PT in the sense that the common divisor of A, B, C is 1?

Here is procedure which finds (within one arbitrary permutation) all the PT (a, b, c) assuming the answer to question Q1 is YES and (A, B, C) is "reduced".

 > restart
 > PrimitivePythagoreanTriple := proc(r, s) isolve({u=r^2-s^2, v=2*r*s, w=r^2+s^2}) end proc:
 > SPT := proc(exemple)   local sorted, check, dc, rPT, M, se, re, rel, rs, SPT, r, a, s:   # Verifiy is "exemple" is a Pythagorean Triple (PT)   sorted := sort(exemple);   check  := add(sorted[1..2]^~2) - sorted[3]^2;   if check <> 0 then     error cat(exemple, " is not a pythagorean triple")   else     # Reduce PT        dc  := igcd(exemple[]);     rPT := exemple /~ dc:     if dc > 1 then       printf("Attention, %a n'est pas sous forme réduite (diviseur commun = %d)\n", exemple, dc);       printf("On considere ARBITRAIREMENT le triplet pythagoricien réduit %a\n", rPT);     end if:        # Rearrange PPT in a convenient order        M := max(rPT):     se, re := selectremove(type, rPT, odd);     if M::odd then       rPT := [min(se), re[1], max(se)]     else       rPT := [min(re), se[1], max(re)]     end if;        # Find "generators"        rel := rPT =~ [r^2-s^2, 2*r*s, r^2+s^2];     rs  := solve({rel[1]+rel[3], r > 0});     rs  := rs union {s = solve(eval(rel[2], rs))};        # Generate PT (a, b, c) such that a < rPT[1], b < rPT[2], c < rPT[3]        SPT := NULL:     for r from 2 to eval(r, rs) do       if r::even then a := 1 else a := 2 end if:       for s from a to eval(s, rs) by 2 do         SPT := SPT, (abs@rhs)~(PrimitivePythagoreanTriple(r, s)):       end do:     end do:        return {SPT}   end if: end proc:
 > SPT([275, 252, 373])
 (1)
 > SPT([30, 16, 34])
 >
 Attention, [30, 16, 34] n'est pas sous forme réduite (diviseur commun = 2) On considere ARBITRAIREMENT le triplet pythagoricien réduit [15, 8, 17]
 (2)
 >

## Suggestion...

As your expression is the identical to those you pres ented in your previous question I advice you to read My reply to this latter question where you could find useful stuff, more specifically  all the material to determine how many real roots tou have depending on the values of rho and Gamma..

More of this I do not understand what you expect from your plot?
For instance the first plot does not plot "_quartic" but only one of the roots. Notional example:

```restart;
Eq := x^2 - rho^2:
f := unapply(RootOf(Eq, x), rho);  # two roots -rho and +rho
plot(f(rho), rho=0..1);            # only one relation plotted

# to plot both do this
plot([allvalues(f(rho))], rho=0..1)
```

## I was afraid you wanted that...

I think @Mariusz Iwaniuk is right (at least in the sense that a general formula is unlikely to be found using only build-in Maple's functions).

I tried using recurrence formulas an integration by parts but it seems a dead end to obtain a general expression.

Maybe this is a classical problem and answers can be find in reference books?
I advice you to browse the Abramowitz Stegun book which compiles an amazing lot of mathematical formulas.

## For information...

@Preben Alsholm

With Maple 2015:

```numtheory:-pdexpand(2/3);
numtheory:-pdexpand(50/7)
PDEXPAND(1, 0, [], [6])
PDEXPAND(1, 7, [], [1, 4, 2, 8, 5, 7])
```

For more recent versions there exists something close in NumberTheory (sory but I can say more for I'm using Maple 2015 right now).

 First 6 7 8 9 10 11 12 Last Page 8 of 135
﻿