mmcdara

7002 Reputation

18 Badges

8 years, 227 days

MaplePrimes Activity


These are replies submitted by mmcdara

@felixiao 

Sorry I missed your file in your initial question

restart
for r to 3 do 
  T[r] := exp(r+1); 
  P[r] := exp(r-1) 
end do:

mul(T[r]*P[r], r=1..3)
                         2                     
                 (exp(2))  exp(3) exp(1) exp(4)

or

restart
TP := 1:

for r to 3 do 
  T[r] := exp(r+1); 
  TP   := TP*T[r]:
  P[r] := exp(r-1):
  TP   := TP*P[r]:
end do:

TP
                         2                     
                 (exp(2))  exp(3) exp(1) exp(4)

 

@acer 

The equation the OP presents is the one dimensional (N=1) wave equation. This equation derive from a variational principle of energy conservation.


A good way to test a numerical scheme is to verify that E(t) is indeed a constant when u(x, t) is replaced by a numerical approximation uN(x, t)
This is how I would interpret "I want to test how well Maple's numeric solver respects a variety of conservation laws"

As a rule stable numerical schemes dissipate (mass, impulse, energy) and E(t) is likely do decrease over time. The smaller this decrease the better the solving method.
From your file:

restart;

pde := diff(v(x, t), t, t) = diff(v(x, t), x, x):

f := xi -> exp(-xi^2):

a := -10: b := 10: dx := 1/50: t_final := 10:

pds := pdsolve(pde, {v(a, t) = 0, v(b, t) = 0, v(x, 0) = f(x + 5),
                     D[2](v)(x, 0) = -eval(diff(f(x), x), x = x + 5)},
               numeric, range = a .. b, time = t, spacestep = dx):

sol_proc := rhs(pds:-value(output = listprocedure)[3]):

sol := (x, t) -> piecewise(a < x and x < b, sol_proc(x, t), 0):

# plot(D[2](sol)(x,0), x=a..b, size=[500,200]);

E := t ->
     evalf(Int((D[2](sol)(x,t))^2 + (D[1](sol)(x,t))^2, x=a..b, digits=10, epsilon=1e-5, method=_d01ajc))    ;

proc (t) options operator, arrow; evalf(Int((D[2](sol))(x, t)^2+(D[1](sol))(x, t)^2, x = a .. b, digits = 10, epsilon = 0.1e-4, method = _d01ajc)) end proc

(1)

E(0)

2.507375287

(2)

for s from 1 to 5 do
  [s, E(s)]
end do;

[1, 2.505877784]

 

[2, 2.505877752]

 

[3, 2.505877729]

 

[4, 2.505877918]

 

[5, 2.505873355]

(3)
 

 

Download E.mw



With Maple 2015:

M21 := expand(M21);
                               0

M_final := MatrixInverse(Matrix(2, 2, {(1, 1) = 1/M11, (1, 2) = -M12/M11, (2, 1) = 0, (2, 2) = -M22/M21}));
%;
Error, (in MatrixInverse) numeric exception: division by zero


 

@JAMET 

Pourquoi n'avez-vous pas dit plus tôt que les codes qui accompagnent vos questions sont générés par une IA (à l'évidence pas si intelligente que ça)?

Cela aurait peut-être permis de comprendre pourquoi ils sont un tel foutoir et pourquoi vos questions successives laissent l'impression que vous n'avez rien appris, au fil des ans, des précédentes réponses que vous avez reçues.
(Vous êtes vous aperçu que le texte que vous avez fourni dans votre question contient deux séquences débitant chacune par un restart ? N'auriez-vous pas pu le nettoyer un peu avant de le livrer afin qu'il soit plus présentable ?),

En outre pourquoi ne délivrez-vous jamais de feuille de travail Maple ?
Si vous n'avez pas de licence personnelle (ce que je peux comprendre car elle est payante) à quoi vous servent alors les codes contenus dans les réponses que vous recevez?
Un petit éclaircissement serait le bienvenu.

Si vous êtes passionné de géométrie, pourquoi ne pas utiliser Geogebra qui est gratuit et bénéficie d'un excellent support (en français)... et qui en outre propose es applications permettant de tracer les hyperbole d'Apollonius d'une conique (dont je n'ai trouvé aucune trace par ailleurs) ?

Pour conclure cette réponse, et je vous prie une fois de plus d'excuser mes propos dans ma réponse précédente, avoir 85 ans et être defficient visuel ne devrait pas être un prétexte pour ne pas respecter les quelques règles de courtoisie en vigueur sur ce site.


(improved DEEPL translation at the end of the comment)

 restart;

with(geometry):
_EnvHorizontalName := x: _EnvVerticalName := y:

F := proc(__A, __B, __C, ratio)

  local A, B, C, T, G, XY, AB, BC, CA, inC, exC, lAB, lBC, lCA;
  local H1AB, H1CA, H2CA, H2BC, H3AB, H3BC, H:
  local f, Apo, tx, TX, i, P, GP, ici;

  uses geometry, plots:
  
  point(A, op(__A)):
  point(B, op(__B)):
  point(C, op(__C)):

  triangle(T, [A, B, C]);
  centroid(G, T);
  XY := coordinates(G);

  bisector(AB, C, T);
  bisector(BC, A, T);
  bisector(CA, B, T);   
  
  incircle(inC, T);
  excircle(exC, T, [c1(o1),c2(o2),c3(o3)]);

  line(lAB, [A, B]):
  line(lBC, [B, C]):
  line(lCA, [C, A]):

  f   := (x, y) -> sqrt((x - __A[1])^2 + (y - __A[2])^2)/sqrt((x - __B[1])^2 + (y - __B[2])^2) - ratio;
  Apo := implicitplot(
           f(x, y)
           , x = -5 .. 5, y = -5 .. 5
           , grid = [100, 100]
           , style = line
           , color = red
           , thickness = 2
          );

  tx := NULL:

  TX := ["A", "B", "C"]:
  for i from 1 to 3 do
    P   := args[i]:
    GP  := P -~ XY:
    ici := P +~ GP*~0.1:
    tx := tx, textplot([ici[],  TX[i]], font = [times, bold, 16])
  end do:

intersection(H1AB, exC[1], lAB);
intersection(H1CA, exC[1], lCA);
intersection(H2CA, exC[2], lCA);
intersection(H2BC, exC[2], lBC);
intersection(H3AB, exC[3], lAB);
intersection(H3BC, exC[3], lBC);
H := evalf(coordinates~([H1AB, H1CA, H2CA, H2BC, H3AB, H3BC, A, B, C]));

  plots:-display(
    [
      Apo
      , tx
      , draw(T, color = black, thickness = 2)
      , draw([AB, BC, CA], style = line, color = blue, linestyle=3)
      , draw(inC, style = line, color = green, thickness = 2)
      , draw(exC, style = line, color = magenta, thickness = 2)
      , draw([lAB, lBC, lCA], color=black, linestyle=4)
    ]
    , axes = none
    , view=[((min-1)..(max+1))(map2(op, 1, H)), ((min-1)..(max+1))(map2(op, 2, H))]
    , size=[600, 600]
    , scaling = constrained
    , title = "Triangle with Bisectors, Apollonius Hyperbola, and Circles"
  );

end proc:

A := [0, 0];

B := [4, 2];

C := [2, 3];
F(A, B, C, 3)

 

[0, 0]

 

[4, 2]

 

[2, 3]

 

 

 

 

Download Proposition.mw


 

Why didn't you say earlier that the text codes accompanying  your questions are generated by an AI (obviously not that intelligent)?

That might have helped us to understand why they're such a mess, and why your repeated questions leave the impression that you've learned nothing, over the years, from the previous answers you've received.
(Did you notice that the text you provided in your last question contains two sequences, each beginning with a restart? Couldn't you have cleaned it up a bit before delivering and make it more presentable?),

And besides, why don't you ever deliver any Maple worksheets?
If you don't have a personal license (which I can understand, as it's not free), then what use are the codes uploaded in the answers you receive?
A little clarification would be welcome.

If you're passionate about geometry, why not use Geogebra, which is free and benefits from an excellent french support... and which also offers free applications for tracing Apollonius hyperbolas of a conic (of which I've found no mention elsewhere)?

To conclude this reply, and once again I apologize for my words in my previous comment, being 85 years old and visually defficient should not be an excuse for not respecting the few rules of courtesy that apply on this site.

Translated with DeepL.com (free version)

 

@Carl Love 

It works perfectly well and goes far beyond what I expected.

You told me once that subsindets was one of the most powerful algebraic operation in Maple. But I'm still not at ease with it and keep using makeshift alternatives based on things like map and select, or patmatch sometimes.
Since I read your last reply I've been practicing rewriting a few things using subsindets (whose help page is not very clear, in particular concerning the construction of fcntype), and it's very powerful indeed. 
Now all I have to do is give up my old habits.

Thanks for your time.

@nm 

Your reply suits me.
I can consider that I found a solution to what to a limitation of my old 2015 version and that it has been fixed in the most recent versions. 
I can't decently ask someone to explain me why something which didn't work 10 years ago works today: codes evolve and it's all for the better.

Thanks again

By the way: in Maple 2015 you can convert an expression containing intat/Intat into another one containing int/Int, but the reciprocal is not possible. Is that possible in Maple 2024?
For instance:

kernelopts(version)

`Maple 2015.2, APPLE UNIVERSAL OSX, Dec 20 2015, Build ID 1097895`

(1)

J := Intat(f(x), x=y)

Intat(f(x), x = y)

(2)

K := convert(J, Int);

Int(f(y), y)

(3)

L := convert(K, Intat)

Error, unrecognized conversion

 

# one might have expected something like

L = Intat(f(_Z), _Z=y)

L = Intat(f(_Z), _Z = y)

(4)
 

 

Download Intat.mw

@vv 

As CD=AB-2 is assumed to be a strictly positive integer (provided C and D are not confounded, which is the assumtion you use),
its niminum value is 1.
Which corresponds to AB = 3, and BC=5, so the lowest value of AD is 9.

Why do use Maple to do this?
It's a hydraulic hammer to kill a fly, and that's why teachers get desperate when they see students pulling out their pocket calculators to add 9 and 6.

Why do you keep asking questions like that?
A lot of your problems, like this one, can be solved by a middle school student and there is no need of any CAS for that.

Do you really want to know if Maple is capable to answer this one?
I think if he could not, it would have been thrown out a long time ago.

I am pretty sure there are more challenging problems for Maple than this one.

Remark: 
The formulation of the problem is for youngsters but lacks precision to be solved by Maple (does "consecutive" mean "not confounded"?)

@imparter 


You write I have an equation  W which constist of wo,w1,w2 and w3,:
No, you have 4 variables w0, ...w3 and another one W1 (you mispelled W in yout reply) which is equal to

W1:= (w0+w1*r^2+w2*r^4+w3*r^6);

W1 is not an equation:

whattype(W1); 
                     `+`
type(W1, 'equation')
                    false

At the end (output labeled (1) in your worksheet) the expression of  W1 depends on 5 indeterminates:

indets(W1, name)
                        {a, b, c, r, z}


Later, before applying plot, you do several substitutions which transform W1 into a new expression which depends on 11 indeterminates:

           {Da, Gr, S, alpha, c, kf, ks1, ks2, m, phi1, phi2}


You write  i want to plot the graphs for two data combine in one plot display in W1,
I understand you want to plot the expression of W1 (the one which depends on {a, b, c, r, z}, or the one which depends on {Da, Gr, S, alpha, c, kf, ks1, ks2, m, phi1, phi2} ?) as a function of two independent variables:

  • Do you want to do something like plot3d(some_expression_of_W1, variable_1, variable2) where some_expression_of_W1 is a an rewritting of W1 which contains variable_1 and variable2 ?
     
  • If it is so what are those inependent variables  variable_1 and variable2 ?
    To clarify this, you can do something like this
    plot3d(eval(W1, [a=1, b=2, c=3]), r=0..1, z=0..1)
    if you use the expression of W1 labeled (1) in your worksheet.

    Or 
    data := {Da=1, Gr=1, S=1, alpha=1, c=1, kf=1, ks1=1, ks2=1, m=1, phi1=1, phi2=1}:
    plot3d(eval(W1, data), r=0..1, M=2..9);
    if you use the expression of W1 after the rewrittings of {a, b, c}.

    But maybe you want to do
    data := {Da=1, Gr=1, S=1, alpha=1, c=1, kf=1, ks1=1, ks2=1, m=1, phi1=1, phi2=1}:
    W1e := eval(W1, data):
    plot( [seq(W1e, M=__M), __M=2..9)], r=0..1, legend='M'=~[$2..9]);


Try to be more precise in what you want to achieve.


The attached file explains you where the error comes from and why, once fixed, the plot command will produce another error.
It is up to you to fix this latter by giving numeric values to several remaining undeterminates.
Error_in_Display_1_mmcdara.mw

@minhthien2016 

My reaction to the MMA link you provide:

I'm disappointed by the lack of seriousness of the person who replied you: it simply shows that it has no statistical (nor mechanical) skills, as its answer simply makes no sense (unless it previously drawn the histogram of your raw data and observed that the the hypothesis of a uniform distribution was acceptable).

Don't take the answers you receive at face value: it's your responsibility to analyze them to understand whether or not they're credible.

Please read again my reply, I updated it.

The original @nm's question was "The problem is to find from all permutations of [1,2,3,4] those lists which has 2 in them before 3." and It feels like everybody took the same direction than @nm's, which is "construct the list of all permutations and select those where 2 appears before 3".
But It looks more natural to "construct directly the list of permutations for which 2 appears before 3".  
Behind the question I asked @Carl Love  (since I only have Maple 2015 I can't evaluate the performance of his solution) my real question was "Is this second approach more efficient than the one everyone else has considered?"

Here is a simple code (that could probably be improved) which seems to prove it's the case.
For comparison, I used @Kitonum's method, which @acer found to be the most efficient.
 

restart

C := proc(N, left, right)
  local P, J, L, k, n, j:

  P := combinat:-permute({$1..N} minus {left});
  J := ListTools:-Search~(right, P);

  L := table([]):
  k := 1:
  for n from 1 to (N-1)! do
    for j from 1 to J[n] do
      L[k] := [op(1..j-1, P[n]), left, op(j..-1, P[n])]:
      k    := k+1:
    end do:
  end do:
  L
end proc:

eval(C(4, 2, 3))

table( [( 1 ) = [2, 1, 3, 4], ( 2 ) = [1, 2, 3, 4], ( 3 ) = [2, 1, 4, 3], ( 4 ) = [1, 2, 4, 3], ( 5 ) = [1, 4, 2, 3], ( 6 ) = [2, 3, 1, 4], ( 7 ) = [2, 3, 4, 1], ( 9 ) = [4, 2, 1, 3], ( 8 ) = [2, 4, 1, 3], ( 11 ) = [2, 4, 3, 1], ( 10 ) = [4, 1, 2, 3], ( 12 ) = [4, 2, 3, 1] ] )

(1)

n := 4:
n! / 2;
CodeTools:-Usage(C(n, 2, 3)):

12

 

memory used=15.02KiB, alloc change=0 bytes, cpu time=0ns, real time=0ns, gc time=0ns

 

n := 5:
n! / 2;
CodeTools:-Usage(C(n, 2, 3)):

60

 

memory used=41.78KiB, alloc change=0 bytes, cpu time=0ns, real time=1000.00us, gc time=0ns

 

n := 6:
n! / 2;
CodeTools:-Usage(C(n, 2, 3)):

360

 

memory used=175.72KiB, alloc change=0 bytes, cpu time=1000.00us, real time=2.00ms, gc time=0ns

 

n := 7:
n! / 2;
CodeTools:-Usage(C(n, 2, 3)):

2520

 

memory used=1.07MiB, alloc change=0 bytes, cpu time=8.00ms, real time=8.00ms, gc time=0ns

 

n := 8:
n! / 2;
CodeTools:-Usage(C(n, 2, 3)):

20160

 

memory used=8.76MiB, alloc change=36.00MiB, cpu time=84.00ms, real time=84.00ms, gc time=6.98ms

 

n := 9:
n! / 2;
CodeTools:-Usage(C(n, 2, 3)):

181440

 

memory used=73.08MiB, alloc change=288.00MiB, cpu time=988.00ms, real time=824.00ms, gc time=343.09ms

 

# For comparison on my machine (from acer):
# Kitonum's suggestion

L:=combinat:-permute([1,2,3,4,5,6,7]):
CodeTools:-Usage(select(t->ListTools:-Search(2,t)<ListTools:-Search(3,t), L)):
nops(%);

print():print():
L:=combinat:-permute([1,2,3,4,5,6,7,8]):
CodeTools:-Usage(select(t->ListTools:-Search(2,t)<ListTools:-Search(3,t), L)):
nops(%);


print():print():
L:=combinat:-permute([1,2,3,4,5,6,7,8,9]):
CodeTools:-Usage(select(t->ListTools:-Search(2,t)<ListTools:-Search(3,t), L)):
nops(%);

memory used=1.44MiB, alloc change=0 bytes, cpu time=19.00ms, real time=19.00ms, gc time=0ns

 

2520

 

 

 

memory used=11.54MiB, alloc change=0 bytes, cpu time=138.00ms, real time=138.00ms, gc time=0ns

 

20160

 

 

 

memory used=103.83MiB, alloc change=26.92MiB, cpu time=3.66s, real time=2.03s, gc time=2.25s

 

181440

(2)
 

 

Download suite_2_3.mw

@Carl Love 

As I can't use the Iterator package (still Maple 2015), could you please give me the performances you get when evaluating function f for a few values of N:

f := N -> {seq}(p[], p= Iterator:-TopologicalSorts(N, {2<3}));
CodeTools:-Usage(f(...)):

Thanks in advance

@Aung 

I'm fed up with people asking questions and not bothering to give feedback on the answers they've received.
Considering that what I did no longer interest you I then remove some parts of this reply


Result without explanation



When you will be interested again, if that ever happens, let me know, I will deliver you the code

@nm 

You must create an account first (free and anonymous, your email adress is never asked nor your username).
Once done the description page looks loke this 
Enter your answer and click on the Check button to check it.

Solutions are gathered here.
As Project Euler is more computing oriented than brainstorming this site only contains code in 4 different languages (MMA in particular) but no textual explanation of the way to get these solutions is provided.

This site provides more explanations, but only for the problems the author solved.

5 6 7 8 9 10 11 Last Page 7 of 145