Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

why?? it should be another thing!! 1

Status
Not open for further replies.

yyhhcart2

Electrical
Sep 20, 2006
1
Hi

as you now exp(i*pi)=-1
and as well exp(i*pi)+1 should be 0
but you find it is 1.2246e-016i!!!! in matlab..
does somebody know why???
tnx
 
Replies continue below

Recommended for you

Why would you think that a numerical processor has infinite precision?

TTFN



 
The exponential is an infinite series. If you have an infinite amount of time you can get a better answer.

corus
 
"If you have an infinite amount of time you can get a better answer"
Not quite, you would also need a computer with an infinite number of bits. That is to say this is a quantisation problem not a time one.
 
Actually FrancisL since its a converging infinite series any computer will do - you just need a bigger stack of paper in your printer [smile]

Good Luck
johnwm
________________________________________________________
To get the best from these forums read faq731-376 before posting

Steam Engine enthusiasts:
 
So long as you don't use floating point... the source of the rounding errors.

bcd maths would be better...
 
bcd math would have to be floating point as well, to represent cos(). These are irrational numbers and cannot be represented in any format exactly.

TTFN



 
Indeed.

But bcd math doesn't have the binary/decimal conversion error.

:eek:)
 
The conversion error is at the limit of the machine's precision, so it really doesn't matter whether you were able to express 0.1 exactly in BCD, when there is an infinite number of cases that BCD doesn't help anyway.

TTFN



 
You can calculate using scaled integers to any arbitrary precision, as long as the function can be reduced to a converging series. About 20 years ago I was teaching a BASIC programming class in which we calculated pi and e to 100000 places using integer arithmetic.

Took some time to calculate though [smile]

Good Luck
johnwm
________________________________________________________
To get the best from these forums read faq731-376 before posting

Steam Engine enthusiasts:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor