In the fraction formed by the symbolic variable "s", the coefficient is too large and shows as “Inf”, which cannot separate the numerator and denominator. How to simplify it?

1 view (last 30 days)
Friends, I am dealing with a fraction formed by a symbolic variable with a large coefficient, which is likely to become larger and larger with subsequent multiplies. I would like to ask if there is a way to simplify or reduction symbolic fraction.
I tried using "simplify" to simplify fractions, which made nothing better but the coefficients became larger. I also wanted to convert fractions numerically by using "double", but the conversion failed because the fraction contained symbolic variable.
Here is the fraction as bellow.
(((45759979496176626692050450696805005565806574625*s*((5080133413424225723388921704625*s...
*((112090290656527208263060342210875*s)/316912650057057350374175801344 ...
+ 30552169752491162830473320431875/633825300114114700748351602688))/20769187434139310514121985316880384 ...
+ 20286320422766753661829418720889/20282409603651670423947251286016))/93536104789177786765035829293842113257979682750464... ...
+ (45759979496176626692050450696805005565806574625*s*((5080133413424225723388921704625*s...
*((112090290656527208263060342210875*s)/316912650057057350374175801344 + ...
30552169752491162830473320431875/633825300114114700748351602688))/20769187434139310514121985316880384 ...
+ 1267650597283017110295360187969/1267650600228229401496703205376))...
/93536104789177786765035829293842113257979682750464)*((112090290656527208263060342210875*s)...
/316912650057057350374175801344 + 30552169752491162830473320431875/633825300114114700748351602688) ...
+ (206104494090311446492353214522878559354463867301233136994975125*s*...
((1009668247808049509412402534409397964247392580875*s)/1427247692705959881058285969449495136382746624 ...
+ 275202745215966093183022177892084753866632481875/2854495385411919762116571938898990272765493248))...
/421249166674228746791672110734681729275580381602196445017243910144 + ...
(4504033794585333*((5080133413424225723388921704625*s*((112090290656527208263060342210875*s)...
/316912650057057350374175801344 + 30552169752491162830473320431875/633825300114114700748351602688))...
/20769187434139310514121985316880384 + 20286320422766753661829418720889/20282409603651670423947251286016)^2)...
/4503599627370496 - (((5080133413424225723388921704625*s*((45759979496176626692050450696805005565806574625*s*...
((1009668247808049509412402534409397964247392580875*s)/1427247692705959881058285969449495136382746624 + ...
275202745215966093183022177892084753866632481875/2854495385411919762116571938898990272765493248))...
/93536104789177786765035829293842113257979682750464 + ((5080133413424225723388921704625*s*...
((112090290656527208263060342210875*s)/316912650057057350374175801344 + 30552169752491162830473320431875... ...
/633825300114114700748351602688))/20769187434139310514121985316880384 + 20286320422766753661829418720889... ...
/20282409603651670423947251286016)^2))/20769187434139310514121985316880384 + ...
(51521156592014478012672258690832318901788671629627330591517375*s*((5080133413424225723388921704625*s...
*((112090290656527208263060342210875*s)/316912650057057350374175801344 + 30552169752491162830473320431875... ...
/633825300114114700748351602688))/20769187434139310514121985316880384 + 20286320422766753661829418720889... ...
/20282409603651670423947251286016))/105312291668557186697918027683670432318895095400549111254310977536 + ...
(51521156592014478012672258690832318901788671629627330591517375*s*((5080133413424225723388921704625*s*...
((112090290656527208263060342210875*s)/316912650057057350374175801344 + 30552169752491162830473320431875... ...
/633825300114114700748351602688))/20769187434139310514121985316880384 + 1267650597283017110295360187969... ...
/1267650600228229401496703205376))/105312291668557186697918027683670432318895095400549111254310977536)*...
(((112090290656527208263060342210875*s)/316912650057057350374175801344 + 30552169752491162830473320431875... ...
/633825300114114700748351602688)*(((5080133413424225723388921704625*s*((112090290656527208263060342210875*s)...
/316912650057057350374175801344 + 30552169752491162830473320431875/633825300114114700748351602688))...
/20769187434139310514121985316880384 + 1267650597283017110295360187969/1267650600228229401496703205376)^2 ...
+ (45759979496176626692050450696805005565806574625*s*((1009668247808049509412402534409397964247392580875*s)...
/1427247692705959881058285969449495136382746624 + 275202745215966093183022177892084753866632481875... ...
/2854495385411919762116571938898990272765493248))/93536104789177786765035829293842113257979682750464) + ...
(4504033794585333*((5080133413424225723388921704625*s*((112090290656527208263060342210875*s)...
/316912650057057350374175801344 + 30552169752491162830473320431875/633825300114114700748351602688))...
/20769187434139310514121985316880384 + 20286320422766753661829418720889/20282409603651670423947251286016)...
*((1009668247808049509412402534409397964247392580875*s)/1427247692705959881058285969449495136382746624 ...
+ 275202745215966093183022177892084753866632481875/2854495385411919762116571938898990272765493248))...
/4503599627370496 + (4504033794585333*((1009668247808049509412402534409397964247392580875*s)...
/1427247692705959881058285969449495136382746624 + 275202745215966093183022177892084753866632481875... ...
/2854495385411919762116571938898990272765493248)*((5080133413424225723388921704625*s...
*((112090290656527208263060342210875*s)/316912650057057350374175801344 + 30552169752491162830473320431875... ...
/633825300114114700748351602688))/20769187434139310514121985316880384 + 1267650597283017110295360187969... ...
/1267650600228229401496703205376))/4503599627370496))/((1125899905534687*((5080133413424225723388921704625*s...
*((112090290656527208263060342210875*s)/316912650057057350374175801344 + 30552169752491162830473320431875... ...
/633825300114114700748351602688))/20769187434139310514121985316880384 + 1267650597283017110295360187969... ...
/1267650600228229401496703205376)^2)/1125899906842624 + ...
(51521156592014478012672258690832318901788671629627330591517375*s*...
((1009668247808049509412402534409397964247392580875*s)/1427247692705959881058285969449495136382746624 + ...
275202745215966093183022177892084753866632481875/2854495385411919762116571938898990272765493248))...
/105312291668557186697918027683670432318895095400549111254310977536 + (5080133413424225723388921704625*s...
* (((5080133413424225723388921704625*s*((112090290656527208263060342210875*s)/316912650057057350374175801344 ...
+ 30552169752491162830473320431875/633825300114114700748351602688))/20769187434139310514121985316880384 ...
+ 20286320422766753661829418720889/20282409603651670423947251286016)* ...
((1009668247808049509412402534409397964247392580875*s)/1427247692705959881058285969449495136382746624 ...
+ 275202745215966093183022177892084753866632481875/2854495385411919762116571938898990272765493248) ...
+ ((1009668247808049509412402534409397964247392580875*s)/1427247692705959881058285969449495136382746624 ...
+ 275202745215966093183022177892084753866632481875/2854495385411919762116571938898990272765493248) ...
*((5080133413424225723388921704625*s*((112090290656527208263060342210875*s)/316912650057057350374175801344 ...
+ 30552169752491162830473320431875/633825300114114700748351602688))/20769187434139310514121985316880384 ...
+ 1267650597283017110295360187969/1267650600228229401496703205376)))/20769187434139310514121985316880384))/s
Yes, the expression is so complex that I can only handle it by code. I need to separate the numerator and denominator of this fraction by using "numden", but the command window shows as bellow.
Error using filter
First denominator filter coefficient must be finite.
Error in deconv (line 30)
[q,zf] = filter(b, a, [1 zeros(1,nb-na)]);
Error in residue (line 87)
if length(u) >= length(v), [k,u] = deconv(u,v); end
Error in youilfenshihe (line 9)
[r,p,k]=residue(a_fenzi,a_fenmu);
I guess it maybe because the coefficients are too large to handle. How can I do with it?

Answers (1)

Sam Chak
Sam Chak on 17 Apr 2022
@梦雪 王, Have you tried this?
sympref('FloatingPointOutput', true)
It should display the expression in floating-point format.
  4 Comments
梦雪 王
梦雪 王 on 26 Apr 2022
Thank u very much. The solution you provided helped me successfully separate the numerator and denominator of fractions with relatively larger coefficients using numden(), but it did not completely solve my problem as shown bellow. The error occured because the coefficient of the symbolic variable in the numerator or denominator of the fraction is inf and cannot be processed further.
Since vpa() seems to be just a fractional simplification of the symbolic variable equation in display process. The fraction still performs in integer form during the calculation, where the coefficients of symbolic variable revert back to the large.
Error using roots (line 27)
Input to ROOTS must not contain NaN or Inf.
Error in residue (line 88)
r = roots(v);
Error in youilfenshihe (line 16)
[r,p,k]=residue(a_fenzi,a_fenmu);
In short, is there a way to radically reduce the coefficients of teh symbolic variable? In other word, if the coefficient of the symbolic variable is too large, is there a general way to solve the problem at the expense of accuracy?
Sam Chak
Sam Chak on 26 Apr 2022
Try this method, see whether it can make large constants more readable or not.
% Define the large constants as symbols
g = 112090290656527208263060342210875;
M = ...;
m = ...;
L = ...;
sympref('AbbreviateOutput', false);
% Create symbolic scalar variables and functions that you want to solve
syms x(t) y(t) u
sympref is introduced in R2015a. The 'AbbreviateOutput' should work.

Sign in to comment.

Categories

Find more on Symbolic Math Toolbox in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!