I would like to create a Mathcad program that distinguishes whether the denominator of a given fraction is a polynomial or not, returning 0 or 1 for example. How do I do this?
The function of the program should be something like this:
once the type has been identified, we pass to the transformation into a polynomial, if possible.
I got this far, so far:
I doubt whether this will (rather sure that this will not) work in Mathcad 15, but it does work in Mathcad 11.
I am tempted to say that what you demand can't be done in Mathcad in a reasonable way as Mathcad does not provide the necessary tools.
Nonetheless here is a first attempt which may serve as a starting point for your own experiments.
There are a lot of drawbacks so far - you can only evaluate the function symbolically, its only working for functions in one variable and otherwise constants, ...
A few of the adverse effects could probably be corrected by some further investigations, but presumably not all. And I guess it will remain an uncertain, unreliable thing.
I don't think there is a way.
You can switch off signalling of certain (types of) warnings.
You cannot switch off errors.
We could at least avoid the error(s) in "IsPoly2" by adding additional arguments and providing an alternative result in case the equality condition is not met. The value does not matter as we never arrive at the last line - if the equality condition is not met an error is thrown.
You may add two additional dummy arguments when you call "IsPoly2" from within "IsDenomPoly", but its not necessary to do so.
Not sure if we also could avoid the error in "IsDenomPoly" - in fact I don't understand the reason for the error message "This value must be a scalar".
I'd expect an error message "This function needs more arguments." for your call of IsPoly2(v) inside the function IsDenomPoly(f).
IsPoly2 requires 3 parameters, you call it with only 1...
Or have you found a way to define functions with optional parameters?