Integrating piecewise function
4 ビュー (過去 30 日間)
古いコメントを表示
I'm following up on this q&a:
I typed in the following code and I don't understand the result:
syms a x y p
p=2;
fint = int(heaviside(y-a)*(y-a)^p,y,a,x)
subs(fint,{a,x},{sym(0),sym(-3)})
fint =
-(a - x)^3/3
ans =
-9
I guess I'm being dense here, but it seems that the heaviside function has had no effect. Shouldn't answers for x<a be zero? Why isn't fint a piecewise function?
Thanks,
Susan
回答 (3 件)
Walter Roberson
2011 年 5 月 25 日
It would be easier to read (and might even solve the problem) if you were to explicitly specify the variable of integration in the int() call instead of just specifying the bounds and having it try to deduce the variable.
3 件のコメント
Walter Roberson
2011 年 5 月 25 日
Just to check: are you using the Maple based symbolic toolbox (older versions) or the MuPad based one (newer versions) ?
When I try this out in Maple directly, the answer I get after substitution is
limit(-Heaviside(y)*y^(p+1)/(p+1)+3^(p+1)/(p+1), y = 0, right)
which simplifies to
-(limit(Heaviside(y)*y^(p+1)-3^(p+1), y = 0, right))/(p+1)
The piecewise() equivalent of this is (in Maple notation)
piecewise(y < 0, 3^(p+1)/(p+1), y = 0, -(limit(-3^(p+1)+y^(p+1)*undefined, y = 0, right))/(p+1), 0 < y, -(limit(-3^(p+1)+y^(p+1), y = 0, right))/(p+1))
Maple's "undefined" is pretty much equivalent to NaN -- that is, Heaviside is not defined when its argument is 0.
Susan
2011 年 5 月 25 日
2 件のコメント
Walter Roberson
2011 年 5 月 25 日
If you mentally add the assumption that x >= x0, then when you use an x0 that is greater than your a, then x < a is going to be false so you fall over to just the heaviside portion.
Christopher Creutzig
2011 年 5 月 30 日
When integrating from a to x, int makes the implicit assumption that a ≤ y ≤ x and thus a ≤ x, unless that is obviously wrong, in which case the interval borders are swapped. This is a side-effect of restricting the variable of integration to the interval given.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!