# Plotting a function based on complicated integral

I have this function :

f[Lambda_] := K Integrate[x Exp[- x^2-Lambda x]
HypergeometricU[-Lambda,1/2,(x+ Lambda/2+2)^2],{x,0,Infinity}];


where

K = 1/(Lambda (Lambda +4)/(4(4-Lambda))
HypergeometricU[1 -Lambda,3/2, ( Lambda+ 4)^2/4] +
Integrate[Exp[-y /2( 2 y +2 Lambda)]
HypergeometricU[- Lambda,1/2,(2y Lambda+4)^2/4],{y,0,Infinity}])


I want to plot it for lambda in $[0,4]$, but it seems that it is too complicated to plot directly. I wanted to know what is the best way to have an approximated plot of this function.

• Have you actually tried to plot it and something has not worked? Show what you have tried and the error you are receiving. While you are editing your post format your code with the {} button. – Edmund Feb 4 '16 at 0:42

Some of the definitions in the original question were problematic. I edited the question to have more consistent code.

In order to plot the function numerical values are needed, so using Integrate is not necessary. We can use NIntegrate instead. The plot is produced within 30 seconds on my laptop with Mathematica 10.3.1.

Here is the function redefined:

fn[Lambda_?NumericQ] :=
Block[{K},
K = 1/(Lambda (Lambda + 4)/(4 (4 - Lambda)) HypergeometricU[
1 - Lambda, 3/2, (Lambda + 4)^2/4] +
NIntegrate[
Exp[-y/2 (2 y + 2 Lambda)] HypergeometricU[-Lambda,
1/2, (2 y Lambda + 4)^2/4], {y, 0, Infinity},
Method -> {Automatic, "SymbolicProcessing" -> 0}]);
K*NIntegrate[
x Exp[-x^2 - Lambda x] HypergeometricU[-Lambda,
1/2, (x + Lambda/2 + 2)^2], {x, 0, Infinity},
Method -> {Automatic, "SymbolicProcessing" -> 0}]
];


Here is the plot of the function:

AbsoluteTiming[
Plot[fn[x], {x, 0.1, 4}, PerformanceGoal -> "Speed"]
]


• Thank you so much ! I am a beginner with Mathematica :D – Rim Feb 5 '16 at 1:01
• @Rim No problem, good luck! – Anton Antonov Feb 5 '16 at 17:03