Dr. David Harrington

1375 Reputation

13 Badges

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

@lak Sorry, I don't give help outside this forum, but there is lots of good help here. 

The NullSpace command in the LinearAlgebra package will be useful here.

@vv For a system where all the parameters are within a few orders of magnitude of unity, it makes sense to interpret something like 10^(-18) as just a numerical zero and not significant. However, here the equilibrium constants are very far from 1, and so we expect some concentrations to be very small. So for a well-posed physical problem, there will be a unique physical solution with positive concentrations among other nonphysical solutions with some negative concentrations.

For the three independent reactions here if we neglect interactions betweem molecules (set all the u_X variables to 1), then the first 6 equations will have a unique physical solution in which we expect the concentrations of H+ and OH- and the ion-pair HCl to be very small.

The other equations are about the interactions between molecules and mean that the u_X quantities depart from 1, but not by that much - see the plot. These are empirical equations and need not be physically self-consistent, and can lead to there being no solution at all in the physical regime. On the other hand if the solution is comparable to the one for eqns 1-6 with the u_X =1, which seems to be the case here though I didn't check it quantitatively, then there is good reason to think that the solution is physical and that the small positive concentrations are not just numerical zeroes.

@kfli I realised that if you have a dc component, then you don't use a factor of two for that, which gives the clue to its origin.

Only the first half of the frequencies are used because, for transformation of a real signal, the second half of the frequencies have redundant information - the real parts are symmetric and the imaginary parts are antisymmetric with respect to the centre frequency. (The second half of the frequencies can be considered negative frequencies or duplicates). So if you look only at the first half you need a factor of two to account for the second half that you neglected. But the dc component does not have a matching part in the second half and so doesn't need a factor of 2. (The Nyquist frequency also does have a matching frequency, must be purely real, and does not require the factor of 2

@vv @mmcdara

The following code cuts down by n!*(n-1)! by cutting down permutations of the columns and then permutations of the rows except the first. The Iterator package would be better for faster code but I didn't try it.  There are some known results about diagonal dominance and invertibility that might help out but I'm guessing that testing for these would still be non trivial.

S    := 0:
n    := 3;
N    := n^2:
COMB:=choose(N,n): #combinations for first row
for comb in COMB do
  COMB2:=choose(clist,n-1);  #combinations for rest of first column
  for comb2 in COMB2 do
    PERM:=permute(plist);   # permutations of the rest  
    for perm in PERM do
      if LinearAlgebra:-Determinant(M)=0 then S := S+1; end if:
    end do:
  end do:
end do:


@nrussoniello Here's an example. The 1,1 entry is zero because it has to be for an antisymmetric matrix, and the shape=antisymmetric also forces the 1st column entries when the first row is inserted.



A := Matrix(4, 4, {(1, 2) = -77, (1, 3) = -98, (1, 4) = 33, (2, 3) = 87, (2, 4) = -18, (3, 4) = -38, }, storage = triangular[upper,strict], shape = [skewsymmetric])


S := Vector[row](4, {(1) = s1, (2) = s2, (3) = s3, (4) = s4})



Matrix([[0, s1, s2, s3, s4], [-s1, 0, -77, -98, 33], [-s2, 77, 0, 87, -18], [-s3, 98, -87, 0, -38], [-s4, -33, 18, 38, 0]])



Download Border.mw

@nrussoniello Yes, the entries of the matrix are not what they seem (see attached) - there is a lot of hidden stuff there. Even the "-" in -e3 and the "-" in e2 - e1 are not the same. The differential algebra package sets up its own environment in a very compilcated way.


OK, assuming the Matrix is always antisymmetric, then this works as a conversion process from L to the matrix, assuming i understand the coding in L


op(op(L))[2] gives the list below - need to convert it to an antisymmetric matrix

LL:=[[[1, 3, 3], -1], [[1, 4, 4], 1], [[2, 3, 3], 1], [[2, 4, 4], -1], [[3, 4, 1], -1], [[3, 4, 2], 1]];

[[[1, 3, 3], -1], [[1, 4, 4], 1], [[2, 3, 3], 1], [[2, 4, 4], -1], [[3, 4, 1], -1], [[3, 4, 2], 1]]


[[1, 3] = -s3, [1, 4] = s4, [2, 3] = s3, [2, 4] = -s4, [3, 4] = -s1, [3, 4] = s2]

Need to add duplicates

for i in t do
end do:

table( [( 1, 4 ) = s4, ( 3, 4 ) = -s1+s2, ( 2, 3 ) = s3, ( 1, 3 ) = -s3, ( 2, 4 ) = -s4 ] )


CI := Matrix(4, 4, {(1, 2) = 0, (1, 3) = -s3, (1, 4) = s4, (2, 3) = s3, (2, 4) = -s4, (3, 4) = -s1+s2, }, storage = triangular[upper,strict], shape = [skewsymmetric])





Download LieMatrix.mw

@nrussoniello  The rank looks OK to me. The zero pattern means that columns 1, 2, 4, and 5 are linearly independent. Columns 2 and 3 have the same zero pattern, but are independent since the first entries have different variables (e1 vs e2). Note that Maple views the rank in the general case, for example there may be specific values of the variables that reduce the rank, e.g. e1=e2, but assuming thay all have arbirary unrelated values, the rank seems OK.

Maybe I've missed something - which dependence do you think there is between columns  (or rows)?

@gawati2611 Sorry, I misunderstood your zig-zag order. But still I don't know what you want. Do you want a function that produces two indices i and j from the zig-zag order single digit, or a function that takes i and j and produces the single digit? I can't imagine what you would do with that other than just fill arrays always with the same numbers, in which case you are presumably happy with @acer's filling method.

@Umang Varshney To add to Tom's comment, the palette entry an with the same color is a__n in 1-D, and that means the n has no special significance, it just appears as a subscript; the palette entry with two colors is a[n], where the n has some special significance, e.g,, the nth entry of a Vector or list.

The same is true for the layout panel. To see what is happening, you can just use a 1-D prompt (ctrl-M) and see what happens when you click on the layout or expression entry.

If you just want to fill in row order, you can supply a list of entries. To access in row order, you can use programmer indices (in parentheses ()) provided the matrix has order=C_order.


A := Matrix(3, 3, {(1, 1) = 1, (1, 2) = 4, (1, 3) = 9, (2, 1) = 16, (2, 2) = 25, (2, 3) = 36, (3, 1) = 49, (3, 2) = 64, (3, 3) = 81}, order = C_order)







Download Indexing.mw


Suggest you upload a worksheet trhat produces the multiplication table, and then it will be easier to undestand what you want converted to a Matrix. Use the fat green up arrow.

@ianmccr Thanks. I figured most of the stuff out by trial and error. You prompted me to post it in the hope it might help others. It is in a suboptimal state - I had always been meaning to tidy up the code and post it, but never got the time. 

@Anthrazit  I don't have the right version to really comment specifically about your document (On your earlier document, I saw strange behaviour that I didn't understand, including the datatable extending briefly and then returning.) A long time ago, I wrote an app with datatables extending and reducing as required, and there was no problem - http://web.uvic.ca/~dharr/software/statmech/ I don't have any expectation that the size of the array and the number of visible columns or rows will automatically track each other - I always put the code to extend the array and to increase the visible columns together, and usually within a button code.

I do recall that forcing updates can sometimes be an issue, as @acer pointed out,

@Anthrazit  When I run that Document it leaves the number of visible columns at 1.

Adding the line SetProperty("DataTable0",VisibleColumns,8); at the end of the worksheet I uploaded before works consistently as I change the number of columns. I don't use document mode; maybe it is to do with that or a version issue (I'm using Maple 2017).

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