Is Matlab consistently and correctly handling symbolic expressions that include a dirac function applied at a point of discontinuity?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Is Matlab consistently and correctly handling symbolic expressions that include a dirac function applied at a point of discontinuity?
Preliminary definitions
sympref('default');
syms f(t)
assume(t,'real')
fint = @(f) int(f(t)*dirac(t),t,-inf,inf,'Hold',true) == int(f(t)*dirac(t),t,-inf,inf);
fsimp = @(f) f(t)*dirac(t) == simplify(f(t)*dirac(t),100);
out = @(g) [f(t) == g; f(0) == g(0); fint(g); fsimp(g)];
For an undefined symfun f(t), its defintion, its value at t = 0, its integral against dirac(t), and its simplification when multiplied against dirac(t) are
disp(out(f))
Strictly speaking, it's my understanding that the integral and the simplification are only valid if f(t) is continuous at t = 0. It's always seemed to me that the Symbolic Math Toolbox (SMT) tries to be pretty strict about accounting for all possible forms of expressions and often won't make simplifications/evaluations that don't apply for all possible cases, which is why we often have to use assumptions or IgnoreAnalyticConstraints to get desired/expected/simplified results. But here, the integral and simplification are carried out as if they apply to any f(t), even though they are clearly not true for some allowable forms of f(t). For example, with
f0(t) = 1/t;
the integral and simplifcation are returned unmodified, which is typical when the SMT is asked for something it can't provide.
[fint(f0); fsimp(f0)]
Perhaps I'm reading too much into the integral and simplification for undefined f(t) as to whether or not the SMT is claiming that those results apply for all f(t).
Another case of interest is when f(t) is discontinuous at t = 0. For example, with heaviside:
sympref('HeavisideAtOrigin',10);
f1(t) = heaviside(t);
disp(out(f1))
sympref('default');
It appears that the SMT integral and simplification rules are followed, though I have my doubts about the rigor of these results.
However, things get murky when using piecewise:
f2(t) = piecewise(t<=0,5,8);
disp(out(f2))
If following the integral and simplification rules, the integral and simplification should be 5 and and 5*dirac(t) respectively. It's interesting that the 8*dirac(t) shows up on the "otherwise" branch. Given that it does show up there, I think the integral is obtained by the SMT rewriting the piecewise function using heaviside (even though that's not a rewrite option for the user), and the integral for each branch evaluates to val*HeavisideAtOrigin, or val/2 under the default sympref. So the result is 5/2 + 8/2 = 13/2.
We can test this hypothesis by changing the value of HeavisideAtOrigin.
sympref('HeavisideAtOrigin',10);
disp(out(f2))
sympref('default');
The integral is 5*10 + 8*10 = 130.
Define the apparently same function, but explicitly define it over the whole real line instead of using otherwiseVal.
f3(t) = piecewise(t<=0,5,t>0,8);
disp(out(f3))
A different result is obtained, though again the integral and simplifcation rules are not satisfied, and the integral and simplfiication are not consistent with each other.
Now put the equality on the other side of the discontinuity, using otherwiseVal
f4(t) = piecewise(t<0,5,8);
disp(out(f4))
and define the function over the entire domain explicitly
f5(t) = piecewise(t<0,5,t>=0,8);
disp(out(f5))
In these cases, the results with f4(t) and f5(t) are consistent with each other, even though they don't follow the generic integration and simplification rules, and they don't seem to follow the pattern of f2(t) and f3(t).
My question are:
Should the SMT evaluate the integral and simplification of f(t)*dirac(t) for an undefined symfun f(t), even though those generic results do not apply for all allowable symfuns? Or are those generic results an indication that particular results are actually incorrect if the particular results are inconsistent with generic results?
How should the SMT handle the product of dirac(t) and f(t) when f(t) is not continuous, though defined, at the origin (or more generally where the dirac argument is 0)?
One option would be to not deal with this type of product at all, similar to the case with f(t) = 1/t.
IF the SMT must do something in cases with dirac(t) applied to f(t) with a point discontinuity at the origin, then presumably the results should be 1) consistent for all functions (in these examples, I think the integral of f2, f3, f4, and f5 should all be the same, and so should be the simplification), and 2) the results should be mathematically justifiable, at least loosely if not rigorously. To that end, my vote would be that the integral evaluate to
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1423998/image.png)
and the simpification evaluate to
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1424003/image.png)
with obvious extension to cases where dirac is applied at some other point on the real line (these expressions are consistent with f(t) being continuous at t = 0).
As an aside, I am surprised that this expression does not simplify
syms a real
simplify(f(t)*dirac(t-a))
even though the integral is evaluated
int(f(t)*dirac(t-a),t,-inf,inf)
2 Kommentare
Walter Roberson
am 6 Dez. 2023
I think the integral is obtained by the SMT rewriting the piecewise function using heaviside (even though that's not a rewrite option for the user),
syms x
f = piecewise(x < -2, 5, x^2)
rewrite(f, 'heaviside')
sympref('heavisideAtOrigin', 0)
rewrite(f, 'heaviside')
heaviside is a user-accessible rewrite... it just doesn't do anything a lot of the time. I have used it successfully in the past, but only when I set the heaviside origin (in the expressions I was working with, it never seemed to work when I left the heaviside as the default.)
Antworten (1)
Karan Singh
am 1 Sep. 2023
Hey Paul, the “Symbolic Math Toolbox (SMT)” in MATLAB handles symbolic expressions that include a “Dirac” function applied at a point of discontinuity in a specific way.
1. For an undefined “symfun `f(t)` ”, the SMT evaluates the integral and simplification of “ `f(t)*dirac(t)` “, even though the generic results do not apply to all allowable “symfuns”. The generic results are not an indication that the results are incorrect. The “SMT” aims to provide symbolic evaluations for a wide range of expressions, even if they do not hold for all possible cases. In this case, it treats the expression as a generic symbolic expression and performs the integral and simplification operations accordingly.
2. When “ `f(t)` “ is not continuous at the origin (or where the Dirac argument is “0”), the “SMT” handles the product of “ `dirac(t)` “ and “ `f(t)` “ by evaluating the integral and simplification based on the specific form of `f(t)` and the Dirac function. However, the SMT's approach may not always align with a strict mathematical interpretation or expectations.
Regarding your suggested expression for the integral of “ `f(t)*dirac(t)` “ and the simplification, it is a reasonable approach to handle the product when “ `f(t)` “ is not continuous at the origin. However, the SMT may not currently implement this specific behavior. It's worth noting that the SMT focuses on providing general symbolic evaluations and simplifications rather than specific mathematical interpretations.
Regarding your aside question about the expression “ `f(t)*dirac(t-a)` “, it is surprising that the simplification does not occur automatically. However, the “SMT” may not simplify this expression by default due to the presence of the parameter “a”. You can try using additional simplification techniques or assumptions to simplify the expression further if desired.
In summary, the SMT handles symbolic expressions involving Dirac functions applied at points of discontinuity in a generic manner, aiming to provide symbolic evaluations and simplifications.
Hope it helps!
0 Kommentare
Siehe auch
Kategorien
Mehr zu Assumptions finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!