mmcdara

7891 Reputation

22 Badges

9 years, 60 days

MaplePrimes Activity


These are replies submitted by mmcdara

Here is a solution

PS: you considered only sublists of at least 2 elements ... so I did the same here. But any single element can be considered as a list of one element...

 

restart

CommonSubList := proc(a::list, b::list)
   local s1, s2:
   s1 := { seq(seq(a[i..j], j=i+1..numelems(a)), i=1..numelems(a)-1) };
   s2 := { seq(seq(b[i..j], j=i+1..numelems(b)), i=1..numelems(b)-1) };
   return s1 intersect s2;
end proc:

L1:=[1,2,3,4,5]:
L2:=[0,5,2,3,7]:
L3:=[7,5,2,3,2]:

CommonSubList(L1, L2);
CommonSubList(L1, L3);
CommonSubList(L2, L3);

{[2, 3]}

 

{[2, 3]}

 

{[2, 3], [5, 2], [5, 2, 3]}

(1)

# what are the common sublists to L1, L2, L3

L12  := [ CommonSubList(L1, L2)[] ];
L123 := op(map(u -> CommonSubList(u, L3), L12));

print():
L23  := [ CommonSubList(L2, L3)[] ];
L231 := op(map(u -> CommonSubList(u, L1), L23));


print():
L13  := [ CommonSubList(L1, L3)[] ];
L132 := op(map(u -> CommonSubList(u, L3), L13))

[[2, 3]]

 

{[2, 3]}

 

 

[[2, 3], [5, 2], [5, 2, 3]]

 

{[2, 3]}, {}, {[2, 3]}

 

 

[[2, 3]]

 

{[2, 3]}

(2)

 


 

Download CommonSubLists.mw

@Christian Wolinski 

Don't know what result you obtain with Maple > 2015, but with Maple 2015 the answer is 0.255.
Not what it was asked for.

@Carl Love 
f1:= x-> piecewise(x >= 0, 1, 0); is not equivalent to Heaviside(x).
(f1(0) <> Heaviside(0)).
This could have been a good reason not to use Heaviside.

BTW: I already noted that you often write things like that 

local r:= PiecewiseTools:-Is(x >= 0);

I couldn't find this syntax in the help pages, only 
localSequence  -  (optional) names of local variables
and below :
the local localSequence; clause may optionally be followed by :: and a type.

Is this an "undocumented feature"?

 

Try to write 

seed := randomize()

at the beginning of your worksheet.

@acer 

Thank you acer.
I want "all the procedures which are exports of module M" ...
... and your first proposal works perfectly well.

Thank you acer

@Carl Love 

Sorry Carl, the correct command is 
ff := convert([ seq(es(entries( f [i,..], nolist)), i=1..N^P) ], Matrix);

I probably changed the name of the vraiable ffd into f and saved without executing.
 

@Christian Wolinski 

More elegant than what I did.
By the way, in maple 2015 the command to use is R := RootOf(numtheory:-cyclotomic(N, x), x); 

Thanks for the tip

@Christian Wolinski 

probably too long to explain. But if you want to have a quick idea, it's related to the construction of "full factorial designs"

(here a "3^2 design).
There exist many ways to do that, all depending on some coding. Here I used a coding based on the roots of the 1.
The design is the 9x2 matrix named f.
It's 9x9 extension ff must be an orthogonal matrix relatively to an adhoc dot product.

Tell me if you are are intersted by more details.
 

@Christian Wolinski 

OF COURSE !!!!
F being a matrix of complex I sould have used  LinearAlgebra[HermitianTranspose] instead of ^+

I was fooled by the fact that "." in the double loop gave me the result I expected (the identity matrix) and I didn't payed attention to use  LinearAlgebra[HermitianTranspose].

When I said I was blind !
 

@rlopez 

Thank you.

@rlopez 

Hi, 

Here is a screen capture of the assistant's sub menu in Maple 2015.2
There is no such Typesetiting Assistant: is my version too old?

Thanks

ScreenCapture.pdf

@MaxFilippov315 

Isn't it what I wrote in my reply and in answer.mw ????
So I think your "but thank you:)" is particularly unwelcome.

I don't thank you for that

 

Here is a classical example of missing data in Statistics: you want to collect P informations on a sample of N individuals (practically tht whole information can be represesented by a NxP matrix). Unfortunately, it happens that for one reason or another some informations are not collected for some individuals; in other terms this matrix has "holes"... or "missing data".

I can't relate this to your question, so what do you mean exactly by "missing data"?

 

F(5) (the variable you want to plot?) depends on a, b, c, d, Re, N[1], G(0) and G(1): assuming you want to plot F(5) as a function of Re and N[1] alone, the first thing to do is to set a, b, c, d,G(0) and G(1) to some numerical values.

If you do not want to be bothered with Re, begin your worksheet by
restart:
local Re:

@acer 


​​​​​​​You understood my question poperly.
Thanks for answer acer.

First 118 119 120 121 122 123 124 Last Page 120 of 154