I have an integration function which does not have indefinite integral expression.
Specifically, the function is f(y)=h(y)+integral(@(x) exp(-x-1/x),0,y) where h(y)
is a simple function.
Matlab numerically computes f(y)
well, but I want to compute the following function.
g(w)=w*integral(1-f(y).^(1/w),0,inf) where w is a real number in [0,1].
The problem for computing g(w)
is handling f(y).^(1/w)
numerically.
How can I calculate g(w)
with MATLAB? Is it impossible?
Expressions containing e^(-1/x) are generally difficult to compute near x = 0. Actually, I am surprised that Matlab computes f(y) well in the first place. I'd suggest trying to compute g(w)=w*integral(1-f(y).^(1/w),epsilon,inf)
for epsilon
greater than zero, then gradually decreasing epsilon
toward 0 to check if you can get numerical convergence at all. Convergence is certainly not guaranteed!
You can calculate g(w)
using the functions you have, but you need to add the ( ArrayValued
, true
) name-value pair. The option allows you to specify a vector-valued w
and allows the nested integral
call to receive a vector of y
values, which is how integral
naturally works.
f = @(y) h(y)+integral(@(x) exp(-x-1/x),0,y,'ArrayValued',true);
g = @(w) w .* integral(1-f(y).^(1./w),0,Inf,'ArrayValued',true);
At least, that works on my R2014b installation.
Note: While h(y)
may be simple, if it's integral over the positive real line does not converge, g(w)
will more than likely not converge (I don't think I need to qualify that, but I'll hedge my bets).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.