Subject: [FFC-dev] -fprecision!=15

From: "Ostien, Jakob T" <[email-masked]>
Date: Wed, 20 Aug 2008 10:08:48 -0600

Hi,

Just for fun I tried to compile a form with -fprecision=32, to see if that would impact a problem I was seeing.  The generated code was not what I expected.

For example, using the default, the factor 1/3 is represented as:
  0.333333333333333

But for -fprecision=32 (for the same form) 1/3 becomes
  0.33333333333333331482961625624739

Obviously that latter isn't really that much better than the former.

Is this known?  I can only guess what's happening, anyone have a solid idea?  Possibly (hopefully) its an environment issue that I can fix locally.

Jake

---

From: Anders Logg <[email-masked]>
Date: Wed, 20 Aug 2008 20:05:29 +0200

> For example, using the default, the factor 1/3 is represented as:

It's very simple. FFC (and Python) computes with double precision so
you only have 16 digits. If you ask for more digits, you will get more
digits but they can be anything.

Just try the following in Python:

>>> print "%.32f" % 1.0
1.00000000000000000000000000000000
>>> print "%.32f" % 1.1
1.10000000000000008881784197001252
>>> print "%.32f" % 1.5
1.50000000000000000000000000000000
>>> print "%.32f" % 1.6
1.60000000000000008881784197001252

-- 
Anders

---

From: "Robert Kirby" <[email-masked]>
Date: Wed, 20 Aug 2008 13:06:01 -0500

Hi Jake,
Snarky answer:
If you print out 32 digits of a 16-digit number, well you get what you ask
for :)

Better answer:
The -fprecision flag tells how many digits to print to file, not how many to
compute.  FFC does all of its work in double-precision floating point
arithmetic (native Python floating point numbers) and has no facilities for
arbitrary or extended precision.  If you need the higher precision, you
might try looking at SyFi, which works in symbolic arithmetic and so should
be able to generate more accurate numbers after it gets done.

Regards,
Rob Kirby

On Wed, Aug 20, 2008 at 11:08 AM, Ostien, Jakob T <[email-masked]>wrote:

> Hi,
>
> Just for fun I tried to compile a form with -fprecision=32, to see if that
> would impact a problem I was seeing.  The generated code was not what I
> expected.
>
> Is this known?  I can only guess what's happening, anyone have a solid
> idea?  Possibly (hopefully) its an environment issue that I can fix locally.
>
> Jake
>
>
> _______________________________________________
> FFC-dev mailing list
> [email-masked]
> http://www.fenics.org/mailman/listinfo/ffc-dev
>