dharr

Dr. David Harrington

8270 Reputation

22 Badges

20 years, 357 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

The error message is because you are assigning to kt_poly, which is not allowed, because it is passed into the procedure (and already has a value). The easiest fix is just to have the procedure return the value of Quotient as the last line of the procedure. Now you get an error about Quotient not allowing multivariate polynomials, which is because the X passed into the procedure in cyclo_poly[i] is diiferent from the local X. The simplest fix is to pass the variable you want (X) as a third argument to the procedure.

``

Programm zur Brechnung der Kreisteilungspolynome_2022-04-05 Ki

 

NULL

restart; with(Algebraic); with(NumberTheory)

Error, invalid input: with expects its 1st argument, pname, to be of type {`module`, package}, but received NumberTheory

n := 6;

6

 

cyclo_poly := Vector[row](1 .. n, 0)

cyclo_poly := Vector[row](6, {(1) = X-1, (2) = X+1, (3) = 0, (4) = 0, (5) = 0, (6) = 0})

i := 1;

1

X-1


c_poly := proc (i, kt_poly, X) local j, hz1, hz2; j := i+1; hz1 := X^j-1; hz2 := kt_poly; Algebraic:-Quotient(hz1, hz2, X) end proc:

cyclo_poly[2] := c_poly(i, cyclo_poly[i], X);

X+1

i := 1;

1

X-1

j := i+1;

2

X^2-1

X+1

X-1

Download Programm_zur_Brechnung_der_Kreisteilungspolynome_2022-04-05_Ki.mw

s := series(1/tan(x), x, 9);

series(x^(-1)-(1/3)*x-(1/45)*x^3-(2/945)*x^5+O(x^7),x,7)

s2 := convert(s, polynom)+`...`

1/x-(1/3)*x-(1/45)*x^3-(2/945)*x^5+`...`

``

Download dots.mw

A plot of the indefinite integral shows discontinuities at 0, Pi, 2*Pi. If you take the limits from the left or right as appropriate, and avoid the discontinuities, you can get the right answer.

restart; with(Student[Calculus1])

Ellipse := [3*cos(theta), 2*sin(theta)]:

 

Why do the answers from evaluating EllALintegral differ from those provided by the ArcLength command?

evalf(ArcLength(Ellipse, theta = 0 .. 2*Pi));

15.86543959

evalf(Student:-Calculus1:-ArcLength(Ellipse, theta = 0 .. (1/4)*Pi));

1.734843463

Student:-Calculus1:-ArcLength(Ellipse, theta = 0 .. 2*Pi, output = integral);

Int((9*sin(theta)^2+4*cos(theta)^2)^(1/2), theta = 0 .. 2*Pi)

15.86543959

plot(sqrt(9*sin(theta)^2+4*cos(theta)^2), theta = 0 .. 2*Pi);

EllALintegral := int(sqrt(9*sin(theta)^2+4*cos(theta)^2), theta);

-3*((5*cos(theta)^2-9)*(cos(theta)^2-1))^(1/2)*(1-cos(theta)^2)^(1/2)*EllipticE(cos(theta), (1/3)*5^(1/2))/((5*cos(theta)^4-14*cos(theta)^2+9)^(1/2)*sin(theta))

plot(EllALintegral, theta = 0 .. 2*Pi);

limit(EllALintegral, theta = 2*Pi, left);

3*EllipticE((1/3)*5^(1/2))

3.966359898

-3*EllipticE((1/3)*5^(1/2))

-3.966359898

2*(limit(EllALintegral, theta = Pi, left)-(limit(EllALintegral, theta = 0, right)));

12*EllipticE((1/3)*5^(1/2))

15.86543959

NULL

Download ArcLength_of_Ellipse.mw

I used eval to substitute C1 and C2 into psi, which had square brackets around that I removed. Then the limit works. You should be usung LinearAlgebra rather than linalg.

limit.mw

I usually force the hardware type I want, here integer[8]. Then you get an explicit error about the overflow.

Note that tail recursion gives a massive speedup - as the documentation says: "During compilation, tail-recursive calls are detected and transformed into iteration. This means that tail-recursive procedures compile to very fast code."

Download fibonacci.mw

Eigenvalues are efficiently calculated for floating point matrices, and if you specify shape=symmetric then it will use an algorithm for symmetric matrices that returns real eigenvalues. (Calculating through eigenvalues is better than through the characteristic polynomial).
 

restart;

with(LinearAlgebra):with(GraphTheory):
G2:=Graph({{1,2},{2,3},{3,1},{3,4}}):
A2:=AdjacencyMatrix(G2):
Anum:=Matrix(A2,datatype=float[8],shape=symmetric);
Eigenvalues(Anum);

Typesetting:-mrow(Typesetting:-mi("Anum", italic = "true", mathvariant = "italic"), Typesetting:-mo(":=", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.2777778em", rspace = "0.2777778em"), Typesetting:-mverbatim("-I'RTABLEG6"6%"5i?>">uSuY%=-I'MATRIXG6"6#7&7&$""!""!$"""""!$"""""!$""!""!7&$"""""!$""!""!$"""""!$""!""!7&$"""""!$"""""!$""!""!$"""""!7&$""!""!$""!""!$"""""!$""!""!I'MatrixG6$%*protectedGI(_syslibG6""))

Vector[column]([[-1.48119430409202], [-1.00000000000000], [.311107817465982], [2.17008648662603]])

NULL

 

Download evals.mw

Not sure about types of matrices, normal, diagonalizable, large or small etc, but this might be useful. For general M,N there is unlikely to be a solution.

Solve M^i = N for i

restart

with(LinearAlgebra)

Set up one we know (M should be diagonalizable; this one is also normal)

M := Matrix(2, 2, {(1, 1) = 3/2, (1, 2) = 1/2, (2, 1) = 1/2, (2, 2) = 3/2})

M := Matrix(2, 2, {(1, 1) = 3/2, (1, 2) = 1/2, (2, 1) = 1/2, (2, 2) = 3/2})

N := M^7

N := Matrix(2, 2, {(1, 1) = 129/2, (1, 2) = 127/2, (2, 1) = 127/2, (2, 2) = 129/2})

Straightforward method

Z := MatrixFunction(M, x^i, x)-N; solve({entries(Z, 'nolist')}, i)

Z := Matrix(2, 2, {(1, 1) = -64+2^(-1+i), (1, 2) = -64+2^(-1+i), (2, 1) = -64+2^(-1+i), (2, 2) = -64+2^(-1+i)})

{i = 7}

Explicitly through the eigenvalues and eigenvectors

evs, U := Eigenvectors(M)

evs, U := Vector(2, {(1) = 2, (2) = 1}), Matrix(2, 2, {(1, 1) = 1, (1, 2) = -1, (2, 1) = 1, (2, 2) = 1})

So M can be written

Lambda := DiagonalMatrix(evs); U.Lambda.(1/U)

Lambda := Matrix(2, 2, {(1, 1) = 2, (2, 2) = 1}, storage = diagonal, shape = [diagonal])

Matrix([[3/2, 1/2], [1/2, 3/2]])

A function on the matrix is a function on its eigenvalues in this form, so M^i is

U.Lambda^i.(1/U)

(Matrix(2, 2, {(1, 1) = 1, (1, 2) = -1, (2, 1) = 1, (2, 2) = 1})).(Matrix(2, 2, {(1, 1) = 2, (2, 2) = 1}, storage = diagonal, shape = [diagonal]))^i.(Matrix(2, 2, {(1, 1) = 1/2, (1, 2) = 1/2, (2, 1) = -1/2, (2, 2) = 1/2}))

So we can convert M^i to diagonal form by U^(-1).M^i.U, and if we do the same to N then the entries should be the same

P := 1/U.N.U

P := Matrix(2, 2, {(1, 1) = 128, (1, 2) = 0, (2, 1) = 0, (2, 2) = 1})

If it wasn't diagonal, then there wouldn't be a solution. Equating the diagonals

Equate(`~`[`^`](evs, i), Diagonal(P)); solve(%, i)

[2^i = 128, 1 = 1]

{i = 7}

``

 

Download evs.mw

I'm guessing there are further rules to appear?

(I'm a liitle surprised my earlier code https://www.mapleprimes.com/questions/233777-Pythagorean-Puzzle#answer285102 works for these edge cases, since I didn't think about them at the time.)

Building on Joe Riel's solution, here are three solutions with two resistors. In each case one resistor current is 1 A and the other is 0 A. Resistance procedure is in startup code region

restart

with(GraphTheory):

@Joe Riel's solution with the second resistor disconnected

G1 := GraphTheory:-Graph(["gnd", "1", "2", "3"], {[{"1", "gnd"}, 1], [{"2", "3"}, 1]}):

GraphTheory:-SetVertexPositions(G1, [[0, 0], [0, 1], [1, 1], [2, 1]]):

GraphTheory:-DrawGraph(G1);
EquivResistance = Resistance(G1, "1", "gnd")

EquivResistance = 1

If it has to be connected.

G2 := GraphTheory:-Graph(["gnd", "1", "2"], {[{"1", "2"}, 1], [{"1", "gnd"}, 1]}):

GraphTheory:-SetVertexPositions(G2, [[0, 0], [0, 1], [1, 1]]):

GraphTheory:-DrawGraph(G2);
EquivResistance = Resistance(G2, "1", "gnd")

EquivResistance = 1

If it has to be connected both ends

G3 := GraphTheory:-Graph(["gnd", "1", "2", "3"], {[{"1", "2"}, 1], [{"1", "3"}, 0], [{"1", "gnd"}, 1], [{"2", "3"}, 0]}):

GraphTheory:-SetVertexPositions(G3, [[0, 0], [0, 1], [1, 1], [1/2, 1/2]]):

GraphTheory:-DrawGraph(G3);
EquivResistance = Resistance(G3, "1", "gnd")

EquivResistance = 1

NULL

Download OneOhm.mw

Not sure exactly what you want - here is a start.

restart

Use GroupTheory - group is deprecated

with(GroupTheory):

a := Perm([[2, 3, 5], [4, 7, 6]]);

_m486598272

_m486592800

H := Group({a, b});

_m485510144

elems := convert(Elements(H), list);

[_m483701280, _m483705632, _m483706528, _m483707424, _m483708320, _m483709344, _m483710240, _m483711136, _m483712032, _m483712928, _m483713184, _m483714016, _m483714848, _m483715744, _m483716640, _m483718880, _m483719712, _m483720544, _m485479424, _m486592800, _m486598272]

21

Product of all elements of H in the above order

`.`(elems[]);

_m483719712

DrawCayleyTable(H);

NULL

NULL

Download Group.mw

Edit: here some of it in the older group package, if you have Maple earlier than version 17

oldgroup.mw

S := sum(cos(i*x)/cos(x)^i, i = 0 .. n);

cos(x)*sin((n+1)*x)/(sin(x)*cos(x)^(n+1))

``

Download sum.mw

If you export as .rtf, you should be able to open it in Word, in a form that allows it to be modified.

Select all the font files (ctrl-A), and then the right-click menu has install or install for all users. (Double-clicking a single font file will install it.)

Not sure exactly what shape and size you want, but easiest to just declare b as an upper triangular matrix before generating the b[i,j] which go into it.You then get an error because you assigned a non zero entry for the lower triangular part. (Edit: I removed b[j,i]:=b[i,j] to fix that.) Probably you can fix this up to do what you want. (You should avoid using b for more than one purpose.)

bmatrix.mw

Yes, if typesetting is standard then you get the 2D output close to the version you see.

`Methods for first order ODEs:``--- Trying classification methods ---``trying a quadrature``<- quadrature successful`                         sol := y(x) = -cos(x) + _C1

Note that for the lprinted lines, each line is delimited with backquotes, so you could use this to insert linebreaks.

Well, I would just use view not to see the others, since you end up making another list otherwise. But I fixed your `if`; you want NULL to remove the list element (and there was something strange about the first "abs")

Download plotting.mw

First 43 44 45 46 47 48 49 Last Page 45 of 82