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 Center および File ExchangeAssumptions についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by