Subject: [UFL-dev] [HG UFL] ad test

From: [email-masked] (UFL)
Date: Wed, 24 Sep 2008 15:37:26 +0200 (CEST)

One or more new changesets pushed to the primary ufl repository.
A short summary of the last three changesets is included below.

changeset:   261:47f24c5a799264152018ebb14d5c623206cb8c12
tag:         tip
user:        "Kent-Andre Mardal <[email-masked]>"
date:        Wed Sep 24 15:37:24 2008 +0200
files:       demo/ad_ex1.ufl
description:
ad test

changeset:   260:4e87970569562901a101b2bc90b916c90e552cfd
user:        "Martin Sandve Alnæs <[email-masked]>"
date:        Wed Sep 24 15:28:22 2008 +0200
files:       test/classcoverage.py test/mass.py ufl/algorithms/ad.py ufl/algorithms/transformations.py ufl/algorithms/ufl2latex.py ufl/formoperators.py
description:
Some bugfixes and test fixes.
Some tests fail, but that's ok for now.

changeset:   259:5693657007c3c3fbb954aaf20aecabb4761f5608
user:        "Martin Sandve Alnæs <[email-masked]>"
date:        Wed Sep 24 14:06:55 2008 +0200
files:       ufl/algorithms/ad.py ufl/base.py ufl/baseoperators.py ufl/common.py
description:
More AD rules, most important ones are in place now.

----------------------------------------------------------------------
For more details, visit http://www.fenics.org/hg/ufl

---

From: Kent Andre <[email-masked]>
Date: Wed, 24 Sep 2008 15:41:22 +0200

I tried: 
a = f*f*f*f*f*f*v*dx
b = derivative(a, f)

which gets a bit larger than it should: 

{ (((((((((((v_0 * w_0) + (w_0 * v_0)) * w_0) + ((w_0 * w_0) * v_0)) *
w_0) + (((w_0 * w_0) * w_0) * v_0)) * w_0) + ((((w_0 * w_0) * w_0) *
w_0) * v_0)) * w_0) + (((((w_0 * w_0) * w_0) * w
_0) * w_0) * v_0)) * v_-2) } * dx0

Or is this an efficient way to represent it ? 

Kent

On on., 2008-09-24 at 15:37 +0200, UFL wrote:
> _______________________________________________
> UFL-dev mailing list
> [email-masked]
> http://fenics.org/mailman/listinfo/ufl-dev

---

From: "Martin Sandve Alnæs" <[email-masked]>
Date: Wed, 24 Sep 2008 17:15:13 +0200

UFL doesn't do any simplifications and rewriting at all, by design.
Rewriting rules are not reversible in general, but can always be
applied later. The exception is that obvious zeros are removed in
some key places, e.g. 0*f -> 0, 0+f -> f, and during AD.

The same applies for the flattening of expressions like (f*f)*f -> (f*f*f)
which is implemented as a function. We may collapse (f*f*f) to 3*f
in that routine as well, but in general the problem of deciding which
simplifications it is a good idea to do does not have a unique solution.

The form compiler may or may not be able to use information
from the original expression form in heuristics for optimization.

The latex compiler will produce bad output (not close to user input)
if we do too much automatic simplifications.

--
Martin

---

From: [email-masked]
Date: Wed, 24 Sep 2008 19:08:17 +0200 (CEST)

> simplifications it is a good idea to do does not have a unique solution.

ok, but I guess the simple solution in this example is to implement
a pow function in a similar fashion as cos, etc.
If you think it is a good idea, I can implement it. (It would be good for
me to
try to implement something. )

But, this is an example in which AD produces "an explosion", if one does
not have
simplification algoriithms (or a pow function with a derivative). Is this
the only example then ?

Kent

>>> files:       test/classcoverage.py test/mass.py ufl/algorithms/ad.py
>>> ufl/algorithms/transformations.py ufl/algorithms/ufl2latex.py
>>> ufl/formoperators.py
>>> description:

---

From: [email-masked]
Date: Wed, 24 Sep 2008 20:59:24 +0200 (CEST)

> try to implement something. )

Of course, you have already implemented this...

Kent

---

From: "Martin Sandve Alnæs" <[email-masked]>
Date: Wed, 24 Sep 2008 22:44:31 +0200

> simplification algoriithms (or a pow function with a derivative). Is this

The algorithm isn't finished.

--
Martin