Forgot password?
 Create new account
View 115|Reply 1

Mathematica与SymPy解方程组不同

[Copy link]

3147

Threads

8493

Posts

610K

Credits

Credits
66163
QQ

Show all posts

hbghlyj Posted at 2023-7-26 06:01:55 |Read mode
Last edited by hbghlyj at 2023-7-26 06:07:00求参数的值,使二元多项式在ℝ上可约Mathematica解方程组:
  1. f = (x^2 + y^2 - 1) ((x - 3)^2 + y^2 - 1) + k x y;
  2. Assuming[k∈Reals, Solve[D[f, x] == D[f, y] == f == 0, {k, x, y}]]
Copy the Code

输出10组解:
  1. {{k -> 0, x -> 3/2, y -> -I/2*Sqrt[5]},
  2. {k -> 0, x -> 3/2, y -> I/2*Sqrt[5]},
  3. {k -> Root[{24 + 7*#1 - 22*#1^3 + 6*#1^4 & , -392 - 96*#1 - 105*#1^2 + 426*#1^3 - 108*#1^4 + 95*#2^2 & , 1323*#2 + 5454*#1*#2 + 3810*#1^2*#2 - 8254*#1^3*#2 + 1932*#1^4*#2 + 380*#3 & }, {1, 1, 1}], x -> Root[24 + 7*#1 - 22*#1^3 + 6*#1^4 & , 1, 0], y -> Root[{24 + 7*#1 - 22*#1^3 + 6*#1^4 & , -392 - 96*#1 - 105*#1^2 + 426*#1^3 - 108*#1^4 + 95*#2^2 & }, {1, 1}]},
  4. {k -> Root[{24 + 7*#1 - 22*#1^3 + 6*#1^4 & , -392 - 96*#1 - 105*#1^2 + 426*#1^3 - 108*#1^4 + 95*#2^2 & , 1323*#2 + 5454*#1*#2 + 3810*#1^2*#2 - 8254*#1^3*#2 + 1932*#1^4*#2 + 380*#3 & }, {1, 2, 1}], x -> Root[24 + 7*#1 - 22*#1^3 + 6*#1^4 & , 1, 0], y -> Root[{24 + 7*#1 - 22*#1^3 + 6*#1^4 & , -392 - 96*#1 - 105*#1^2 + 426*#1^3 - 108*#1^4 + 95*#2^2 & }, {1, 2}]},
  5. {k -> Root[{24 + 7*#1 - 22*#1^3 + 6*#1^4 & , -392 - 96*#1 - 105*#1^2 + 426*#1^3 - 108*#1^4 + 95*#2^2 & , 1323*#2 + 5454*#1*#2 + 3810*#1^2*#2 - 8254*#1^3*#2 + 1932*#1^4*#2 + 380*#3 & }, {2, 1, 1}], x -> Root[24 + 7*#1 - 22*#1^3 + 6*#1^4 & , 2, 0], y -> Root[{24 + 7*#1 - 22*#1^3 + 6*#1^4 & , -392 - 96*#1 - 105*#1^2 + 426*#1^3 - 108*#1^4 + 95*#2^2 & }, {2, 1}]},
  6. {k -> Root[{24 + 7*#1 - 22*#1^3 + 6*#1^4 & , -392 - 96*#1 - 105*#1^2 + 426*#1^3 - 108*#1^4 + 95*#2^2 & , 1323*#2 + 5454*#1*#2 + 3810*#1^2*#2 - 8254*#1^3*#2 + 1932*#1^4*#2 + 380*#3 & }, {2, 2, 1}], x -> Root[24 + 7*#1 - 22*#1^3 + 6*#1^4 & , 2, 0], y -> Root[{24 + 7*#1 - 22*#1^3 + 6*#1^4 & , -392 - 96*#1 - 105*#1^2 + 426*#1^3 - 108*#1^4 + 95*#2^2 & }, {2, 2}]},
  7. {k -> Root[{24 + 7*#1 - 22*#1^3 + 6*#1^4 & , -392 - 96*#1 - 105*#1^2 + 426*#1^3 - 108*#1^4 + 95*#2^2 & , 1323*#2 + 5454*#1*#2 + 3810*#1^2*#2 - 8254*#1^3*#2 + 1932*#1^4*#2 + 380*#3 & }, {3, 1, 1}], x -> Root[24 + 7*#1 - 22*#1^3 + 6*#1^4 & , 3, 0], y -> Root[{24 + 7*#1 - 22*#1^3 + 6*#1^4 & , -392 - 96*#1 - 105*#1^2 + 426*#1^3 - 108*#1^4 + 95*#2^2 & }, {3, 1}]},
  8. {k -> Root[{24 + 7*#1 - 22*#1^3 + 6*#1^4 & , -392 - 96*#1 - 105*#1^2 + 426*#1^3 - 108*#1^4 + 95*#2^2 & , 1323*#2 + 5454*#1*#2 + 3810*#1^2*#2 - 8254*#1^3*#2 + 1932*#1^4*#2 + 380*#3 & }, {3, 2, 1}], x -> Root[24 + 7*#1 - 22*#1^3 + 6*#1^4 & , 3, 0], y -> Root[{24 + 7*#1 - 22*#1^3 + 6*#1^4 & , -392 - 96*#1 - 105*#1^2 + 426*#1^3 - 108*#1^4 + 95*#2^2 & }, {3, 2}]},
  9. {k -> Root[{24 + 7*#1 - 22*#1^3 + 6*#1^4 & , -392 - 96*#1 - 105*#1^2 + 426*#1^3 - 108*#1^4 + 95*#2^2 & , 1323*#2 + 5454*#1*#2 + 3810*#1^2*#2 - 8254*#1^3*#2 + 1932*#1^4*#2 + 380*#3 & }, {4, 1, 1}], x -> Root[24 + 7*#1 - 22*#1^3 + 6*#1^4 & , 4, 0], y -> Root[{24 + 7*#1 - 22*#1^3 + 6*#1^4 & , -392 - 96*#1 - 105*#1^2 + 426*#1^3 - 108*#1^4 + 95*#2^2 & }, {4, 1}]},
  10. {k -> Root[{24 + 7*#1 - 22*#1^3 + 6*#1^4 & , -392 - 96*#1 - 105*#1^2 + 426*#1^3 - 108*#1^4 + 95*#2^2 & , 1323*#2 + 5454*#1*#2 + 3810*#1^2*#2 - 8254*#1^3*#2 + 1932*#1^4*#2 + 380*#3 & }, {4, 2, 1}], x -> Root[24 + 7*#1 - 22*#1^3 + 6*#1^4 & , 4, 0], y -> Root[{24 + 7*#1 - 22*#1^3 + 6*#1^4 & , -392 - 96*#1 - 105*#1^2 + 426*#1^3 - 108*#1^4 + 95*#2^2 & }, {4, 2}]}}
Copy the Code

SageMath解相同的方程组:
  1. var('k x y')
  2. f = (x^2 + y^2 - 1) * ((x - 3)^2 + y^2 - 1) + k * x * y
  3. solve([diff(f, x), diff(f, y), f], [k, x, y], solution_dict=True, algorithm='sympy')
Copy the Code

为什么仅输出了前2组解呢?
  1. [{k: 0, x: 3/2, y: -1/2*I*sqrt(5)},
  2. {k: 0, x: 3/2, y: 1/2*I*sqrt(5)}]
Copy the Code

3147

Threads

8493

Posts

610K

Credits

Credits
66163
QQ

Show all posts

 Author| hbghlyj Posted at 2023-7-26 06:09:30
发现把algorithm='sympy'去掉,就也是10组解了。这是什么原因?

手机版Mobile version|Leisure Math Forum

2025-4-20 22:16 GMT+8

Powered by Discuz!

× Quick Reply To Top Return to the list