dharr

Dr. David Harrington

8215 Reputation

22 Badges

20 years, 339 days
University of Victoria
Professor or university staff
Victoria, British Columbia, Canada

Social Networks and Content at Maplesoft.com

Maple Application Center
I am a retired professor of chemistry at the University of Victoria, BC, Canada. My research areas are electrochemistry and surface science. I have been a user of Maple since about 1990.

MaplePrimes Activity


These are answers submitted by dharr

I'm assuming you really want a group, rather than just doing arithmetic mod n. The addition case is just the CyclicGroup:

with(GroupTheory)

G := CyclicGroup(7)

_m1835422256320

lbl:=proc(el) local i;
  i:=convert(el,'list');
  if nops(i)=0 then 0 else i[1]-1 end if;
end proc:
     

DrawCayleyTable(G, labels = lbl)

 

 

Download mod7.mw

Following @Mariusz Iwaniuk but can't get the last step.

Download summation.mw

I clicked on a pMML link (5.13.E1), which downloaded a file. I opened it in a text editor, selected all the text and copied it. In a Maple 2D input region, I pasted and it asked me if I wanted to convert MathML to 2D input, and I said yes. It looks a little strange in the input region (not as bad as here), but seems to be functionally OK.

restart

q := (int(GAMMA(s+a)*GAMMA(b-s)*z^(-s), s = c-i*infinity .. c+i*infinity))/(2*Pi*i) = GAMMA(a+b)*z^a/(1+z)^(a+b)

(1/2)*(int(GAMMA(s+a)*GAMMA(b-s)*z^(-s), s = c-i*infinity .. c+i*infinity))/(Pi*i) = GAMMA(a+b)*z^a/(1+z)^(a+b)

lprint(q)

1/2/Pi/i*int(GAMMA(s+a)*GAMMA(b-s)*z^(-s),s = c-i*infinity .. c+i*infinity) =
GAMMA(a+b)*z^a/((1+z)^(a+b))

NULL

Download PMML.mw

Perhaps you want to assume n is an integer, or even or odd, in which case the following may help. If you want to use the +/- symbol, then that is not as easily done.

X := -1

-1

X^n

(-1)^n

`assuming`([simplify(X^n)], [n::even])

1

`assuming`([simplify(X^n)], [n::odd])

-1

Y := 1

1

Y^n

1

``

Download Xn.mw

@Kitonum's method requires retyping of the variable names on the lhs. This can be avoided with assign.

restart

sys := {T__1 = m__1*a, a = R*alpha, -R*T__1+R*T__2 = I__s*a/R, g*m__2-T__2 = m__2*a}

vars := {T__1, T__2, a, alpha}

params := `minus`(indets(sys), vars)

NULL

ans := solve(sys, vars)

{T__1 = R^2*g*m__2*m__1/(R^2*m__1+R^2*m__2+I__s), T__2 = m__2*g*(R^2*m__1+I__s)/(R^2*m__1+R^2*m__2+I__s), a = R^2*g*m__2/(R^2*m__1+R^2*m__2+I__s), alpha = R*g*m__2/(R^2*m__1+R^2*m__2+I__s)}

map(proc (x) options operator, arrow; assign(lhs(x) = unapply(rhs(x), params[])) end proc, ans)

{}

op(a)

proc (I__s, R, g, m__1, m__2) options operator, arrow; R^2*g*m__2/(R^2*m__1+R^2*m__2+I__s) end proc

a(1, 2, 3, 4, 5)

60/37

NULL

Download solveEqs.mw

The ExportMatrix command can take a list of Matrices and write them to a MATLAB format file. See the help page for more details.

I don't know the exact answer. I found it confusing that you added the types in the module within the module; maybe it is a scoping issue. Why not just add them in the ModuleLoad procedure of RationalTrigonometry? (And for debugging purposes, I'd comment out any lines that remove them, in case they were added and the removed before you intended.)

Perhaps this is what you recall.

de:=gfun:-algeqtodiffeq(y = y^2*z + 1, y(z))

gives

The thing on the left-hand side of an assignment (:=) can't be an expression like lambda^m. You could assign to, say, lambda_m, but it would just be a name.

Perhaps you want something like eqn[m] instead of lambda^m?

Use mul for this, just

mul(v)

or

mul(i, i in v)

 

You do need to change to x=1/I to do linear least squares. 

restart

with(Statistics); with(plots); interface(imaginaryunit = I)

data := LinearAlgebra:-Transpose(`<,>`(`<|>`(1.31, 1.01, .81, .67, .56), `<|>`(1, 1.5, 2, 2.5, 3)))

Matrix(%id = 36893490698736924180)

Not linear, so use nonlinear least squares

plot(data, style = point)

Fit(U/I-R__i, data, I)

-HFloat(0.454173024787339)+HFloat(1.9582384498777987)/I

Take reciprocal of I to get x

data2 := `<|>`(`~`[`^`](data[() .. (), 1], -1), data[() .. (), 2])

Matrix(%id = 36893490698736840204)

Now linear

p1 := plot(data2, style = point); display(p1)

Get the same numbers.

eqn := Fit(U*x-R__i, data2, x)

-HFloat(0.454173024787339)+HFloat(1.9582384498777987)*x

display(p1, plot(eqn, x = .5 .. 2))

X := data2[() .. (), 1]; Y := data2[() .. (), 2]

Vector(5, {(1) = .7633587786, (2) = .9900990099, (3) = 1.234567901, (4) = 1.492537313, (5) = 1.785714286})

Vector[column](%id = 36893490698744642724)

Do it the hard way (eqns from Wikipedia page)

sumX := add(X); sumY := add(Y); sumX2 := add(x^2, `in`(x, X)); sumXY := X.Y

6.266277288

10.0

8.503613718

13.8061292359499994

eq1 := numelems(X)*a+b*sumX = sumY; eq2 := a*sumX+b*sumX2 = sumXY

5*a+6.266277288*b = 10.0

6.266277288*a+8.503613718*b = 13.8061292359499994

solve({eq1, eq2}, {a, b})

{a = -.4541730232, b = 1.958238449}

NULL

Download Mapleprimes_Question_Book_2_Paragraph_5.12_Question_3.mw

Use

W := Matrix(2, 2, [[a, b], [c, d]])

not Array for "." to work correctly.

For varying initial conditions on one variable (x in the worksheet) use DEplot. Example in the attached worksheet.

Download DEplot.mw

des := {diff(x(t), t) = -x(t), diff(y(t), t) = -y(t)^2};
DEtools:-DEplot(des, {x(t), y(t)}, 0 .. 4,
                [[x(0) = 1, y(0) = 1],[x(0) = 2, y(0) = 1]], scene = [t, x]);

 

@tomleslie's generation of a CSV file is correct, but if you want it named as a .txt file just use

Export("E:\\M.txt", M, format = "CSV");

Your error message was because Export wants the filename before the data.

There seems to be some theory about fundamental cutsets being used to generate cutsets and a relationship to spanning trees, which I didn't try to follow.  I also found the description of structure graphs in your reference confusing. The following just uses all partitions of the vertices into two sets and then collects the cutsets for those partitions that give two-component graphs. Your graph can be done in about 20 min on my laptop.

Edit: This new version uses a single iterator (Iterator:-SetPartitions), and is slightly faster. 

Edit: A new method involving fundamental cutsets is given in this post

Find all minimal edge sets. Brute force - just generates all bipartitions of the vertices.

https://www.mapleprimes.com/questions/235430-Find-All-Minimal-Edge-Cuts-Of-A-Graph

restart

MinimalEdgeCuts:=proc(G::GRAPHLN)
  local mincutsets,n,edges,partitions,
    vertset,verts,vertices,i,j,G1,G2;
  uses GraphTheory;
  if not IsConnected(G) then return Vector([]) end if;
  n:=NumberOfVertices(G);
  edges:=Edges(G);
  vertices:={Vertices(G)[]};
  mincutsets:=table();
  j:=0;
  partitions:=Iterator:-SetPartitions(n,parts=2);
  for verts in partitions do
    vertset:={seq(ifelse(verts[i]=1,vertices[i],NULL),i=1..n)};
    G1:=InducedSubgraph(G,vertset);
    G2:=InducedSubgraph(G,vertices minus vertset);
    if IsConnected(G1) and IsConnected(G2) then
       j:=j+1;
       mincutsets[j]:=edges minus Edges(G1) minus Edges(G2)
    end if
  end do;
  Vector(j,mincutsets)
end proc:

with(GraphTheory)

G1 := Graph({{a, b}, {a, c}, {a, h}, {a, i}, {b, c}, {c, d}, {d, e}, {d, f}, {e, f}, {h, i}}); DrawGraph(G1, size = [200, 200]); mincutset1 := CodeTools:-Usage(MinimalEdgeCuts(G1)); numelems(mincutset1)

G1 := `Graph 4: an undirected unweighted graph with 8 vertices and 10 edge(s)`

memory used=4.28MiB, alloc change=0 bytes, cpu time=141.00ms, real time=201.00ms, gc time=0ns

Vector[column](%id = 36893490719163192972)

10

G2 := Graph({{1, 2}, {1, 4}, {1, 5}, {2, 3}, {2, 5}, {3, 5}, {3, 6}, {4, 5}, {4, 7}, {5, 6}, {5, 7}, {5, 8}, {5, 9}, {6, 9}, {7, 8}, {8, 9}}); SetVertexPositions(G2, [[1, 3], [2, 3], [3, 3], [1, 2], [2, 2], [3, 2], [1, 1], [2, 1], [3, 1]])

GRAPHLN(undirected, unweighted, [1, 2, 3, 4, 5, 6, 7, 8, 9], Array(1..9, {(1) = {2, 4, 5}, (2) = {1, 3, 5}, (3) = {2, 5, 6}, (4) = {1, 5, 7}, (5) = {1, 2, 3, 4, 6, 7, 8, 9}, (6) = {3, 5, 9}, (7) = {4, 5, 8}, (8) = {5, 7, 9}, (9) = {5, 6, 8}}), `GRAPHLN/table/1049604`, 0)

DrawGraph(G2, size = [200, 200]); mincutsets2 := CodeTools:-Usage(MinimalEdgeCuts(G2)); numelems(mincutsets2)

memory used=9.63MiB, alloc change=0 bytes, cpu time=281.00ms, real time=338.00ms, gc time=0ns

57

g := "S~tIID@OI?{@n~V?goYEDOWd?qI?sJ?[C"; G := GraphTheory:-ConvertGraph(g); GraphTheory:-DrawGraph(G)

GRAPHLN(undirected, unweighted, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], Array(1..20, {(1) = {2, 3, 4, 5, 12, 13}, (2) = {1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16, 17, 18, 19, 20}, (3) = {1, 2, 4, 12, 13, 20}, (4) = {1, 2, 3, 5, 13, 14}, (5) = {1, 2, 4, 6, 13, 14}, (6) = {2, 5, 7, 13, 14, 15}, (7) = {2, 6, 8, 13, 15, 16}, (8) = {2, 7, 9, 13, 16, 17}, (9) = {2, 8, 10, 13, 17, 18}, (10) = {2, 9, 11, 13, 18, 19}, (11) = {2, 10, 12, 13, 19, 20}, (12) = {1, 2, 3, 11, 13, 20}, (13) = {1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16, 17, 18, 19, 20}, (14) = {2, 4, 5, 6, 13, 15}, (15) = {2, 6, 7, 13, 14, 16}, (16) = {2, 7, 8, 13, 15, 17}, (17) = {2, 8, 9, 13, 16, 18}, (18) = {2, 9, 10, 13, 17, 19}, (19) = {2, 10, 11, 13, 18, 20}, (20) = {2, 3, 11, 12, 13, 19}}), `GRAPHLN/table/770`, 0)

mincutsets := CodeTools:-Usage(MinimalEdgeCuts(G)); numelems(mincutsets)

memory used=38.90GiB, alloc change=6.19GiB, cpu time=16.98m, real time=11.14m, gc time=9.53m

314415

NULL

 

Download MinEdgeCutsPartition.mw

 

Older edit: The earlier version below used the Combination iterator multiple times. In the first version the rank option of the Iterator was not working as advertised, so there was 1 duplicate in the last example, now fixed; see reply for more details.

Download MinEdgeCuts2.mw

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