Reduce symbolic fraction by powers of ten
1 次查看(过去 30 天)
显示 更早的评论
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
2021-3-3
syms s
vpa(1e101*s^2 + 1e106*s + 1e164) / (1e140 * s + 1e112)
simplify(ans)
Seems to be reduced ?
It might help to have your actual expression.
采纳的回答
Walter Roberson
2021-3-5
load sample;
syms s
G = YQ_sym(1,2);
vpa(G,5)
vpa(simplify(G),5)
[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)
vpa(simplify(G),5)
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)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Assumptions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!