dharr

Dr. David Harrington

8837 Reputation

22 Badges

21 years, 122 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 replies submitted by dharr

@MaPal93 The rho_u case seems to have a positive solution, but when I substitute into EqN_rhou I don't find it is a solution. Perhaps the solution matches another version of EqN_rhou?

250523_SOLUTION_analytical2.mw

@MaPal93

"Does it mean that the quadratic solutions I obtain from the solver would be the same regardless of the assumptions on my variables and parameters (and only the roots to these quadratic equations depend on the assumptions)?" 

Yes, I do not think PolynomialSystem is using the assumptions and so you could (should) leave them out. In principle if you put them in, say by using RegularChains:-Triangularize directly (where you can just add them to the set of equations), and it could figure out that the quadratic did not have any positive solutions then it would not return the quadratic as a solution. I only tried RegularChains:-Triangularize once with inequalities and they seemed to slow it down so much I didn't wait for a solution, on a problem smaller than yours.

@MaPal93 In general, Maple doesn't handle assumptions particularly well, so I usually leave them out, or just add "assuming" clauses when I really need them. For solve itself, you need "useassumptions" as a solve option for the assuming clause to take effect - see the gamma file I uploaded for an example. For the polynomial systems if you look at RegularChains:-Triangularize that PolynomialSysyem is using, you can see how to more specifically add inequalities, but it might be faster to process them after as needed.

@MaPal93 Because a set cannot have duplicates, if you do a substitution that reduces nops from 3 to 2, then two of these equations became equal. (To see which are equal you could do the substitution on the individual equations and then compare them, by seeing if simplification of their differences was zero.)

I analysed the quadratic solution of the gamma equation, and found there are no all-positive solutions.

Edit: forgot the file:

220523_SOLUTION_reducedform_calibrations2.mw

@dharr the positive solution had lambda__1 = lambda__2 (some others did too). If there is some reason why this will be always true, then the system of 3 equations reduces to two, and can be solved extremely quickly with solve.

EqN2.mw

@MaPal93 I agree with your analysis, that the 5th solution has a unique positive solution, and that the first solution has an inifinite number of real solutions but none are positive. 

For the discriminant solving for when it is zero for a quadratic finds one real root, but positive discriminant gives other real roots. (In the general case it is zero if and only if a polynomial has roots of multiplicity greater than 1.)

Edit: note that solution 1 is just the common factor.

@davimon L^2 + L - (element in G) = 0 is still a polynomial with coefficients in G, so can be solved the same way.

restart

pr := T^4+T+1; alias(alpha = RootOf(pr))

T^4+T+1

rts := `mod`(Roots(lambda^2+lambda-alpha-1, alpha), 2)

[[alpha^3+alpha^2, 1], [alpha^3+alpha^2+1, 1]]

NULL

Download GF24solve2.mw

@dharr 

restart

p := 2; k := 4

2

4

pr := `mod`(Nextprime(T^k, T), p)

T^4+T+1

G := GF(p, k, pr)

_m2868928204704

Choose a number and square it

"use G in     b:=input(14);     c:=b^(2);  end use;"

modp1(ConvertIn(T^3+T^2+T, T), 2)

modp1(ConvertIn(T^3+T+1, T), 2)

Now take the square root by solving x^2-c

alias(alpha = RootOf(pr, T))

alpha

`mod`(Factor(x^2-alpha^3-alpha-1, alpha), 2); rts := `mod`(Roots(x^2-alpha^3-alpha-1, alpha), 2)

(alpha^3+alpha^2+alpha+x)^2

[[alpha^3+alpha^2+alpha, 2]]

Back to modp1 form

G:-ConvertIn(subs(alpha = T, rts[][1]))

modp1(ConvertIn(T^3+T^2+T, T), 2)

NULL

Download GF24solve.mw

@davimon Sorry, I was working with your code outside the procedure. Outside the error message is that lambda is not a number in the field. Inside I don't really understand the error message. Usually I would use "uses packagename;"  in a procedure, but the GF package doesn't lend itself to this usage easily.

(See above edit, but I'm not sure yet how it applies to your case). But for sure solve is not going to work for your problem. [Edit -see below for how to this]

@davimon G has only numbers and does the field operations on them, it doesn't have variables. Solving lambda^2-(number in G) = 0 means solving a polynomial whose coefficient field is G. 

Edit: Factor and other commands can handle Galois Fields (but this isn't done through the G:-GF() construct.) From the Factor help page: "The call Factor(a, K) mod p and computes the factorization of the polynomial a over the Galois field (finite field) defined by the algebraic extension K over the integers mod p a prime integer. The extension K is specified by a RootOf and must be irreducible over the integers mod p."

p.s., the usage is

use G in 
c:=b^2
end use;

@MaPal93 

Let me be clear about my goal. I am looking for a (i) closed-form, (ii) real, and (iii) positive solution. Even just one solution satisfying all three constraints would be fantastic.

Now, it seems that sol[1] (2 equations in the lambdas) and sol[5] (3 equations in the lambdas) do not look weird and are the most promising for further analysis.

sol[2..5] all involve solutions of high degree polynomials, which in general do not have solutions in terms of radicals. So when you put your parameters in, you will not likely get symbolic solutions. So sol[1], which is surprisingly just a quadratic is your best chance. 

However, for the case with all parameters =1, an exhaustive analysis proves that there are no positive solutions for any of the 5 cases:
triade.mw

My questions:

1) How did you find the unique and real but negative lambdas from sol[5]?

In each case, you solve the third equation for lambda__1, substitute it into the second equation and solve it for lambda_2 and then substitute these solutions into the first equation and solve for lambda__3 (this is the backsubstitution on the triangularized system). See details in the file above. 

2) You showed me one example in which also sol[1] produces a real but negative solution. In the same comment you mentioned "but real and positive is harder". Why is it the case? If mathematically real and positive solutions are not ruled out a priori, is there a more systematic way to find them? (even just a loop which tries many substitutions and stops as soon as we find one would do, I guess?)

I did it in detail on the attached. With parameters it will be harder, but some things can help in this sort of analysis, Descartes rule of signs etc.

3) It's not clear to me the benefit of dividing out the common factor in the system with all parameters normalized to 1 (since we already found solutions and, factorized or not, these solutions would be the same). The benefit would be clear if such removable common factor existed in the uncalibrated equations EqN := ((numer@evala@:-Norm@numer)'tilde'@eval)(MyEqs). How to verify this possibility?

I agree. I assume factorizing before solving speeds up the solution process. Factorizing may not work with parameters but you can try the factor() command to see.

4) Surely a naive question, but would a solution found as in 2) solve also the uncalibrated system? That is, would simplify(eval(EqN,sol)) still give me 0 for EqN := ((numer@evala@:-Norm@numer)'tilde'@eval)(MyEqs) instead of EqN := ((numer@evala@:-Norm@numer)'tilde'@eval)(MyEqs,P='tilde'1)?

Seems very unlikely.

5) Related to 4). My end goal is to study how lambda_1, lambda_2, and lambda_3 vary with my parameters. Is it legit to pick a real and positive lambda_2 and lambda_3 (found as in 2)) and plug them back into uncalibrated EqN[1] (and solve for lambda_1), then pick lambda_1 and lambda_3 and plug them back into uncalibrated EqN[2] (and solve for lambda_2), finally, pick lambda_1 and lambda_2 and plug them back into uncalibrated EqN[3] (and solve for lambda_3)? See my original script 160523_stylized_triade.mw: the first equation is for lambda_1, second for lambda_2, and third for lambda_3.

I'm not sure I understand this, but in general the solution for all parameters=1 is not going to generalize to the case with parameters.

Really thank you for helping me out with this.

You're welcome. There are some interesting symmetries that might help you, For example EqN[2] and EqN[3] are the same if lambda__1 and lambda__2 are exchanged (and this was true for sol[1].) Is this expected?

@MaPal93 I looked again at the solutions, and many will be roots of high-degree poynomials that have no closed form. Given that, I don't think backsubstitute=true will help. You can analyse to find when there might be real or positive roots. For example, the polynomial in the fifth solution has only one real solution, which is negative, so lambda_1 = lambda_2 =-0.41 and lambda_3 = -0.82. No positive solutions. Here is the solution with the common factor removed

factored.mw

@dharr For the EqN for all parameters 1, the three equations have a common factor, that can be divided out so that you could work on solving a simpler system. If this still works with parameters in, that could afford a considerable simplification. 

@MaPal93 In general, I expect the solvability to depend on the parameters. This seems like a very complicated problem with too many parameters - how about solving a simpler version of the problem with a smaller set of parameters first? But if I were doing this problem I would step back and analyze the matrices. Are lambda's eigenvalues? if so a lot can be said about their possible values depending on the structure of the matrix of which they are eigenvalues, e.g., we know many classes of matrices that are guaranteed to have one or more real eigenvalues.

@dharr For solution 1 you can find real solutions as follows (but real and positive is harder). 

restart

EqN in startup code.

Since most lambda__1  and lambda++2 work, you can look at the solution as a quadratic in lambda_3

sol1 := [[((2*`&lambda;__1`+1)*`&lambda;__2`+`&lambda;__1`)*`&lambda;__3`^2+((2*`&lambda;__1`+1)*`&lambda;__2`^2+(2*`&lambda;__1`^2-6*`&lambda;__1`+2)*`&lambda;__2`+`&lambda;__1`^2+2*`&lambda;__1`)*`&lambda;__3`+4*`&lambda;__2`^2*`&lambda;__1`+(4*`&lambda;__1`^2+8*`&lambda;__1`)*`&lambda;__2`], {(2*`&lambda;__1`+1)*`&lambda;__2`+`&lambda;__1` <> 0}]

[[((2*lambda__1+1)*lambda__2+lambda__1)*lambda__3^2+((2*lambda__1+1)*lambda__2^2+(2*lambda__1^2-6*lambda__1+2)*lambda__2+lambda__1^2+2*lambda__1)*lambda__3+4*lambda__1*lambda__2^2+(4*lambda__1^2+8*lambda__1)*lambda__2], {(2*lambda__1+1)*lambda__2+lambda__1 <> 0}]

p := collect(sol1[1][], `&lambda;__3`)

((2*lambda__1+1)*lambda__2+lambda__1)*lambda__3^2+((2*lambda__1+1)*lambda__2^2+(2*lambda__1^2-6*lambda__1+2)*lambda__2+lambda__1^2+2*lambda__1)*lambda__3+4*lambda__1*lambda__2^2+(4*lambda__1^2+8*lambda__1)*lambda__2

d := discrim(p, `&lambda;__3`)

4*lambda__1^4*lambda__2^2+8*lambda__1^3*lambda__2^3+4*lambda__1^2*lambda__2^4+4*lambda__1^4*lambda__2-52*lambda__1^3*lambda__2^2-52*lambda__1^2*lambda__2^3+4*lambda__1*lambda__2^4+lambda__1^4-20*lambda__1^3*lambda__2-42*lambda__1^2*lambda__2^2-20*lambda__1*lambda__2^3+lambda__2^4+4*lambda__1^3-52*lambda__1^2*lambda__2-52*lambda__1*lambda__2^2+4*lambda__2^3+4*lambda__1^2+8*lambda__1*lambda__2+4*lambda__2^2

Real solutions when discriminant is zero

ans := solve(d, `&lambda;__2`)

-(lambda__1+2)/(2*lambda__1+1), -lambda__1, (-lambda__1^2+(lambda__1^4-32*lambda__1^3+222*lambda__1^2-32*lambda__1+1)^(1/2)+15*lambda__1-1)/(2*lambda__1+1), -(lambda__1^2+(lambda__1^4-32*lambda__1^3+222*lambda__1^2-32*lambda__1+1)^(1/2)-15*lambda__1+1)/(2*lambda__1+1)

example

sol := {`&lambda;__1` = 1}; sol := `union`(sol, {`&lambda;__2` = (eval(ans, sol))[3]}); sol := `union`(sol, {`&lambda;__3` = solve(eval(p, sol), `&lambda;__3`)[2]}); simplify(eval(EqN, sol))

{lambda__1 = 1}

{lambda__1 = 1, lambda__2 = 13/3+(1/3)*160^(1/2)}

{lambda__1 = 1, lambda__2 = 13/3+(1/3)*160^(1/2), lambda__3 = -2*(13+4*10^(1/2))/(2*10^(1/2)+7)}

{0}

 

Download EqNsol.mw

First 52 53 54 55 56 57 58 Last Page 54 of 95