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1,
0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 0, 0]], Matrix): # adjacency

The desired diagram resembles:

The first one comes from Mathematica; the second one comes from MATLAB.
In MMA, we can use GraphLayout -> "LayeredDigraphEmbedding"; in MatLab, we can use Layout = "layered". Note that overlapping edges should be avoided in a layered plot.

Currently, since the vertices of a 2-D graph can be manually positioned, we can click, drag and place them to embed vertices, route edges, and then get a hierarchical structure as follows:

However, it's just a clumsy and fiddly job. Isn't there a fully automatic and less time-consuming method to do so in Maple?

                                                                                  Théorème de Brianchon
restart; with(plots):unprotect(gamma):
Error, missing operator or `;`
##Si un hexagone est circonscrit à un cercle, les droites qui joignent les sommets opposés passent par un même point.
_EnvHorizontalName := 'x';_EnvVerticalName := 'y';
                    _EnvHorizontalName := x

                     _EnvVerticalName := y

line := proc (x1, y1, x2, y2) options operator, arrow; (x-x1)*(y2-y1)-(y-y1)*(x2-x1) end proc:
R := 3:
ang := [0, (1/3)*Pi, 3*Pi*(1/4)+.2, 7*Pi*(1/6)+.4, 8*Pi*(1/5), 13*Pi*(1/7)]:
for i to 6 do P || i := [R*cos(ang[i]), R*sin(ang[i])] end do:
pts := [seq(P || i, i = 1 .. 6)]:
for i to 6 do tang || i := x*P || i[1]+y*P || i[2] = R^2 end do:
sol:=solve({tang1,tang3},{x,y}):Q13:=[subs(sol,x),subs(sol,y)]:
sol := solve({tang1, tang2}, {x, y}): Q1 := [subs(sol, x), subs(sol, y)]:
sol := solve({tang2, tang3}, {x, y}): Q2 := [subs(sol, x), subs(sol, y)]:
sol := solve({tang3, tang4}, {x, y}): Q3 := [subs(sol, x), subs(sol, y)]:
sol := solve({tang4, tang5}, {x, y}): Q4 := [subs(sol, x), subs(sol, y)]:
sol := solve({tang5, tang6}, {x, y}): Q5 := [subs(sol, x), subs(sol, y)]:
sol := solve({tang1, tang6}, {x, y}): Q6 := [subs(sol, x), subs(sol, y)]:
ptQ := [seq(Q || i, i = 1 .. 6)]:
line14 := line(Q1[1], Q1[2], Q4[1], Q4[2]): L14 := implicitplot(line14, x = -10 .. 10, y = -10 .. 10, color = red):
line25 := line(Q2[1], Q2[2], Q5[1], Q5[2]): L25 := implicitplot(line25, x = -10 .. 10, y = -10 .. 10, color = red):
line36 := line(Q3[1], Q3[2], Q6[1], Q6[2]): L36 := implicitplot(line36, x = -10 .. 10, y = -10 .. 10, color = red):
sol := solve({line14, line25}, {x, y}): I1 := [subs(sol, x), subs(sol, y)]:

lineP23 := line(P2[1], P2[2], P3[1], P3[2]): lineP56 := line(P5[1], P5[2], P6[1], P6[2]):
sol := solve({lineP23, lineP56}, {x, y}): gamma := [subs(sol, x), subs(sol, y)]:
Error, attempting to assign to `gamma` which is protected.  Try declaring `local gamma`; see ?protect for details.
lineP12 := line(P1[1], P1[2], P2[1], P2[2]): lineP45 := line(P4[1], P4[2], P5[1], P5[2]):
sol := solve({lineP12, lineP45}, {x, y}): beta := [subs(sol, x), subs(sol, y)]:
lineP34 := line(P3[1], P3[2], P4[1], P4[2]): lineP16 := line(P1[1], P1[2], P6[1], P6[2]):
sol := solve({lineP16, lineP34}, {x, y}): alpha := [subs(sol, x), subs(sol, y)]:
pl:= line(alpha[1], alpha[2], gamma[1], gamma[2]):
hexa := seq(implicitplot(tang||i, x = -20 .. 20, y = -20 .. 20, linestyle=3,color = blue),i=1..6);
hexa:=plot([seq([P||i,P||(i mod 6)+1],i=1..6),color=green); 
hexa:=plot([seq([P||i,P||(i+1)],i=1..6)],thickness=4,color=green); 
hex:=plot([[Q1,Q2],[Q2,Q3],[Q3,Q4],[Q4,Q5],[Q5,Q6],[Q6,Q1]],thickness=4,color=green);
tp := textplot({seq([op(pts[i]), cat("P", i)], i = 1 .. 6)}, 'align' = {'above', 'left'});
tpq := textplot({seq([op(ptQ[i]), cat("Q", i)], i = 1 .. 6)}, 'align' = {'above', 'left'});
TP:=textplot([[I1[],"I"],[alpha[],"alpha"],[beta[],"beta"],[gamma[],"gamma"]],'align' = {'above', 'left'});
slopes:=[seq(((dx,dy)->dy/dx)((pts[i]-pts[(i mod 6)+1])[]),i=1..6)];
lines:=zip((pt,slope)->y=slope*(x-pt[1])+pt[2],pts,slopes);
plotpts:=plot(pts,style=point,colour=red,symbol=solidcircle,symbolsize=5);
plotptQ:=plot(ptQ,style=point,colour=black,symbol=solidcircle,symbolsize=5);
plotlines:=plot(rhs~(lines),style=line,linestyle=3,colour=magenta);
cir:=implicitplot(x^2+y^2=R^2,x=-R..R,y=-R..R,color=black);
PL:=implicitplot(pl,x=-1..15,y=-15..6,color=blue,thickness=3);

 hexa := implicitplot(tang1, x = -20 .. 20, y = -20 .. 20, 

   linestyle = 3, color = blue), implicitplot(tang2, 

   x = -20 .. 20, y = -20 .. 20, linestyle = 3, color = blue), 

   implicitplot(tang3, x = -20 .. 20, y = -20 .. 20, 

   linestyle = 3, color = blue), implicitplot(tang4, 

   x = -20 .. 20, y = -20 .. 20, linestyle = 3, color = blue), 

   implicitplot(tang5, x = -20 .. 20, y = -20 .. 20, 

   linestyle = 3, color = blue), implicitplot(tang6, 

   x = -20 .. 20, y = -20 .. 20, linestyle = 3, color = blue)


Error, `)` unexpected
display(plotpts,plotptQ,plotlines,hex,cir,L14,L25,L36,PL,tp,tpq,TP,axis = [gridlines = [4, color = blue]],
view=[-6..10,-15..6],scaling=constrained,axes=none,size=[800,800]);
display(plotpts, plotptQ, plotlines, hex, cir, 

  implicitplot(0, x = -10 .. 10, y = -10 .. 10, color = red), 

  implicitplot(0, x = -10 .. 10, y = -10 .. 10, color = red), 

  implicitplot(0, x = -10 .. 10, y = -10 .. 10, color = red), PL, 

  tp, tpq, TP, axis = [gridlines = [4, color = blue]], 

  view = [-6 .. 10, -15 .. 6], scaling = constrained, 

  axes = none, size = [800, 800])


NULL;
I don’t know how to correct those mistakes. Thank you to help me.

Hello everybody. 

Im working on some implicit differentiation math right now. And by following the example, it is not bringing me anywhere close to the right answer. 

In English it says: Given the implicit written function x^2-2*x*y+2*y^2=12. Determine the local maximum and/or minimum of y and x. 

The answer (as can be seen in the maple file), is for y between 2sqrt3 and -2sqrt3, and -2sqrt6 and 2sqrt6. 

The example clearly states in the solution (oplossing), that the dy/dx needs to be derived for x. But after doing that, and filling in the equation the same way the example is doing it, im not getting to the rigth answer, but -sqrt3/24, and that doesnt look like the right answer


 

#Opdracht 4

x^2-2*x*y+2*y^2-12

x^2-2*x*y+2*y^2-12

(1)

diff(x^2-2*x*y+2*y^2-12, x)

2*x-2*y

(2)

diff(x^2-2*x*y+2*y^2-12, y)

-2*x+4*y

(3)

solve(x^2-2*x^2+2*x^2-12 = 0, x)

2*3^(1/2), -2*3^(1/2)

(4)

"f(x,y):=x^(2)-2*x*y+2*y^(2)-12"

proc (x, y) options operator, arrow, function_assign; x^2-2*y*x+2*y^2-12 end proc

(5)

dy/dx = -(2*x-2*y)/(-2*x+4*y)

dy/dx = -(2*x-2*y)/(-2*x+4*y)

(6)

simplify(%)

dy/dx = (x-y)/(x-2*y)

(7)

x^2-2*x*y+2*y^2-12

smartplot[x, y](x^2-2*x*y+2*y^2-12 = 0)

 

 

evalf(2*sqrt(3))

3.464101616

(8)

(x-y)/(x-2*y)

diff((x-y)/(x-2*y), x)

1/(x-2*y)-(x-y)/(x-2*y)^2

(9)

simplify(%)

-y/(x-2*y)^2

(10)

-2*sqrt(3)/(2*sqrt(3)*0-(2*2)*sqrt(3))^2

-(1/24)*3^(1/2)

(11)

evalf(%)

-0.7216878367e-1

(12)

``

Thank you for your time!

Greetings,

The Function

Download Mapleprimes_Question_Book_2_Paragraph_5.9_Question_4.mw

This is something that has been a problem using Maple for decades.

Is it at all possible to create indexed variables ?
e.g.

R1, R2, R3 etc by defining for example R$index and then varying $index for 1.....n to get the required
R1,R2 .... Rn  I can assign to equations or filenames?

It will really simplify batch work.

Thanks

Hello

I am experiencing some problems with procedures that are saved to a file and are read back to a new worksheet.  Grid:-Map and Grid:-Set, which work just fine when the procedures were defined in the same worksheet, complain about the input parameters.  I have tried to define the procedures again in the same worksheet, call Grid:-Set and etc but to no avail.   I would like to try to save all user variables except for the user-defined procedures and defined them again in the new worksheet, and see if that works. Is there an easy way to do that?

I am open to try whatever is suggested.

Many thanks.

Ed

Hey dear friends, in the following code (which is also attached at bottom of this post)

restart;
with(Physics[Vectors]);
Setup(mathematicalnotation = true);
with(Physics);
Setup(op = {H, I__C, I__G, Omega, R, a_, p, r, rho, v_, `α_`, `ω_`, `ϰ_`})
Newton_generalized_MatForm := m*(Omega*rho*H(t)*diff(`ϰ_`(t), t) - rho*diff(H(t), t)*diff(`ϰ_`(t), t) - rho*H(t)*diff(`ϰ_`(t), t, t) + diff(v_(t), t)) = f_[c] + f_[g]

 i wish to get the  (kappa-dot) coefficients 

so I used the "Coefficients" function as follows:

Coefficients(Newton_generalized_MatForm, diff(varkappa_(t), t))

but the results aren't as expected and it's this:

so is there a way around this , thanks in advance
Coeff.mw

Hello!
I have a document which can't be opened that contains several things I need to take my exam in a couple of days. The document has crashed and keeps telling this message: "There were problems during the loading process. Your worksheet may be incomplete". The only thing left in the document is a command and there should be several solved tasks.

I have tried to open the launch.ini file and add some script which MapleSoft suggested could sovle the problem, but I dont have access to the file by some reason. I read somewhere that danish letters such as æøå could be the reason for the document crashing. Is there any way to save the file or is it just lost? Eksamenssæt.mw

I embed Maple code in Mobius for test questions. A simple 2-step CRR tree gives significantly different answer from the calculated by hand or by R's fOptions. Here is the piece of Mobius/Maple:

$ct = maple("
    with(Finance):
    S0:=50; X:=50; Ty:=6./12; r:=0.07; sig:=0.3156; n:=1;
    dt := Ty/n;
    u  := exp(sig*sqrt(dt));
    d  := 1/u;
    pu := (exp(r*dt) - d)/(u - d);
    pd := 1 - pu;
    BT := BinomialTree(Ty,n,S0,u,pu,d,pd);
    cT := ST -> max(ST - $X,0);
    Ec := EuropeanOption(cT, $Ty):
    LatticePrice(Ec,BT,$r);
    ");

The answer is: 6.545478168.  Exactly the same with BlackScholesBinomialTree

The correct answer should be 6.32

In this case the solution by hand is simply e^(-0.07*05)*0.5236*$12.50

R confirms 6.32:

CRRBinomialTreeOption(TypeFlag = "ce", S=S, X=X, Time=T, r=r, b=b, sigma=sig, n=n)@price

The error decreases with the increase of number of steps. All quantities before LatticePrice are calculated corectly. Any idea of what the reason might be?

Thanks.

Where to store a collection of 100 matrices of different orders in Python language.

Then I need to pass that file as input to Maple for so kind of analysis here.

If possible an example with 3 to 4 matrices in python stored in some file I don't know which will be good and how say excel or database or any other (This only mainly I am not getting any idea)

Then the maple program here takes that file as input and does calculations here in maple 

Say as example Eigen values of those matrices

Here my matrices are all square matrices of various different orders

This code can draw the subgroup lattice:

DrawSubgroupLattice(GaloisGroup(x^3 - 2, x), 'indices')

But I really want to know what the extension of field about each subgroup corresponds to, like this:

The root of the polynomial r1=21/3, r2=21/3(-1+sqrt(3) I)/2, r2=21/3(-1-sqrt(3) I)/2 in the above graph. Further, how do we draw the extension relation of this polynomial:

x5+15x+44

The maple can draw this graph? If maple can't draw it, what software can?

SS.mw

How to rectify this error,I want a downfall curve ,Please help.

indets(I, anything^Non(integer)) = {I};

How does one return this to proper form?

 

restart;

q := (u,v) -> u^2 + v^2;

proc (u, v) options operator, arrow; v^2+u^2 end proc

D[3](q);

Error, (in D/procedure) index out of range: function takes only 2 arguments

Question: How does D know that q takes two arguments?

In general, if I pass q to another proc, how can I find out, within
that proc, that q takes only two arguments?

download number-of-arguments.mw

Dear,

I would like to do equation of motion calculations using spin matrices.

I would like to do calculations using the  coupling.

Thanks for listening.

Given a vector-valued function z(u,v), I want to calculate the derivative of z with respect to its first argument by applying the D operator to it. I don't see how.  Any suggestions?

restart;

z := (u,v) -> < a(u,v), b(u,v) >;

proc (u, v) options operator, arrow; `<,>`(a(u, v), b(u, v)) end proc

Calculate the derivative of z with respect to its first argument:

P := diff(z(u,v), u);

Vector(2, {(1) = diff(a(u, v), u), (2) = diff(b(u, v), u)})

Express P through the D operator:

Q := convert(P, D);

Vector(2, {(1) = (D[1](a))(u, v), (2) = (D[1](b))(u, v)})

Question:  How do we obtain Q directly by applying the D operator to z

without the help of diff?  This one doesn't work:

D[1](z)(u,v);
type(%, Vector);

(D[1](`<,>`))(a(u, v), b(u, v))*(D[1](a))(u, v)+(D[2](`<,>`))(a(u, v), b(u, v))*(D[1](b))(u, v)

false

Download diff.mw

First 243 244 245 246 247 248 249 Last Page 245 of 2425