Dr. David Harrington

2830 Reputation

17 Badges

17 years, 273 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 replies submitted by dharr

@jud In general it's poor etiquette to delete a post after it has been answered. Perhaps it will be useful for someone else (the indexing ds[2] is not obvious for example but you had figured that out.) Happy to help in your transition to Maple.

@salauayobami Click the green up-arrow, then Choose the file. Then click "upload". Then perhaps after a delay depending on how complicated your worksheet is you should see the two options "Insert link" and "insert contents". Sometimes "Insert contents" does not work well, so just do "insert link". If that doesn't work, suggest you remove the output from the worksheet by Edit->Remove Output -> From worksheet, and try again.

I deleted the many pages of cut-and-paste, which was not readable. Instead please upload your worksheet, using the green up-arrow.

It would really help if you gave a very specific example of what you want to start with and what the output would be.

@Carl Love "for k from k" - very efficient; I like it. But "is" seems redundant here.

Not sure entirely about your purpose, but from your title you may want to look at de2diffop.

@Carl Love Thanks. Edge {3,6} is missing on the 2 ohm one - still planar after adding it, 2 ohms between vertices 1 and 15.

@Tokoro No-one solved your first one-ohm problem. As I said before, it seems hard to search for these solutions, so if you have a method, you should share it.

@Tokoro The is a nice answer, and quite unexpected. Across which vertices is the equivalent resistance equal to one? Please post your code creating the graph so we can play with it. All vertex degrees are three except two...

I think that the rules should have: "all currents are different and none of them are zero", otherwise my second answer (and adding a pendent edge to your answer) is stlll valid.

I didn't want to do much work here since it wasn't really clear to me that it wasn't a trick question. But after seeing it I wondered how easy it would be to search for a solution by generating connected graphs with iteratively more vertices, with all combinations of edges to the previous vertices (this generates duplicates and might not be the most efficient). However, after 8 vertices it seemed like it would never get to 9. So the real question is - did you find this with Maple?

@evanhowington Hmm - very interesting, I thought the strict inequality case might be clearer. At least in Maple 15:

is(1+I < 2+I);

This is what I would expect:  "<" not defined for complex. Now

is(1+I < 1+I);

I would still expect FAIL here - if you can't define it, then you can't answer the question. But it seems that Maple decides that if they are equal, then a decision can be made. Then the same for the symbolic case:

is(x<x) assuming x::complex


@Earl You're welcome. I think plotting is always useful. But also, as @tomleslie pointed out, letting Maple do the definite integral gives immediately the correct answer - Maple is smart about understanding discontinuities and dealing with them. You can also use value() if you have an unevaluated integral (gray integral sign). For example:. 

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


@gtbastos Here are some thoughts.

There are some rejection tests you can do, for example if N is a power of M then they will commute, so if they don't commute there is no solution. Probably inspecting the eigenvalues is the best way, but if they aren't in the field then there is extra work as @Carl Love pointed out - he has a nice post about that here: https://www.mapleprimes.com/questions/203977-How-To-Find-Roots-Of-Polynomial-In-Finite#answer215097

You can do it more easily if both M and N happen to have only one root in the field -  then you can inspect all 5^9 powers of the eigenvalue of M to see which matches with the eigenvalue of N. If you can't factor at all, you can do the same thing with determinants - see attached - this takes only 15 seconds on my laptop. For determinants you may have to test more or revert to the full eigenvalue method. Is the maximum order of a matrix in the product group 5^9-1?

Both these methods can give false positives, so you then could test if the power you found actually works. A power of n or higher, where n is the matrix size, can be expressed as a linear combination of n-1 and lower powers, so that can be an efficient test (circumventing the discrete log problem to some extent). To test M^i, note the polynomial p_i(x) =q(x)p_M(x)+r(x), where p_i(x)=x^i, p_M(x) is the characteristic polynomial of M and q(x) and r(x) are the quotient and remainder when dividing x^i by p_M(x). If you take x=M in this polynomial, then p_M(M)=0 by Cayley-Hamilton, and M^i = r(M), so evaluate r(M) and see if it is N.



Shorthand for matrix multiplication in field G

`&*`:= (A::Matrix,B::Matrix)->LinearAlgebra:-Generic:-MatrixMatrixMultiply[G](A,B):

Set up field. Extension ex is polynomial of degree n that is irreducible mod p. GF will randomly choose one if not supplied, but supplying one makes t global and a little easier to work with.

ex:=Nextprime(t^n,t) mod p;






Matrix may be entered in integer form and then converted to internal form


iM := Matrix(3, 3, {(1, 1) = 98548, (1, 2) = 360142, (1, 3) = 206555, (2, 1) = 841913, (2, 2) = 414734, (2, 3) = 1740986, (3, 1) = 155301, (3, 2) = 596971, (3, 3) = 414440})

M := Matrix(3, 3, {(1, 1) = modp1(ConvertIn(t^7+t^6+t^5+2*t^4+3*t^3+t^2+4*t+3, t), 5), (1, 2) = modp1(ConvertIn(4*t^7+3*t^6+t^4+t^3+3*t+2, t), 5), (1, 3) = modp1(ConvertIn(2*t^7+3*t^6+t^5+2*t^3+2*t^2+t, t), 5), (2, 1) = modp1(ConvertIn(2*t^8+3*t^6+4*t^5+2*t^4+t^2+2*t+3, t), 5), (2, 2) = modp1(ConvertIn(t^8+t^6+2*t^5+3*t^4+2*t^3+4*t^2+t+4, t), 5), (2, 3) = modp1(ConvertIn(4*t^8+2*t^7+t^6+2*t^5+2*t^3+4*t^2+2*t+1, t), 5), (3, 1) = modp1(ConvertIn(t^7+4*t^6+4*t^5+3*t^4+2*t^3+2*t^2+1, t), 5), (3, 2) = modp1(ConvertIn(t^8+2*t^7+3*t^6+t^5+3*t^2+4*t+1, t), 5), (3, 3) = modp1(ConvertIn(t^8+t^6+2*t^5+3*t^4+2*t^2+3*t, t), 5)})

Try N = M^9

N:=M &* M: #M^2
N:=N &* N: #M^4
N:=N &* N: #M^8
N:=N &* M; #M^9

N := Matrix(3, 3, {(1, 1) = modp1(ConvertIn(t^8+t^7+2*t^6+t^5+t^2+t+1, t), 5), (1, 2) = modp1(ConvertIn(3*t^8+4*t^7+2*t^4+t^3+4*t^2+2*t+1, t), 5), (1, 3) = modp1(ConvertIn(3*t^7+2*t^6+2*t^5+2*t^4+t^3+t+2, t), 5), (2, 1) = modp1(ConvertIn(2*t^8+4*t^7+3*t^6+2*t^5+2*t^3+2*t+2, t), 5), (2, 2) = modp1(ConvertIn(3*t^8+t^7+4*t^5+4*t^3+t^2+4*t+3, t), 5), (2, 3) = modp1(ConvertIn(t^8+2*t^7+4*t^6+2*t^4+4*t^3+4*t+3, t), 5), (3, 1) = modp1(ConvertIn(t^8+4*t^7+4*t^6+3*t^5+3*t^2+1, t), 5), (3, 2) = modp1(ConvertIn(4*t^7+4*t^6+t^5+t^2+4*t, t), 5), (3, 3) = modp1(ConvertIn(3*t^8+3*t^7+4*t^6+3*t^5+3*t^4+3*t^3+3*t^2+4*t+4, t), 5)})

If they are powers then they should commute

EqualEntries(N &* M, M &* N);


Generate the determinants


modp1(ConvertIn(3*t^8+t^6+3*t^4+t^3+t+1, t), 5)

modp1(ConvertIn(t^8+2*t^6+4*t^5+4*t^4+t^3+2*t^2+2*t, t), 5)

Check all q-1 powers of the determinant of M to see if they match the determinant of N

for i to q-1 do;
  if G:-`=`(prod,dN) then print(i); end if;
end do:





Download GF.mw

@Carl Love OK, I see your point about the hard solve. Thinking about the eigenvalues sheds some light on how hard it will be to find a solution, even if it is not computationally efficient to evaluate them. Of course there are many ways to (partly) locate and decide the types of eigenvalues, which may mean you can decide there is no solution before you get to the hard solve. A trivial example would be that there will be no solution if M is singular but N is not. Not sure how Gershgorin disks and the like carry over for finite fields.

One ends up with more equations than unknowns. Perhaps it is easier to decide if the equation are incompatible and there is no solution than is is to try to solve them.


@Carl Love I'm not really serious about those, but it would be nice to get some clearer rules before I spend more time on this. If they are not OK I have a vague idea that 1 = 1/2 + 1/4 + 1/8 ... or similar series might form the basis of an infinite network solution.

@Joe Riel  But then the other three resistors have the same (zero) current. I suppose having one of the four unconnected with zero current is OK. But perhaps the problem doesn't insist on four resistors?

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