Reduce symbolic fraction by powers of ten

조회 수: 1 (최근 30일)
max.s
max.s 2021년 3월 3일
댓글: max.s 2021년 3월 5일
I have symbolic expression in terms of a primary symbolic variable and 2 auxillary symbolic variables.
The coefficients are as follows:
[a,b] = numden(myfrac(2,1))
coeffs(a)'
coeffs(b)'
shows coefficients for both numerator and denominator in the range of 1e108 to 1e164. I do not seem to be able to get rid of those, not with vpa, also not with simplifyFraction etc. Any suggestions on how to proceed?
Take this as an example:
vpa(1e101*s^2 + 1e106*s + 1e164) / (1e140 * s + 1e112)
  댓글 수: 2
Walter Roberson
Walter Roberson 2021년 3월 3일
syms s
vpa(1e101*s^2 + 1e106*s + 1e164) / (1e140 * s + 1e112)
ans = 
simplify(ans)
ans = 
Seems to be reduced ?
It might help to have your actual expression.
max.s
max.s 2021년 3월 4일
Hi, I've attached a mat file with the sample variable in question. It looks like MATLAB should be able to eliminate a factor 1e81 from both numerator and denominator in component YQ_sym(1,2).

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

채택된 답변

Walter Roberson
Walter Roberson 2021년 3월 5일
load sample;
syms s
G = YQ_sym(1,2);
vpa(G,5)
ans = 
vpa(simplify(G),5)
ans = 
[N,D] = numden(G);
Dc = coeffs(D,s);
FN = factor(N);
NN = prod(FN.*[ones(1,length(FN)-1),1/Dc(end)]);
FD = factor(D);
ND = prod(FD.*[ones(1,length(FD)-1),1/Dc(end)]);
G = vpa(NN/ND, 5)
G = 
vpa(simplify(G),5)
ans = 
Still not really what you would want.
There is a trade-off between making it "nice" and making it general.
It would be possible to analyze each term in terms of products and exponents, and calculate the total exponent, and take the N'th root of the factor Dc(end) and multiply each term inside the exponent by the N'th root. For example the bottom is (s+2) * term^3 so we could calculate a total of exponent of 4, take the 4th root of Dc(end) and multiply (s+2) and (term) by the 4th root, so that overall the product was 1/Dc(end) . This would distribute the factor "fairly" ... but might not really be what you are expecting either.
It isn't obvious what the "best" way would be that also preserves the structure.
It becomes easy if you expand() the numerator and denominator and divide each by Dc(end)
  댓글 수: 1
max.s
max.s 2021년 3월 5일
Thanks for putting the effort in to find a suitable solution. I agree that this problem is somewhat inherently nasty.

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by