필터 지우기
필터 지우기

‘Polynomial expression expected.’ showed when i tried to get the coefficents

조회 수: 13 (최근 30일)
syms T p1 p2 p3 p4 p5 p6 real
J = T + T*((6*p1)/T^2 - (2*p4)/T)^2 + T*((6*p2)/T^2 - (2*p5)/T)^2 + T*((6*p3)/T^2 - (2*p6)/T)^2 + (T^6*((12*p1)/T^3 - (6*p4)/T^2)^2)/3 + (T^6*((12*p2)/T^3 - (6*p5)/T^2)^2)/3 + (T^6*((12*p3)/T^3 - (6*p6)/T^2)^2)/3 - T^2*((6*p1)/T^2 - (2*p4)/T)*((12*p1)/T^3 - (6*p4)/T^2) - T^2*((6*p2)/T^2 - (2*p5)/T)*((12*p2)/T^3 - (6*p5)/T^2) - T^2*((6*p3)/T^2 - (2*p6)/T)*((12*p3)/T^3 - (6*p6)/T^2);
J1 = diff(J,T);
cT = coeffs(J1,T);
Just got J for another window.
why would it show "Error using symengine Polynomial expression expected." as i ran it?
should i get a normal form of J1 first, when i want the coefficients of it? If so, how?
Appreciate for an answer.

채택된 답변

Walter Roberson
Walter Roberson 2020년 4월 29일
coeffs() can only be used for polynomials with respect to the variable. Your expression has division by your variable, and so is not a polynomial.
simplify() would bring a normal form, but it would still have division by the variable and so is not enough.
What you can do is
[N, D] = numden(J1);
Nc = coeffs(N, T, 'all');
Dc = coeffs(D, T, 'all');
Now Nc are the numerator coefficients and Dc are the denominator coefficients.
  댓글 수: 11
Walter Roberson
Walter Roberson 2020년 4월 29일
Yes, and the answer you get would N (the first output of the numden call).
You can remove a lot of the distraction on the solve() by not declaring your p symbols to be real valued. When you solve() you then do not get any warning about needing to return conditions, and you get
root(24*p6^2*z^5 + 24*p5^2*z^5 + 24*p4^2*z^5 - 48*p3*p6*z^4 - 48*p2*p5*z^4 - 48*p1*p4*z^4 + z^4 + 8*p6^2*z^2 + 8*p5^2*z^2 + 8*p4^2*z^2 - 72*p3*p6*z - 72*p2*p5*z - 72*p1*p4*z + 108*p3^2 + 108*p2^2 + 108*p1^2, z, 1)
repeated up to root number 5. And there is not obvious way to reduce that to lower degree.
The problem is not in isolating something that looks polynomial-like: the problem is that your J is too high a degree to be able to find a closed form solution for its critical points in terms of T.
Zhanhao Liang
Zhanhao Liang 2020년 4월 30일
Very appreciate for your patience and specific answer, Mr Roberson.
I have decided to use numerical method in my coding part to give me a bridge.
We tallk next time!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Number Theory에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by