Help to approximate this integral...

11 ビュー (過去 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 Center および File ExchangeNumerical 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