I am trying to solve a set of 6 equations in 6 unknowns using NSolve and I am only interested in solutions with real values not complex values.
As I investigate this area of interest with a sequence of increasing complexity of equations, I find there was only a few solutions with 3 equations/3 unks then many more with 4 eqns/4 unks (with many complex solutions) and at 5 eqns/5 unks 2 separate real solutions (only the 1st one was appropriate to my interest and to many complex solutions to list. But I could get a response. The first real “answer” was the one I was looking for.
When I go to 6 eqns/6unks I can’t seem to get any response even after over 24 hours of “running time”. How do I instruct NSolve to ignore complex solutions so I can examine the real ones – and get an answer is short time.
Here is the NSolve problem I am working.
NSolve[{a + a b + a^2 c + a^3 d + a^4 f + a^5 h == 1, b^2 + 2 a b c + 3 a^2 b d + 4 a^3 b f + 5 a^4 b h == 1,
b c + b^2 c + 2 a c^2 + 3 a b^2 d + 3 a^2 c d + 6 a^2 b^2 f + 4 a^3 c f + 10 a^3 b^2 h + 5 a^4 c h == 1/2,
2 b c^2 + b d + b^3 d + 2 a c d + 6 a b c d + 3 a^2 d^2 + 4 a b^3 f + 12 a^2 b c f + 4 a^3 d f + 10 a^2 b^3 h + 20 a^3 b c h + 5 a^4 d h == 1/6,
c^3 + 2 b c d + 3 b^2 c d + 3 a c^2 d + 6 a b d^2 + b f + b^4 f + 2 a c f + 12 a b^2 c f + 6 a^2 c^2 f + 3 a^2 d f + 12 a^2 b d f +
4 a^3 f^2 + 5 a b^4 h + 30 a^2 b^2 c h + 10 a^3 c^2 h + 20 a^3 b d h + 5 a^4 f h == 1/24, 2 c^2 d + 3 b c^2 d + 3 b^2 d^2 + 6 a c d^2 + 2 b c f + 4 b^3 c f + 12 a b c^2 f + 6 a b d f + 12 a b^2 d f + 12 a^2 c d f + 12 a^2 b f^2 + b h + b^5 h + 2 a c h + 20 a b^3 c h + 30 a^2 b c^2 h + 3 a^2 d h + 30 a^2 b^2 d h + 20 a^3 c d h + 4 a^3 f h + 20 a^3 b f h + 5 a^4 h^2 == 1/120}, {a, b, c, d, f, h}]
Thank you Frank. That was easy but I haven’t seen it work yet. After 48 hours I still don’t have any solutions showing to my 6 eqns NSolve problem. Do you know of any way to make it produce “periodic” outputs just to see how convergence is going? I hate just waiting and waiting and not knowing how the solution is proceeding (it hasn’t said no solution yet – and I have actually done it manually in a few hours but I want to confirm my approach ) – if I could get 14-15 decimals places I would be happy.
Is there any chance that this solution, which took three seconds to find, might provide what you need?
In[1]:= NMinimize[(a + a b + a^2 c + a^3 d + a^4 f + a^5 h - 1)^2 +
(b^2 + 2 a b c + 3 a^2 b d + 4 a^3 b f + 5 a^4 b h - 1)^2 +
(b c + b^2 c + 2 a c^2 + 3 a b^2 d + 3 a^2 c d + 6 a^2 b^2 f + 4 a^3 c f + 10 a^3 b^2 h + 5 a^4 c h - 1/2)^2 +
(2 b c^2 + b d + b^3 d + 2 a c d + 6 a b c d + 3 a^2 d^2 + 4 a b^3 f + 12 a^2 b c f + 4 a^3 d f + 10 a^2 b^3 h + 20 a^3 b c h + 5 a^4 d h - 1/6)^2 +
(c^3 + 2 b c d + 3 b^2 c d + 3 a c^2 d + 6 a b d^2 + b f + b^4 f + 2 a c f + 12 a b^2 c f + 6 a^2 c^2 f + 3 a^2 d f + 12 a^2 b d f + 4 a^3 f^2 + 5 a b^4 h + 30 a^2 b^2 c h + 10 a^3 c^2 h + 20 a^3 b d h + 5 a^4 f h - 1/24)^2 +
(2 c^2 d + 3 b c^2 d + 3 b^2 d^2 + 6 a c d^2 + 2 b c f + 4 b^3 c f + 12 a b c^2 f + 6 a b d f + 12 a b^2 d f + 12 a^2 c d f + 12 a^2 b f^2 + b h + b^5 h + 2 a c h + 20 a b^3 c h + 30 a^2 b c^2 h + 3 a^2 d h + 30 a^2 b^2 d h + 20 a^3 c d h + 4 a^3 f h + 20 a^3 b f h + 5 a^4 h^2 - 1/120)^2,
{a, b, c, d, f, h}, WorkingPrecision -> 32]
Out[1]= {0, {a -> 0.49856360414273480029211060957388,
b -> 0.87633476418476006219360546358197,
c -> 0.24754664962461521368380404047430,
d -> 0.024575890793505412193353159356018,
f -> -0.00093201041042137425003951844268342,
h -> 0.00026544139408412758868359779800026}}
If that isn’t the solution you need then perhaps there is another minimization method which might accept a starting position, find a “nearby” solution and you try random starting positions until you get what you need. Or you might use a minimization method which allows you to specify constraints on the variables to help find the solution that you need.
YES!!! This is precisely what I was expecting. I see rather than NSolve, NMinimize finds it “good enough” . This confirms my direction and I can continue – thank you very much.
Doug