1
$\begingroup$

I'm having problem taking the numerical definite integral of a numerical Laplace transform that depends on two variables due to NIntegrate:inumr errors:

nlap1[f_, u_?NumericQ, s_?NumericQ] := 
 NIntegrate[f[u, t] Exp[-s*t], {t, 0, ∞}]
coshint[s_?NumericQ] := NIntegrate[Cosh[Sqrt[s]*u]*nlap1[intertau, u, s], {u, 0, 1}]

Modifying the wonderful suggestion of flinty in Numerical Laplace Transform of InterpolatingFunction, nlap1 takes the numerical Laplace transform of an InterpolatingFunction intertau that is a function of both u and t but ONLY transforms the variable t. coshint attempts to take the numerical definite integral with respect to u but no matter what values are entered, I get the error NIntegrate: The integrand [e^(-random number*t) in nlap1] has evaluated to non-numerical values for all sampling points in the region {{}}. However, nlap1 itself seems to work fine for the most part.

It's important to note that the region specified in the error is outside of the range of the InterpolatingFunction intertau, but I didn't think this would really matter? I was wondering if anyone had any suggestions for changing coshint so that it accomplishes its intended purpose -- again, Mathematica is quite new to me so I'd greatly appreciate any help!

$\endgroup$
8
  • 2
    $\begingroup$ intertau shouldn't take u as a parameter right. You changed the definition of nlap1 to add f[u, t] but this is incorrect - it should be f[t] $\endgroup$ – flinty Jul 7 '20 at 22:30
  • $\begingroup$ Thanks for your response! I changed nlap1 back to what you originally suggested with only f[t] and called that version in coshint but am still getting the same error unfortunately -- is that what you meant? $\endgroup$ – Rpj Jul 7 '20 at 22:50
  • $\begingroup$ If your interpolation is 1d and has no dependence on u then change nlap1[f_, u_?NumericQ, s_?NumericQ] to nlap1[f_, s_?NumericQ], change f[u,t] to f[t] and change NIntegrate[Cosh[Sqrt[s]*u]*nlap1[intertau, u, s], {u, 0, 1}] to NIntegrate[Cosh[Sqrt[s]*u], {u, 0, 1}]*nlap1[intertau, s] $\endgroup$ – flinty Jul 7 '20 at 22:52
  • $\begingroup$ Yep that's what I did, but my interpolation intertau is 2d and does have a dependence on u but u isn't transformed -- only t is (so the Laplace transform only transforms one variable) $\endgroup$ – Rpj Jul 7 '20 at 22:57
  • $\begingroup$ I see now, have you tried changing f[u,t] to f[{u,t}] in your original code ? $\endgroup$ – flinty Jul 7 '20 at 23:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.