error: too large number in context

Hi there When I run my m file program, I have the following error. My program has a symbol called 'n' which I evaluate numerically. My program has functions I wrote before like 'gain_call'
??? Error using ==> sym.sym>char2sym Error, integer too large in context
Error in ==> sym.sym at 92 S = char2sym(x);
Error in ==> sym.maple at 92 result = sym(result);
Error in ==> sym.exp at 7 Y = maple('map','exp',X);
Error in ==> gain_call at 18 fc=(exp((Ea-Efc)/(K*T))+1)^-1;
Error in ==> gain_input at 45 g3=gain_call(Efc,Efv,freq_j,Eg);
Can anybody help me with this problem. I thought my laptop is not powerful enough to run this program as the error says 'too large number in context'. Is this true??

1 件のコメント

omnia
omnia 2012 年 2 月 2 日
this error only appear after 6 or 7 iteration steps (so I am sure the program is right and can give results)

サインインしてコメントする。

回答 (1 件)

Walter Roberson
Walter Roberson 2012 年 2 月 2 日

0 投票

exp((Ea-Efc)/(K*T)) would produce such a large result that Maple is not able to represent it.
I do not recall what the limit is for Maple; above 10^(10^8) and below 10^(10^9)

12 件のコメント

omnia
omnia 2012 年 2 月 3 日
ok and how can I solve this problem ??I tried to use digits(8) instead of the default 32 bit but it stops at the same step.
Walter Roberson
Walter Roberson 2012 年 2 月 3 日
At the point it stops, what is the value of (Ea-Efc)/(K*T) ?
omnia
omnia 2012 年 2 月 4 日
(Ea-Efc)/(K*T) is function of my variable 'n' defined as asymbol
Walter Roberson
Walter Roberson 2012 年 2 月 4 日
I do not see any 'n' in that expression. Are some or all of the variables symbolic in your gain_input routine? Do you subs() anything in to them before the fc= assignment?
In any case, if you command
dbstop if error
at the MATLAB command line, and you run the program, then when it stops in sym.sym, use the command line command
dbup
until it shows you that you are positioned in gain_call . At that point you should be able to examine the individual variables Ea, Efc, K, and T, and you should be able to evaluate (Ea-Efc)/(K*T)
I speculate that either K or T will be 0 at that point.
omnia
omnia 2012 年 2 月 4 日
K and T are constants and I entered their values in the program. Ea and Efc are functions of 'n' given by
Ea=(h*freq-Eg)*mhh/(me+mhh);
Efc=(log(delta)+delta*(64+0.05524*delta*(64+sqrt(delta)))^-0.25)*K*T;
Eg and delta are functions of the symbol 'n'. As a result Ea and Efc are also symbols. Then I have an equation in all this symbols and try to solve it numerically by secant method.
Walter Roberson
Walter Roberson 2012 年 2 月 4 日
What does
(Ea-Efc)/(K*T)
calculate out to when the problem occurs?
Possibly vpa() of the expression might turn out to be suggestive.
omnia
omnia 2012 年 2 月 4 日
For the step before it stops (after calculating 'n' and substituting):
(Ea-Efc)/(K*T)=-2.5347
In the next step it cannot calculate this expression as a number as I cannot solve the equation of 'n' so this expression still a function of 'n' which has a value
517454681347759706544580009576/602151471086373548867819299917+12290660266811755112085095759995/3879331313331395975440112579971695771648*n^(1/3)-117397416587723775/117397416587723776*log(1/239562285167304647901184*n)-117397416587723775/28123993390493144174105904347378335350784*n/(64+1381/5989057129182616197529600000*n*(64+1/29243443013586993152*3569756227244506^(1/2)*n^(1/2)))^(1/4)
After using vpa() on this expression it will be
.85934304937293+.31682419659735e-8*n^(1/3)-1.*log(.41742797673750e-23*n)-.41742797673750e-23*n/(64.+.23058721434980e-24*n*(64.+.20431054224819e-11*n^(1/2)))^(1/4)
By the way the secant method has subs() many times on the function I want to solve (to get the value of 'n'). Is this related to any thing.
Walter Roberson
Walter Roberson 2012 年 2 月 4 日
Ah... it _might_ be the case that exp() is having trouble with those large numerators and denominators in rational form, as rational form always tries to work with exact solutions.
Perhaps if you inserted vpa() around the (Ea-Efc)/(K*T) it might work. Just be sure you use enough Digits to be meaningful for your purposes.
omnia
omnia 2012 年 2 月 6 日
Thanks. I tried to insert vpa() as you suggested. The iteration increased but after a while the following error appear:
{n}
??? Error using ==> maple
Error, integer too large in context
Error in ==> sym.findsym at 33
v = maple('indets', sc ,'symbol');
Error in ==> sym.subs at 96
OLDexpr = findsym(OLDf,1);
Error in ==> secant at 8
fo=subs(f,xo);
Error in ==> gain_input at 50
n_new(k)=secant(initial_guess,final_guess,f);
where gain_input is my main program and secant is function I made.
Walter Roberson
Walter Roberson 2012 年 2 月 6 日
Ah, and what is vpa((Ea-Efc)/(K*T)) at that point?
omnia
omnia 2012 年 2 月 6 日
I will check for it but the error is no longer in this line:
{n}
??? Error using ==> maple
Error, integer too large in context
Error in ==> sym.findsym at 33
v = maple('indets', sc ,'symbol');
Error in ==> sym.subs at 96
OLDexpr = findsym(OLDf,1);
Error in ==> secant at 8
fo=subs(f,xo);
Error in ==> gain_input at 50
n_new(k)=secant(initial_guess,final_guess,f);
omnia
omnia 2012 年 2 月 6 日
it has a value of:
.85934304937292961902495530021078+.31682419659735343866312859991915e-8*n^(1/3)-.99999999999999999148192499404140*log(.41742797673750005902568898595211e-23*n)-.41742797673750005547000617051654e-23*n/(64.+.23058721434979503260579059583995e-24*n*(64.+.20431054224819140717900382251866e-11*n^(1/2)))^(1/4)

サインインしてコメントする。

質問済み:

2012 年 2 月 2 日

編集済み:

2013 年 10 月 1 日

Community Treasure Hunt

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

Start Hunting!

Translated by