dharr

Dr. David Harrington

8235 Reputation

22 Badges

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

Your worksheet is quite complicated, so maybe you can give some more information about the matrix or provide a simpler example. In particular, are all the entries numeric? is it sparse? Without that information, I can make only the general suggestion

You want FF3 = FF2^(-1).FF1

In general, finding the matrix inverse is bad practice here - you should just solve FF2.FF3=FF1 for the unknown matrix FF3.

Just call LinearSolve with A=FF2 and B=FF1:

FF3 := LinearAlgebra:-LinearSolve(FF2,FF1);

Things will be slow for Digits=30. If you can use Digits less than evalhf(Digits) (usually 15), then the numerical computations will be done in hardware and will be much faster.

Since a=a means any a is acceptable, and you want a>0, then a=a,b=0,c=0 and d=d is not a solution. But any d is OK, so I think a>0,b=0,c=0,d=d is a missing solution.


 

restart;

eqns:=[a>0,b*d*(abs(c)^2-abs(a)^2) = 0, -a*c*(abs(b)^2-abs(d)^2) = 0, -abs(b)^2*a*d+abs(d)^2*b*c = 0, abs(c)^2*a*d-abs(a)^2*b*c = 0];

[0 < a, b*d*(abs(c)^2-abs(a)^2) = 0, -a*c*(abs(b)^2-abs(d)^2) = 0, -abs(b)^2*a*d+abs(d)^2*b*c = 0, abs(c)^2*a*d-abs(a)^2*b*c = 0]

solve(eqns, {a, b, c, d});

{b = 0, c = 0, d = 0, 0 < a}, {b = 0, c = a, d = 0, 0 < a}, {b = d, c = a, 0 < a, 0 < d}, {b = 0, c = -a, d = 0, 0 < a}, {b = -d, c = -a, 0 < a, d < 0}, {b = d, c = a, 0 < a, d < 0}, {b = -d, c = -a, 0 < a, 0 < d}

eval(eqns,{b=0,c=0});

[0 < a, 0 = 0, 0 = 0, 0 = 0, 0 = 0]

 


 

Download ineq.mw

There is only one value for each element. According to ?ScientificConstants,properties, "for those elements with several solid forms, the density is of the most stable crystal form". This is the usual convention for thermodynamic tables, where the most stable allotrope is the standard form (one with the enthalpy of formation defined as zero). The exception is phosphorus, where white phosphorus is the standard form, even though red phosphorus is more stable (because the red phosphorus structure is not well defined). In Maple too, the phosphorus density given is that for white phosphorus (in contrast to the help statement).

nops of a Vector is always 3 - you want numelems here.

As in the help page, Maple outputs the normal form without the D. As per the Wikipedia page, the D can be found from L by taking the squares of the diagonal entries. Following the prescription there, if L is the matrix from Maple's output:

S := DiagonalMatrix([seq(L[i, i], i = 1 .. Dimension(L)[1])]);

D:=S^2;

New L:

Lnew:=L.S^(-1);

 

 

Following Carl's suggestion, the algorithm seems to give eigenvectors with the symmetry you want, except for those corresponding to the pair of zero eigenvalues, and the matrix of eigenvectors produced is orthogonal (as expected for a symmetric matrix). Furthermore the eigenvectors corresponding to the zero eigenvalues both seem to have their 2nd half entries the negative of the first half entries (see below for an example), say [x,-x] and [y,-y] (this is sloppy notation for column vectors stacked above each other).

Now the only possibility is that there are linear combinations of the eigenvectors for the zero eigenvalues that have the symmetry you want. Now any linear combination of [x,-x] and [y,-y] is [z,-z] and so any two orthogonal linear combinations must be [z,-z] and [z2,-z2]. But you want these [v1,v2] and [v2,v1] which can only occur if v2=-v1 so [v1,-v1] and [-v1,v1]. But these are multiples of each other and so not linearly independent.

Perhaps I'm missing something, but are you sure that this is possible?

restart;with(LinearAlgebra):

A:=Matrix(4,4,shape=symmetric,[[2],[3,3],[5,1,0],[6,2,-1,0]]);
B:=Matrix(4,4,shape=skewsymmetric,[[1],[0,2],[5,1,0],[1,-2,1,2]]);
Rank(A);Rank(B);

A := Matrix(4, 4, {(1, 1) = 2, (1, 2) = 3, (1, 3) = 5, (1, 4) = 6, (2, 2) = 3, (2, 3) = 1, (2, 4) = 2, (3, 3) = 0, (3, 4) = -1, (4, 4) = 0}, storage = triangular[upper], shape = [symmetric])

B := Matrix(4, 4, {(1, 2) = 0, (1, 3) = -5, (1, 4) = -1, (2, 3) = -1, (2, 4) = 2, (3, 4) = -1, }, storage = triangular[upper,strict], shape = [skewsymmetric])

4

4

If the Matrix is specified with shape=symmetric, then the algorithm produces eigenvalues that are sorted, and a matrix of eigenvalues that is orthogonal

The eigenvectors have the required symmetry except for the ones corresponding to the zero eigenvalues, which are each of the form [x,-x]^T

M:=Matrix(shape=symmetric,<<A|B>,<-B|-A>>,datatype=float[8]);
evalsM,U:=Eigenvectors(M):
map(fnormal,evalsM);
U;

Typesetting:-mrow(Typesetting:-mi("M", 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%"5m"pW>uSuY%=-I'MATRIXG6"6#7*7*$""#""!$""$""!$""&""!$""'""!$""!""!$""!""!$!"&""!$!""""!7*$""$""!$""$""!$"""""!$""#""!$""!""!$""!""!$!""""!$""#""!7*$""&""!$"""""!$""!""!$!""""!$""&""!$"""""!$""!""!$!""""!7*$""'""!$""#""!$!""""!$""!""!$"""""!$!"#""!$"""""!$""!""!7*$""!""!$""!""!$""&""!$"""""!$!"#""!$!"$""!$!"&""!$!"'""!7*$""!""!$""!""!$"""""!$!"#""!$!"$""!$!"$""!$!""""!$!"#""!7*$!"&""!$!""""!$""!""!$"""""!$!"&""!$!""""!$""!""!$"""""!7*$!""""!$""#""!$!""""!$""!""!$!"'""!$!"#""!$"""""!$""!""!I'MatrixG6$%*protectedGI(_syslibG6""))

Vector[column]([[-13.06479065], [-7.478956942], [-1.541573335], [-0.], [0.], [1.541573335], [7.478956942], [13.06479065]])

Matrix([[.372087728267745, .442146960077929, 0.716552864407905e-1, -.121514458204212, .443710091875770, -.113015584183814, -.281846512162814, -.597551604649895], [-0.289133379852268e-1, 0.744724933588056e-1, -.365636713581575, .138873666519100, -.507097247858023, .502871793286012, -.509625534715401, -.266262877897865], [-.384750443216120, -.167445910347510, .262811302437603, -.708033369242197, -0.916903144690217e-1, .262811302437604, .167445910347510, -.384750443216120], [-.230331010247727, -.518003132670884, -.189283799017428, 0.123994345106340e-1, -0.452765399873239e-1, -.649272541315961, -.367968422739513, -.289193221914421], [.597551604649894, -.281846512162814, .113015584183814, .121514458204211, -.443710091875770, -0.716552864407900e-1, .442146960077928, -.372087728267744], [.266262877897865, -.509625534715401, -.502871793286012, -.138873666519099, .507097247858024, .365636713581574, 0.744724933588058e-1, 0.289133379852270e-1], [.384750443216120, .167445910347510, -.262811302437605, -.655955744297534, -.281851782415781, -.262811302437604, -.167445910347509, .384750443216120], [.289193221914421, -.367968422739513, .649272541315960, -0.123994345106347e-1, 0.452765399873234e-1, .189283799017428, -.518003132670884, .230331010247727]])

map(fnormal,Transpose(U).U); #U is orthogonal

Matrix([[1.000000000, 0., -0., -0., 0., 0., -0., 0.], [0., 1.000000000, -0., 0., 0., -0., 0., -0.], [-0., -0., 1.000000000, -0., -0., -0., -0., -0.], [-0., 0., -0., 1.000000000, -0., 0., -0., 0.], [0., 0., -0., -0., 1.000000000, -0., -0., 0.], [0., -0., -0., 0., -0., 1.000000000, -0., 0.], [-0., 0., -0., -0., -0., -0., 1.000000000, 0.], [0., -0., -0., 0., 0., -0., 0., 1.000000000]])

map(fnormal,Transpose(U).M.U); #similarity gives the diagonal matrix of eigenvalues

Matrix([[-13.06479065, -0., 0., 0., -0., 0., 0., -0.], [-0., -7.478956942, 0., -0., 0., -0., -0., 0.], [0., 0., -1.541573335, 0., 0., -0., 0., -0.], [0., -0., 0., 0., -0., 0., -0., -0.], [-0., 0., 0., -0., 0., 0., -0., -0.], [0., -0., -0., -0., 0., 1.541573335, -0., -0.], [0., -0., 0., -0., -0., -0., 7.478956942, 0.], [0., 0., -0., -0., -0., -0., 0., 13.06479065]])

 

 


 

Download SymmetryEigenvectors2.mw

Edit: Note that NullSpace(M) also gives eigenvectors of the form [x,-x], so the above isn't an artifact related to the fact that the two eigenvalues are small but not exactly the same.

Use Pi not pi for the mathematical constant 3.1416...; pi is just a symbol without a value. The Greek palette gives Pi not pi. 

Move from Text to Math and then choose 2D Math (not 2D Math input), as shown above.

@Rouben Rostamian's answer has the details. Explore allows you to easily vary y and see what happens to the plot. If you do this to the derivative, you see where the zeroes are:

Explore(plot(diff(x^2+y*(1-x)^(3/4),x),x=0..1),y=0..2.0);

or you can look at the plot and its derivative together:

f:=x^2+y*(1-x)^(3/4):Explore(plots:-display(<plot(f,x=0..1)|plot(diff(f,x),x=0..1)>),y=0..2.0);
 

firint in the DEtools package can calculate first integrals, which may be helpful. For your second order ode, it successfully produces a first order ode.

As I indicated to the OP on the other thread, if fsolve doesn't find an answer, it returns NULL (as in the response by @tomleslie) or unevaluated (as in the response by @mmcdara). If you want to test for both these possibilities, then you want

ans:=fsolve(x=x+1,x);

if ans=NULL or op(0,ans)=`fsolve` then "no" end if;

Note this handles also the multivariable case, where a valid solution won't just be a number or sequence of numbers, but something like {x=1, y=3}.

Testing NULL output from fsolve should work here, though sometimes fsolve just returns unevaluated.

Seems to me it is working, just fsolve is really slow. You can speed it up by using the last solution as the initial estimate (but convergence of your outer loop is still really slow).

Try

Q[h+1] := fsolve(eval(f[3], {R = R[h], S = S[h]}) = 0, Q = Q[h]);
if Q[h+1] = NULL then print("breakQ"); break end if;

 

If you work out Theta[k] and Phi[k] for k=2 nd 3, then you can use a single loop from 4 to M for Theta[k], Phi[k], F[k]. (I shouldn't really cut and paste to duplicate lines here.)

Solution_1-dharr.mw

 

as @mmcdara pointed out, you van specify ranges in which to search for solutions. You can also use the avoid option to not get the same solution, e.g. after ans1:=fsolve({f, g}); you can use fsolve({f, g},{x,y},avoid=ans1); to get the second solution.

plots:-complexplot(exp(I*theta),theta=0..2*Pi);

First 66 67 68 69 70 71 72 Last Page 68 of 81