Help to approximate this integral...

조회 수: 14 (최근 30일)
Peter Clifford
Peter Clifford 2019년 3월 3일
편집: David Goodmanson 2019년 3월 15일
Hello,
I am wondering if it is possible to have an approximation of this integral
I have only an approximation
of f which is a solution of an ODE.
Many thanks,
Maher.
  댓글 수: 3
Peter Clifford
Peter Clifford 2019년 3월 6일
No f is asolution of an ODE equation, I have an approximation of it by ode45 method.
darova
darova 2019년 3월 6일
편집: darova 2019년 3월 6일
but what f depends on? If we calculate integral x = [0, 3], what will be f (for example y = 1.56)
have you relation ?

댓글을 달려면 로그인하십시오.

답변 (1개)

David Goodmanson
David Goodmanson 2019년 3월 6일
편집: David Goodmanson 2019년 3월 6일
Hi M^2,
I am assuming that y(t) is strictly monotonic increasing or decreasing so that the inverse exists. It's good if the y and t arrays are not too sparse. Depending on how time comsuming the ode solver is, in the case of ode45, for example, you can output a lot of points by specifying a grid of points in the tspan input variable rather than just an upper and lower limit.
Assuming that t and y are reasonably dense an that the y array starts at 0, then
V(x) = cumtrapz(exp(-t),y)
There are better ways to do an indefinite integral, but this gives a reasonable result if exp(-t) is fairly smooth,
  댓글 수: 2
Peter Clifford
Peter Clifford 2019년 3월 6일
Thanks for the help.
You took ?
what are the relations between and t in
V(x) = cumtrapz(exp(-t),y)
I have this
[t, f] = ode45(@odefunc, tspan, [0; 1], options);
How to deduce an approximation of V defined by :
where is the inverse function of f which is strictly increasing and
Maher.
David Goodmanson
David Goodmanson 2019년 3월 7일
편집: David Goodmanson 2019년 3월 15일
HI Maher,
I should have been more explicit. Yes, I took y = f(t). Then
t = f^-1(y)
This is consistent with just using the line
[t, y] = ode45(@odefunc, tspan, [0; 1], options);
There are two side-by-side output arrays, t and y = f(t). These match up point-by-point. But if both of these arrays are monotonic there is no reason you can't consider y to be the independent variable, t the dependent variable and redefine the arrays as y and t(y), the inverse function of y. Since t and y match up point-by point, t is the same as t(y) and
Int {0,x} e-t(y) dy ---> Int {0,x} e-t dy.
With y as the independent variable you can do the definite integral from 0 to x by trapz (assuming the y array starts at 0) and the indefinite integral by cumtrapz to give the function V(x).
Matlab has plenty of integral evaluation capability when given a function f(x) that can be evaluated at arbitrary points in x.
I hope I'm wrong, but if what you have is an independent and a dependent array at fixed points, I don't know that Matlab has anything easily available that's better than the lamentably primitive trapz and cumtrapz.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

제품


릴리스

R2015a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by