Dr. David Harrington

3813 Reputation

17 Badges

18 years, 153 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 professor of chemistry at the University of Victoria, BC, Canada, where 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

@dharr CayleyTableGroup is another way. (CustomGroup could also be used.) - works for add and multiply



Addition mod 7

Madd := Matrix(7, 7, proc (i, j) options operator, arrow; `mod`(i+j-2, 7)+1 end proc)

Matrix(%id = 36893490821750137428)

Gadd := CayleyTableGroup(Madd)


lblsadd := proc (i) options operator, arrow; i-1 end proc

proc (i) options operator, arrow; i-1 end proc

DrawCayleyTable(Gadd, labels = lblsadd)

Multiplication mod 7

Mmult := Matrix(6, 6, proc (i, j) options operator, arrow; `mod`(i*j, 7) end proc)

Matrix(%id = 36893490821805543780)

Gmult := CayleyTableGroup(Mmult)



Array(%id = 36893490821805550876)

But strangely the ordering is different here:



Download mod7.mw

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


G := CyclicGroup(7)


lbl:=proc(el) local i;
  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.


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)


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


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




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


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


Y := 1





Download Xn.mw

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


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)


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)



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)



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))


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(i, i in v)


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


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)


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)


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





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}


Download Mapleprimes_Question_Book_2_Paragraph_5.12_Question_3.mw


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.

1 2 3 4 5 6 7 Last Page 1 of 46