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
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