Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X
When I integrate a piecewise function created with the IF function, the results are incorrect for some values of the limits, when combined with some values of the parameter of the IF function.
PTC tech support has pointed me to the documentation that states that, under certain conditions, the integral of an abruptly changing function may produce incorrect results. However, they think there responsibility ends there. There do not seem to be any plans to fix this error, or even have Mathcad return an error message instead of a value that appears to be normal and correct.
I've attached the file, or a PDF of the worksheet, depending upon what this new message board will allow me to do.
As can be seen, the function can be made to work by slightly changing the integration limits, or by decreasong TOL (not shown)
I've also tested the function in Mattematica, and it works there without error,
Is there any way to have Mathcad notify me when there may be a problem, instead of just displaying an incorrect answer?
Victor Roberts wrote:
When I integrate a piecewise function created with the IF function, the results are incorrect for some values of the limits, when combined with some values of the parameter of the IF function.
PTC tech support has pointed me to the documentation that states that, under certain conditions, the integral of an abruptly changing function may produce incorrect results.
Numerical integration is an iterative procdure, and as such does not like discontinuous functions. I don't know why the Mathematica one works. Perhaps it automatically breaks up the integral into pieces.
However, they think there responsibility ends there.
Unfortunately, it does. There is no guarantee that any numerical algorithm will always work, under all circumstances. That is not to say that it would not be a nice feature for the integrals to automatically handle functions that are defined in a discontinuous way, but I think they are under no particular obligation to implement that. It's just another request.
Is there any way to have Mathcad notify me when there may be a problem, instead of just displaying an incorrect answer?
I can't think of one. The only solution would be to detect the discontinuities. But if you can do that, then you can automatically split the integral into pieces. The real solution is to always integrate functions you have defined in a discontinuous way in pieces, with boundaries at the discontinuities.
>>The real solution is to always integrate functions you have defined in a discontinuous way in pieces, with boundaries at the discontinuities. <<
Thanks. That seems to be a workable soultion. Why couldn't PTC Support have given me that simple solution?
Vic Roberts
Why couldn't PTC Support have given me that simple solution
Good question.
Viktor,
Your answer is in "Mathcad Usage" 27 June, 2010 ... 11:55
jmG