Dr. David Harrington

1018 Reputation

13 Badges

15 years, 218 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

@acer @nm This is often (usually) a hidden file.

@acer I like to let the OP do some of the work :-). My variation would have been to solve some eqns:

Gc := (s^2*t^2+2*s*t*x+1)*(-b*s+1)/(k*(-b*s+1)*s*(t*c+b));





{A = 2*t*x/(k*(c*t+b)), A/B = 1/(k*(c*t+b)), A*C = t^2/(k*(c*t+b))}


{A = 2*t*x/(k*(c*t+b)), B = 2*t*x, C = (1/2)*t/x}






Download parfrac.mw

@AntoineR Looks like you may have used 2-D input. From your original post, I added multiplications after k, the last s and between t and c. If the first two are omitted, Maple thinks that they are functions f() and s() and so does not think that you have a rational function. In 2-D input use a space or * to distinguish multiplication from functions.

@dharr and to get the coefficients you can use

coeff(Gc2,s,0); coeff(Gc2,s,1); coeff(Gc2,s,-1);

(can't seem to edit my post).

@Joe Riel  Of course I agree the help page is confusing. At one point, it says that all entries of an rtable are "scanned" (as opposed to all opererands), and later that for sparse rtables only the nonzero ones are "scanned", so they can't both be correct.

But I expect (1) any mathematical operation on an rtable to give the same result, whether sparse of not, and (2) some algorithmic efficiencies  may be be applied if it is sparse.

So I think the first point (and the first usage of scan in terms of all entries) means I expect to see seq return the number of elements of the rectangular size. In the case of mul (which has the same strange wording about "scan"), mul(V) returns 0, (as I expect) - it involves the same result as if non sparse, and must involve more that just the stored entries.

I took the second usage of scan (that for sparse rtables only the non-zero entries are scanned), to be associated with the second point, that somehow seq uses a more efficient algorithm, and can be faster because it doesn't attempt to access the non-zero entries. 

But perhaps this is just me being optimistic that there is some resonable meaning behind the second usage (that @vv pointed to as strange)...


@eslamelidy You keep changing the worksheet so each seems unrelated to the previous ones, so suggest you start a new post. The error meesage is telling you there is a singularity, so you can only solve up to just before that point, so you need to look at the equations and figure out why - that is a math question and not a Maple question.

@vv Thanks for the improvement. I did expect there to be duplicates, but mainly because the role of the "permutation matrix" 1s and the "extra 1s" could be reversed. Removing duplicates in this case does produce 40320 = 8*7!.

There are other things that could be checked. For example, if there is a 1 on the diagonal, then there must be an extra 1 in that column and an extra 1 in that row ("guard 1s") to prevent the diagonal element being exposed as eigenvalue (which would make the polynomial reducible). In fact for the polynomial given, since the trace must be 1, and there are only two extra 1s, I could devise a more efficient scheme, though it wouldn't be general.

@dharr Thanks for the update. In the meantime, I figured out how to test this case exhaustively in about an hour, assuming I haven't made a logic error. I'll post it as an answer after I tidy it up and rerun it.

@Magma It is interesting, but perhaps not surprising that the coefficients make a big difference. (I have a hard time thinking about what carries over in the field case from regular matrices.) In your second case the coefficient of x^7 is zero, so the trace is zero, which implies an even number of 1's on the diagonal. So that is quite different from the coefficient of x^6 being zero, which is related to sums of products taken two at a time.

I agree with @vv that using theoretical ideas to limit things might make it tractable to search various subclasses, If you are interested in the general problem, why not start with smaller matrices than 8x8, in which you can do exhaustive tests.

A lot also depends on whether you are interested in the number of solutions, which is in general a hard problem, or just finding examples.

@radaar My code was not Metropolis and is not much use without the whole project. But basically I used

Statistics:-Sample(Statistics:-RandomVariable(Normal(0,sdev)),nfreqs) in a loop (I wanted Normal distribution)

Note that if you rerun a worksheet you get the same numbers, but you can use randomize() to get different numbers every time you run the worksheet. The actual sequence is very long.

@Magma You say "and also the determinant of A should be non-zero" but I'm not clear whether than means it follows automatically or it has to be another test.

I would have thought if you have an irreducible polynomial of degree n which doesn't have zero as a root (such as the one you gave), then the determinant is automatically going to be nonzero? So you only have to test if the characteristic poiynomial is equal to the required polynomial, and then you are done (or could do the determinant test only when the polynomials match to improve efficiency).


@radaar I recently used the Statistics method for a Monte Carlo method of estimating parameter errors in nonlinear regression and it seemed to work well. 

But I don't understand - your timing tests suggested it was faster than rand() and now you are saying rand is faster? Any of them can be used for Metropolis, surely.

Why don't you think the Statistics package method is random? This is what I would use.

Nice worksheet!

To simplify the log of the product to a sum you need to tell Maple N::posint (not just integer). The following works:

LL := expand(log(L)) assuming positive;

I'm assuming in the first part you didn't want to use the Statistics package, but to avoid typing errors for the PDF, I might have done


@Magma A final suggestion might be to look into the literature on totally positive matrices (all minors nonnegative) or strictly totally positive matrices (all minors positive), where there are improvements on how many determinants you need to check - for example you only need check n^2 minors for totally positive matrices, not all of them. These originate in relationships between various determinants, which might help for the MDS case though it seems the MDS case will likely be more difficult. On the other hand, all strictly totally positive matrices are MDS, so if you just want to find some MDS matrices, this might be helpful.

A good starting point is J. Pen~a, SeMA Journal, 62 (2013) 61. 


3 4 5 6 7 8 9 Last Page 5 of 15