mmcdara

7891 Reputation

22 Badges

9 years, 54 days

MaplePrimes Activity


These are replies submitted by mmcdara

The lines you present are not Maple commands.
Either you've come to the wrong site or you're kidding the users here.

Here is an antology of errors for some lines picked here or there

%s1=sbeta./sgamma; sg= with gamma; sb= with beta; c=etar./eta;

Error, `/` unexpected

 

r=0.4:0.000001:1;

1

(1)

b1=0.0;b2=0.0;s=10000;sb=0;s1=sb./s;j=0;EZ=1;zeta0=-1;beta=1;i=(-1).^(1./2);

b1 = 0.

 

b2 = 0.

 

s = 10000

 

sb = 0

 

Error, `/` unexpected

 

%k1=k.^2.*zeta0./(1+c);

Error, `^` unexpected

 

T1=(1+c)./(2.*s.*(i.*alpha.^2.*j-4.*c));

Error, `/` unexpected

 

A1=(beta*besselk(0, k)-besselk(0, k.* sigma))./(besseli(0, k.* sigma).*besselk(0, k )-besselk(0, k.* sigma).*besseli(0, k));

Error, `*` unexpected

 

KK=-(k1.*(k.^2-s.*(4-i.*alpha.^2.*j.*c.^(-1))))./(k.^4-(r11).*k.^2+r22);

Error, `*` unexpected

 

 

Download Little_joker.mw

@Zeineb 

I meant "I believe it can be done in an easier way than the one you used in your question".

So no, I don't have in mind ainy other method to handle your problem.

Computing Steiner trees is a hard problem.

When I'm facing this kind of problem I always ask myself the quetsion "Is it worth writing a complex algorithm in Maple or is it better to use some software that already offers it?"
From nature I'm a lazzy man who doesn't like spending time to rewrite in some language what others already did very well with a different language.
This particularly if the problem I have to solve is of practical interest and that forcing me to use Maple  (or any other language) only can delay my getting a solution and my developping huge efforts.

If you are more interested in CAS look here SageMath
Otherwise loo here geosteiner

Once computed, it's likely that the graph will be able to be read from Maple, if you still want to use it.

@NeraSnow 

Isn't the command  

xlst := eval(ilst, ``(2)=``(x));   # where ilst = map(ifactor, lst)

I gave in my answer a simple enough way to evaluate the result of ifactor?

@Christopher2222 

Maybe there is one which matches your problem?

 

restart:

 

PROBLEM 1

# Modelling
# Let A, B, C, D, E the symbols that represent each family and let us consider
# each of them has a bow witin wich will be put one of these 5 letters to indicate
# the origine of the gift the owner of the box is boing to receive.
#
#      A1 A2 A3   B1 B2 B3 B4   C1 C2 C3 C4   D1 D2 D3 D4   E1
#
# If one is only interested in computing the probability of, let us say,
# all the members of family B receive gifts from members of faniliy C, one
# can forget the numbers 1, 2, 3, 4 and simply consider these boxes:
#
#      A A A   B B B B   C C C C   D D D D   E
#
# The probability P the whole family B will receive gifts from family C
# means that the content of these 16 boxes are
#
#      x x x   C C C C   x x x x   x x x x   x
#
# where x denotes "anything but C"
#
# There are 16! / (3! * (4!)^3 *1!) to dispose the 16 gofts withib the 16 boxes.
# On the other side there are 4! ways to place the 4 C's gift within the 4 B's boxes
# and 12! waus to place the 12 remaining gifts within the 12 remaining boxes.
#
# Thus the probability that the 4 members of family B receive the 4 C's gift is :

P1 := 4! * 12! / 16!;
evalf(%);

1/1820

 

0.5494505494e-3

(1)

 

PROBLEM 2

# What is the probability that all members of family B receive gits from family C
# and that all members of family C receive gifts from family B?
#
# Here the picture of the contentd of the boxes is
#
#      x x x   C C C C   B B B B   x x x x   x
#
# where x denotes "anything but B or C".
#
# As before there are 4! ways to put the C's gift within the B's boxes.
# There are also 4! ways to put the B's gift within the C's boxes.
#
# Let us consider the deposit of C's gifts within B's boxes.
# The 8 remaining gifts can be placed in 8! different ways in the boxes
# labeled x. Once done, the 4 B's gift can only be places in C's boxes in
# 4! different ways.

P2 := 4! * 4! * 8! / 16!;
evalf(%);

1/900900

 

0.1110001110e-5

(2)

# Note that these two results can be directly obtained this way
# (but reasoning cannot harm):

P1 := 1 / combinat:-multinomial(16, 4, 12);
P2 := 1 / combinat:-multinomial(16, 4, 4, 8);

1/1820

 

1/900900

(3)

 

PROBLEM 3

# Finally let us go a litle bit further than problem 2 by imposing now
# that if gift Ci is put within box Bj, then gift Bj is put within box Ci.
#
# Let us start from the result of Problem 2
# We got P2 := 4! * 4! * 8! / 16! because they were 4! to place C's gifts
# in B's boxes and 4! to place B's gifts in C's boxes.
# But now the constrain "if box Bi contains gift Cj then box Cj contains
# gift Bi" reduces this 4! * 4! number.
#
# In effect, once an arrangement is done for, let us say, the content of
# each B box, then the arrangement of the gifts in each box is a direct
# consequence of the former.
# For instance
#      if B1 has C4, B2 has C3, B3 has C1, B4 has C2
# which can be written S := [1=4, 2=3, 3=1, 4=2],
# then the content of C is defined by (rhs=lhs)~(S) in Maple's language.
#
# Thus

P3 := 4! * 8! / 16!;
evalf(%);

1/21621600

 

0.4625004625e-7

(4)

 

 

Download Christmas_Exchanges.mw

@Thomas Richard 

Sorry for having interfered Richard.
I was writting my reply and only read yours after having submitted mine.

I withdraw from this thread because you've already said it all

Several points 

  • The equation is not consistent: should be y(t) at the left hand side, not y(x).
  • Had A anb B be scalars, defining Y(t) = y(t) - B*exp(A*t) means that Y is the convolution product of v by phi where
    phi(t) = exp(A*t)*theta(t).
    Provided the Fourier transform Fv and Fphi of  v and phi do exist, then the Fourier transform of Y is
    FY(tau) = Fv(tau)*Fphi(tau)

    Applying then the inverse Fourier transform to both sides of this equality gives Y(t) and thus y(t).
    (note that neither nor the inverse Fourier transform of exp(A*t) do exist).

  • If B is a vector and A is matrix several questions appear:

    1. What does exp(A (t-x)) mean to you?

      1. Are t and x both vectors of length 4?
        In such a case exp(A (t-x)) is scalar but then B exp(A t) is a vector elementwise multiplied by the scalar exp(A t).

      2. If t and x are both scalar (which your single integral suggests), then exp(A (t-x)) is the exponential of a  matrix elementwise multiplied by the scalar t-x ... or it is a matrix whose the exponential has been applied elementwise to all its elements?

    2. What does B exp(A t) mean to you?
      (see point 1.1 above);

    3. Can you tell what are the domains and codomains of functions y, v, theta?

  • Whatever your answers one thing is sure: as long as you do provide expressions for functions  v and theta there is absolutely no chance to do something like plot(y(t), t=a..b).

To sum up: clarify your problem before coming to this community again

@Christopher2222 

Provided I correctly understood the problem in light of @Carl Love's explanations (which I'm not so sure about any more, because Carl is known for getting things right, see the text in red herafter), I get quite different estimations (even if the probability that all the members of family B exchanged with all the members of family C twice in a row makes the random nature of these exchanges highly suspect).

Maybe I made a wrong interpretation of the term "exchange" while considering that if someone, X, recieves the gift that someone else, Y, bought, then Y recieves X's.

restart:

with(Statistics):

# I describe the families by indexing their members for clarity purpose,
# but this is completely useless for the problem posed.

F  := [seq(A[i], i=1..3), seq(B[i], i=1..4), seq(C[i], i=1..4), seq(D[i], i=1..4), E[1]];
N  := numelems(F);

[A[1], A[2], A[3], B[1], B[2], B[3], B[4], C[1], C[2], C[3], C[4], D[1], D[2], D[3], D[4], E[1]]

 

16

(1)

 

Let EV the event
    EV : "A member in a family exchanges with one of its relatives"

 

# Estimation of the number of occcurrences of EV in a random assignement.
#
# There are about 22% of chanced that EV doesn't occur

R := 10^5:
Coincidences := Vector(R):

for n from 1 to R do
  P  := Matrix(8, 2, combinat:-randperm(F));
  M1 := map2(op, 0, P[.., 1]):
  M2 := map2(op, 0, P[.., 2]):
  is~(M1=~M2);
  Coincidences[n] := numelems(Select((x -> is(x=true)), %))
end do:

sort(Tally(Coincidences), key=(x -> lhs(x)));
Histogram(Coincidences, discrete=true, thickness=11)

[0 = 22301, 1 = 35542, 2 = 26319, 3 = 11906, 4 = 3374, 5 = 500, 6 = 54, 7 = 4]

 

 

# Results
#
# # There are about 22% of chanced that EV doesn't occur


Let EV the event
    EV : "All the members of at least one 4 members family exchange among them"



# Estimation of the number of occcurrences of EV in a random assignement.

R := 10^5:
IntraExchanges := Vector(R):

for n from 1 to R do
  P  := Matrix(8, 2, combinat:-randperm(F));
  P0 := map2(op, 0, P):
  L0 := map(sort, convert(P0, listlist));
  IntraExchanges[n] := ListTools:-Occurrences(2, [seq(ListTools:-Occurrences([f, f], L0), f in [B, C, D])]);
end do:

sort(Tally(IntraExchanges), key=(x -> lhs(x)));

[0 = 95515, 1 = 4373, 2 = 109, 3 = 3]

(2)

# Results
#
# 4373 times out of 10^5 there is  1 family   for which all the members exchange with themselves.
#  109 times out of 10^5 there are 2 families for which all the members exchange with themselves.
#    3 times out of 10^5 there are 3 families for which all the members exchange with themselves.


Let EV the event
    EV : "All the members a 4 members family exchange with all the members of
          another 4 members family"

# Estimation of the number of occcurrences of EV in a random assignement.

ff := [[B, C], [B, D], [C, D]]:
R  := 10^5:
EV := 0:

for n from 1 to R do
  P  := Matrix(8, 2, combinat:-randperm(F));
  P0 := map2(op, 0, P):
  L0 := map(sort, convert(P0, listlist));
  [seq(ListTools:-Occurrences(f, L0), f in ff)];
  if has(%, 4) then EV := EV+1 end if:
end do:

EV

400

(3)

# Results
#
# The frequency of event EV is about 4e-3.
# (Note that the frequency of EV for a given couple of families is 4e-3/3).
#
# Assuming EV happened last Christmas between families, let's say B anc C, what is the
# (estimation of) that EV happens this Christmas between the same families again?
#
# If EV happens this Christmas it can concern families (B, C) or (B, D) or (C,D).
# The probability that EV happens and concerns families B and C is about
# 4e-3 * 1/3.
#
# The probability that EV appears twice in a row between families B and C is
# (4e-3 / 3)^2 ~ 1.8e-6
#
# Quite small a value.
# So, if I understood correctly the problem, the probability that all the members of
# family B exchanged with all the members of family C twice in a row is a strong
# evidence that something not random did occur.

 

Download Families.mw

@Carl Love 

I understand now, explanations are loud and clear.
Thanks

@Carl Love 

Comment:

"Nonetheless, would you agree with this statement:"
To be honnest I didn't clearly understand the process @Christopher2222 described.
When I read "it's really 9 adults and 7 children who can swap presents...Oh, a child can trade with another child or a parent and similarily a parent can trade with another parent or a child" I first thought it was a "simple" problem of or combinatorial derangement as you mentioned it.
A was about to reply as I saw your own answer  which meant it was not that simple.
So, I'm sorry not to able to answer your question.

@Carl Love 

If I may say so, you are making an error of interpretation in saying "Using formal Statistics language, the p-value is less than 2%".

The p-value is used in inferential statistics and related to hypothesis testing.
Had @Christopher2222 provided empirical data collected among years, you could have tested the hypothesis "Was the name choosing really random?"
But it didn't, so the use of the name p-value is inadequate.

@delvin 

You don't have the same version of Maple so it's likely that the simplifications are not done the same way and that displaying orders differ.
As an exercice you can try to rewrite the expressions you got to get mine's.

Fot me the diffferences between us are not a subject worth wasting time on.

@delvin 

Can't you just be a little be patient and wait 75 seconds before panicking

Boy_in_a_hurry.mw

@Carl Love 

Yes of course, I wrote the relation I used without really paying attention.
Thanks for the correction.

I've proposed another approach meanwhile, see here
 

@Christian Wolinski 
Doing something like that (unfortunately the display time is too important) could be interesting.
The displays you will get correspond to those I gave in my answer vor diferent values of x.

Digits := 16:
p1 := plots[intersectplot](
    map(evalf, surface(eq1, y = 0 .. 20, z = -20 .. 20, x = 0 .. 1)),
    map(evalf, surface(eq2, y = 0 .. 20, z = -20 .. 20, x = 0 .. 1)),
    maxlev = 5, 
    grid = [100, 200, 20],  
    thickness = 3,  
    transparency = 0.3 
  ):

                               
Impacts := proc(X)
  plots:-display(
    p1, 
    plot3d(X, y = 0 .. 20, z = -20.. 20, color=black, transparency=0, style=surface)
    , view=[default, default, X..X+0.01]
    , scaling=constrained
    , orientation=[-90, 0, 0]
  );
end proc:

Explore(Impacts(X), parameters=[X = 0. .. 1.] );

In case you would be interested in improving this code?

First 34 35 36 37 38 39 40 Last Page 36 of 154