Message Boards Message Boards

0
|
4651 Views
|
4 Replies
|
1 Total Likes
View groups...
Share
Share this post:

0+a small number = 0 ???

Posted 10 years ago
POSTED BY: Jotwie
4 Replies
Posted 10 years ago

Use integers or fractions, but nothing with decimal points, to avoid this problem.

There are other, but much higher, limits on the ability to calculate exact values without decimal points, but you may never encounter those in your work.

POSTED BY: Bill Simpson
Posted 10 years ago

Where did I use decimal Points in my code? As far as I see: nowhere. Typing in p[2], p[4], ... and so on yields 0 even though it shouldn't. It should rather calculate something larger than 0.

POSTED BY: Jotwie

Try using 1/10 (or, say SetPrecision[0.1, 100]) instead of 0.1 to avoid doing the entire computation at machine precision. Also the definition of t should probably use t[k_, i_, j_] instead of t[k, i, j_]. Then it returns positive numbers

In[14]:= N[{p[2], p[4]}, 20]

Out[14]= {4.9209276886444687077*10^-2094, 9.8369344496002929467*10^-2091}
POSTED BY: Ilian Gachevski
Posted 10 years ago

"Where did I use decimal Points in my code? As far as I see: nowhere."

"a[1, k] = (k - 2)*0.1;" <--- There.

Any time anything with a decimal point is combined with anything else the result will then have a decimal point. (Well almost any)

POSTED BY: Bill Simpson
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract