Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X
Does FIND stop searching for a more accurate solution when it finds a solution satisfying CTOL? For example suppose I want to find temperature to within .5 F and I set CTOL to .5. Will Mathcad stop searching when CTOL is met or will it continue searching until some smaller CTOL is achieved? Note: my Solve Block is solving for 1 unknown with units (BTU/min). My constraint has units of degF. I found that units can be applied to CTOL but then FIND does not work.
Also I have a case where I set CTOL to .4, but the FIND solve block found an answer (solution) at which the error is .53733 which is larger than CTOL. So why is FIND returning a solution?
PS: My constraint is 0 =ABS(T1-T1x) + ABS(T2-T2x)
Solved! Go to Solution.
From this response I learned:
I - do not know BUT Gemini Ai says:
You've hit on some interesting points regarding Mathcad's FIND
function and CTOL
. Let's break them down:
1. Does FIND stop searching when CTOL is met, or continue for a smaller CTOL?
In Mathcad, CTOL
(Constraint Tolerance) defines how closely a constraint in a solve block must be met for a solution to be considered acceptable.
Generally, Mathcad's FIND
function will stop searching once a solution is found that satisfies all constraints within the specified CTOL
. It does not continue to search for a more accurate solution beyond that tolerance. Think of CTOL
as your "acceptance threshold." Once that threshold is met, the solver considers its job done for that particular run.
However, it's important to understand that numerical solvers are iterative. They try to converge to a solution. While CTOL
sets the target accuracy for the constraints, the actual accuracy of the found variables can sometimes be better than CTOL
if the algorithm naturally converges further within the allowed iterations. But you shouldn't rely on it to always find a "smaller CTOL" unless you explicitly reduce CTOL
yourself.
2. Why is FIND returning a solution when the error is larger than CTOL?
This is the more perplexing issue, and it points to a common nuance in numerical solvers:
CTOL
applies to the constraints, not necessarily to the direct "error" you calculate afterwards. Your constraint is 0 = ABS(T1-T1x) + ABS(T2-T2x)
. When Mathcad solves this, it's trying to make the sum of the absolute differences as close to zero as possible within CTOL
.
Let's consider your example: CTOL = 0.4
, but the error (which you're calculating as ABS(T1-T1x) + ABS(T2-T2x)
) is 0.53733
.
CTOL
based on its internal checks, or it might have converged to a local minimum where it couldn't get any closer to zero within the given iterations, even if that local minimum is technically outside your CTOL
for the final calculated error.CTOL
(as you observed, where FIND doesn't work when units are applied to CTOL
itself) can sometimes lead to unexpected behavior if not handled carefully. It's generally recommended to make your constraints dimensionless when possible, or ensure the units are consistent in how CTOL
is applied.0 = ABS(T1-T1x) + ABS(T2-T2x)
is a bit unusual for a solve block in some contexts. Typically, you'd define equations like T1 - T1x = 0
and T2 - T2x = 0
. While ABS(T1-T1x) + ABS(T2-T2x) = 0
is mathematically equivalent to T1=T1x
and T2=T2x
for real numbers, the ABS
function can introduce non-smoothness that might affect the solver's convergence, especially if the initial guesses are far from the solution.Troubleshooting and Best Practices:
Simplify Constraints (if possible): Instead of 0 = ABS(T1-T1x) + ABS(T2-T2x)
, try using direct equalities within your solve block:
Given
T1 = T1x
T2 = T2x
Find(Temperature)
This is a more standard way to define the conditions for a solve block. The FIND
function will then try to make T1-T1x
and T2-T2x
both zero.
Check Initial Guesses: Good initial guesses are crucial for numerical solvers to converge to the correct solution and within the desired tolerance. If your initial guesses are far off, the solver might get stuck in a local minimum or struggle to converge.
Increase Max Iterations (if available): Some solve block settings (though FIND
in Mathcad 14 might not expose this directly for simple cases) allow you to increase the maximum number of iterations. If the solver stops because it hit the iteration limit, the CTOL
might not have been fully met.
Consider minerr
: If your equations are highly nonlinear or difficult to converge, minerr
might be a more robust choice than FIND
. minerr
attempts to minimize the error in the constraints, even if it can't find an exact solution. The output of minerr
will be the variables that result in the smallest possible error in the constraints.
Understand TOL
vs. CTOL
:
TOL
(worksheet variable) controls the precision of functions like integrals, derivatives, and root
.CTOL
(solve block variable) specifically controls how closely constraints must be met in find
, minerr
, minimize
, and maximize
.TOL
and CTOL
in your worksheet like normal variables (e.g., CTOL := 0.5
), avoid putting units on CTOL
directly as it's a dimensionless tolerance. The error in your constraints, however, can have units, and Mathcad will implicitly handle them.Examine the problem's sensitivity: If your problem is highly sensitive, a small change in input can lead to a large change in output, making it harder for the solver to converge precisely.
In summary, while FIND
generally stops when CTOL
is met, the observed discrepancy where your calculated error is larger than CTOL
suggests either an issue with the solver's convergence path (possibly due to the absolute value in the constraint or poor initial guesses) or a subtle difference in how Mathcad's internal error metric relates to your explicit error calculation. Experimenting with simplifying the constraints and checking initial guesses will likely be the most fruitful approach.
From this response I learned:
You may want to attach your worksheet and explain what works and what fails.
Why should the algorithm NOT stop when the defined tolerance is achieved?
I don't know how exactly the algorithm (usually Levenberg-Marquardt is used) is implemented in Mathcad, so we can say for sure if the algorithm always stops when the tolerance level is achieved or if there is an option to go further if for some reason the algorithms "sees" that there may be a chance for a better result.
But you have to know that the tolerance is not with respect to the units you provide but with respect to the base units.
So a result when the values are in micrometer may be disappointing while the same calculation using meter as the unit may give satisfactory results.
You may also try to "weight" the constraint by using something like 0 =(ABS(T1-T1x) + ABS(T2-T2x))*10^7
BTW, does ABS mean the absolute value function? Then your constraint is equivalent to the two constraints T1=T1x and T2=T2x. It may be worth a try to use these two separate constraints instead. Again you may "weight" the constraints by writing (T1-T1x)*10^6 = 0.
I got a great answer by Gemini AI. I posted my response as acceptable/solved. Thanks for your input.