3
$\begingroup$

I have the following code:

n = 11; 
λ[0] = 1; 
α[0] = 10; 
If[n != 9, Do[Delt[L] = 0; , {L, 0, n}]]; 
Delt[9] = 1; 
Do[
  λ[τ + 1] = λ[0] + Sum[λ[k]*((11^α[k]*(10 - λ[k]))/(11^α[k] + 1) - 0.2), {k, 0, τ}];
  α[τ + 1] = α[0] + Sum[5*Delt[k], {k, 0, τ}] - Sum[α[k]/2^λ[k], {k, 0, τ}];,
  {τ, 0, n}
]

Information["λ", LongForm -> False]
Information["α", LongForm -> False]

For n = 20 I have the following message:

Underflow occurred in computation

I want to do the calculation for n = 20 or even n = 30 without underflow occurring. Any suggestions?

$\endgroup$
9
  • $\begingroup$ From help: represents a number too small to represent explicitly on your computer system. so one way is not to make your numbers that small? see also How to avoid overflow or underflow in mathematica? and $\endgroup$
    – Nasser
    Commented Jul 17, 2017 at 9:18
  • $\begingroup$ @Nasser Dear Nasser, I reviewed that. But I can not use for my code. $\endgroup$
    – Abdol Ali
    Commented Jul 17, 2017 at 9:55
  • $\begingroup$ Is there any chance that you might be able to express λ[τ+1] and α[τ+1] strictly in terms of λ[τ] and α[τ]? If that could be done simply enough and without using decimal approximations then RSolve might give you closed form solutions for λ[n] and α[n]. $\endgroup$
    – Bill
    Commented Jul 17, 2017 at 17:35
  • $\begingroup$ @Bill λ[τ+1] and α[τ+1] are related. Can I use of RSolve? $\endgroup$
    – Abdol Ali
    Commented Jul 17, 2017 at 17:47
  • $\begingroup$ RSolve can handle some, sometimes simple, systems of recurrence relations. Look in the help page, click on Scope and scroll down to see that they show systems of recurrence relations that depend on each other. I suspect the key is to think about the algebra to simplify your system as I described. $\endgroup$
    – Bill
    Commented Jul 17, 2017 at 17:51

1 Answer 1

2
$\begingroup$

Change your 0.2, an approximate machine number, to 2/10, an exact rational. Exact calculations don't underflow.

Unfortunately, the results, while exact, are unwieldy.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.