Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations SDETERS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

MathCAd Error

Status
Not open for further replies.

Sheila Rose

Civil/Environmental
Oct 26, 2016
14
Hi Folks,

Please help me with the issues I have encountered using MathCAd 15. I'm using a Script with program on it but the result box shows differently. Please see snap for reference. I dont know which part is wrong. Thanks.

When I redefined one of the values using the same magnitude, the result box become correct.
 
 http://files.engineering.com/getfile.aspx?folder=ff5acc42-5e43-4799-a84d-e1840dd37a53&file=MathCAd.pdf
Replies continue below

Recommended for you

Both are technically wrong, as written.

> In both boxes, you are comparing fractions using Mathcad's internal floating point representation, so the difference of two fractions is not equivalent to resultant fraction, when expressed in floating point. The usual approach is to compare against some sort of ε, which is the largest possible valid floating point difference, rather than zero
> Your second box has the two input values reversed



TTFN (ta ta for now)
I can do absolutely anything. I'm an expert! faq731-376 forum1529 Entire Forum list
 
sorry. I'm not into programming. Can you please explain further. It will help me a lot. Thanks.
 
You should be able to do at least the math; this is pretty much high school stuff

Instead of

If Inputs(0).Value > Inputs(1).Value Then

you would have

If Inputs(0).Value - Inputs(1).Value > epsilon Then

TTFN (ta ta for now)
I can do absolutely anything. I'm an expert! faq731-376 forum1529 Entire Forum list
 
Oh I see. Thanks.

I'm thinking if there is any option or program that can possibly round the given value into closest number that may used to satisfy the "equal part" of the program.

There is no problem in greater or less than part, its just the equal portion.

Thanks.

[bigsmile]
 
Round both numbers to the desired number of places then.
 
That's essentially equivalent to comparing the difference to epsilon, but there's still a risk of rounding the wrong direction and it removes the precision that the floating point values have.

Best practice is to use full precision and compare against a known static value. I think you are missing the point. The use of the epsilon is specifically for comparing "equal" values that might not have exactly identical floating point representation. This is hardly a new problem; it's been around since computer programs starting using floating point numbers.

If you must, you can leave the numbers as fractions using Mathcad's symbolic engine

TTFN (ta ta for now)
I can do absolutely anything. I'm an expert! faq731-376 forum1529 Entire Forum list
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor