Skip to main content

Friends, II have a recurrence relation that grows exponentially if expressed in closed-form. I need to integrate this function. If I plot it, I think MathematicaMathematica evaluates the recurrence numerically at every level, so the recurrence doesn't grow to be a huge expression. NIntegrateNIntegrate, however, seems to be trying to find a closed-form equation to integrate, even when I turn off symbolicprocessing. I've tried all the options I can think of, including extracting my relation to a function, adding SimplifySimplify to the recurrence, and I'm just completely stumped at how I can force MathematicaMathematica to stop using symbolic manipulation for an expression that has 2^100$2^{100}$ terms. Anyone have any ideas?

HOWavefunctions = Function[{q, n}, 
    RecurrenceTable[{y[i + 1] == 
       Sqrt[2/(i + 1)]*q*y[i] - Sqrt[i/(i + 1)]*
           y[i - 1], y[0] == 1/(Pi^0.25*E^(0.5*q^2)), 
     y[1] == Sqrt[2]*q*y[0]}, y, {i, 0, n}]]
n = 100;
Plot[HOWavefunctions[q, n][[n + 1]]^2, {q, 14.05, 15}]
NIntegrate[HOWavefunctions[q, n][[n + 1]]^2, {q, 14.05, 15}]

(If you turn n$n$ down to 15$15$ or so, both work just fine.)

I guess, ultimately, what I'm looking for is a way to tell RecurrenceTableRecurrenceTable to evaluate 'lazily', that is, only evaluate a term once all variables have numeric values, and never ever expand the relationship symbolically. I tried inserting a SimplifySimplify in the recurrence, but MathematicaMathematica apparently ignored me.

Friends, I have a recurrence relation that grows exponentially if expressed in closed-form. I need to integrate this function. If I plot it, I think Mathematica evaluates the recurrence numerically at every level, so the recurrence doesn't grow to be a huge expression. NIntegrate, however, seems to be trying to find a closed-form equation to integrate, even when I turn off symbolicprocessing. I've tried all the options I can think of, including extracting my relation to a function, adding Simplify to the recurrence, and I'm just completely stumped at how I can force Mathematica to stop using symbolic manipulation for an expression that has 2^100 terms. Anyone have any ideas?

HOWavefunctions = Function[{q, n}, 
    RecurrenceTable[{y[i + 1] == 
       Sqrt[2/(i + 1)]*q*y[i] - Sqrt[i/(i + 1)]*
           y[i - 1], y[0] == 1/(Pi^0.25*E^(0.5*q^2)), 
     y[1] == Sqrt[2]*q*y[0]}, y, {i, 0, n}]]
n = 100;
Plot[HOWavefunctions[q, n][[n + 1]]^2, {q, 14.05, 15}]
NIntegrate[HOWavefunctions[q, n][[n + 1]]^2, {q, 14.05, 15}]

(If you turn n down to 15 or so, both work just fine.)

I guess, ultimately, what I'm looking for is a way to tell RecurrenceTable to evaluate 'lazily', that is, only evaluate a term once all variables have numeric values, and never ever expand the relationship symbolically. I tried inserting a Simplify in the recurrence, but Mathematica apparently ignored me.

I have a recurrence relation that grows exponentially if expressed in closed-form. I need to integrate this function. If I plot it, I think Mathematica evaluates the recurrence numerically at every level, so the recurrence doesn't grow to be a huge expression. NIntegrate, however, seems to be trying to find a closed-form equation to integrate, even when I turn off symbolicprocessing. I've tried all the options I can think of, including extracting my relation to a function, adding Simplify to the recurrence, and I'm just completely stumped at how I can force Mathematica to stop using symbolic manipulation for an expression that has $2^{100}$ terms. Anyone have any ideas?

HOWavefunctions = Function[{q, n}, 
    RecurrenceTable[{y[i + 1] == 
       Sqrt[2/(i + 1)]*q*y[i] - Sqrt[i/(i + 1)]*
           y[i - 1], y[0] == 1/(Pi^0.25*E^(0.5*q^2)), 
     y[1] == Sqrt[2]*q*y[0]}, y, {i, 0, n}]]
n = 100;
Plot[HOWavefunctions[q, n][[n + 1]]^2, {q, 14.05, 15}]
NIntegrate[HOWavefunctions[q, n][[n + 1]]^2, {q, 14.05, 15}]

(If you turn $n$ down to $15$ or so, both work just fine.)

I guess, ultimately, what I'm looking for is a way to tell RecurrenceTable to evaluate 'lazily', that is, only evaluate a term once all variables have numeric values, and never ever expand the relationship symbolically. I tried inserting a Simplify in the recurrence, but Mathematica apparently ignored me.

Source Link

Forcing RecurrenceTable + NIntegrate to evaluate lazily

Friends, I have a recurrence relation that grows exponentially if expressed in closed-form. I need to integrate this function. If I plot it, I think Mathematica evaluates the recurrence numerically at every level, so the recurrence doesn't grow to be a huge expression. NIntegrate, however, seems to be trying to find a closed-form equation to integrate, even when I turn off symbolicprocessing. I've tried all the options I can think of, including extracting my relation to a function, adding Simplify to the recurrence, and I'm just completely stumped at how I can force Mathematica to stop using symbolic manipulation for an expression that has 2^100 terms. Anyone have any ideas?

HOWavefunctions = Function[{q, n}, 
    RecurrenceTable[{y[i + 1] == 
       Sqrt[2/(i + 1)]*q*y[i] - Sqrt[i/(i + 1)]*
           y[i - 1], y[0] == 1/(Pi^0.25*E^(0.5*q^2)), 
     y[1] == Sqrt[2]*q*y[0]}, y, {i, 0, n}]]
n = 100;
Plot[HOWavefunctions[q, n][[n + 1]]^2, {q, 14.05, 15}]
NIntegrate[HOWavefunctions[q, n][[n + 1]]^2, {q, 14.05, 15}]

(If you turn n down to 15 or so, both work just fine.)

I guess, ultimately, what I'm looking for is a way to tell RecurrenceTable to evaluate 'lazily', that is, only evaluate a term once all variables have numeric values, and never ever expand the relationship symbolically. I tried inserting a Simplify in the recurrence, but Mathematica apparently ignored me.