Solved
The reason is the way how multiple successive if-statements followed by an otherwise are evaluated. Otherwise only triggers if ALL if's had failed. So your variable h never gets a value and is zero - therefore the wrong result.
A workaround can be to separate the if's by a dummy line:

From Mathcad's help:
- Each conditional evaluation is considered on its own. When Mathcad encounters several sequential if statements at the same level, it evaluates each if statement in turn, regardless of the results of the previous statement. If you wish to evaluate an expression based on whether a particular if statement evaluates as true or false, use the otherwise operator.
- If you use more than one if statement before an otherwise statement, the otherwise statement is executed only when all previous conditions are false. However, all previous if statements continue to be evaluated regardless of the results of the previous if. In the example above fy(5) = 9 and fy(2) = 1. There is no "else if" or "case" statement in Mathcad that allows you to switch on multiple cases, other than to use nested if ... otherwise pairs.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.

