It may have to do with the if-else instruction and the min/max functions used there, but the main problem lies in the numeric methods used internally for the calculation of the integral.
PTC has massively changed the numeric algorithms used in Prime and praised the new ones as being much better. Perhaps this is not the case in all cases. As you can see in the following picture (right side) the integral does not converge for some arguments x.c like 0.49 or 0.51). Thats the reason for the gaps in the plot and the error you get when you try to create the vector.
If this happened in real Mathcad you could right click the integral and give another algorithm a try (which is not necessary in case of your integral because "autoselect" did a good job).

But in Prime we have no choice. If the algorithm does not work - bad luck.

There is one way you can get the sheet to work OK in Prime, too, but its risky. You can play with the setting of the system variable TOL (you may change it in the "calculation" ribbon menu or simply assign it a value at the top of the worksheet like a normal variable). The default setting is 10^-3. If you change it to a ridiculously large value like 0.3 your sheet seems to work OK (at least in Prime 6) but you have to decide for yourself how much you trust the results now. At least I won't expect high precision. Note the difference of the results for the argument 0.51 if you compare the picture of Mathcad and the one of Prime.

BTW, if you set TOL to a lower value (like 10^-9) in real Mathcad, the integral fails now an then, too, and you see some gaps in the plot.
Another way to deal with the problem of the vector creation failing could be to write a wrapper function which uses the "try" command (in real mathcad its "on error") to return NaN if the calculation fails. That way the vector can be created, but it will contain a couple of NaNs. If thats a solution for you depends on what you would like to use the vector for. If its just needed to export the results to Excel, the described method should work OK. Of course you could also chose to return a string like "error" instead of NaN or anything else you think is appropriate.

Welcome to the PTC Community
No account yet? Create an account
Please use your PTC eSupport account.
LoginEnter your E-mail address. We'll send you an e-mail with instructions to reset your password.



