symbolic and automatic differentiation & code generation · t5 = tll = t12 t18 t19 t21 = t22...

15
Symbolic and Automatic Differentiation & Code Generation Doug James

Upload: others

Post on 31-Jul-2020

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Symbolic and Automatic Differentiation & Code Generation · t5 = tll = t12 t18 t19 t21 = t22 t23 t25 = t26 t31 = t32 = t31*t31; t34 = Sm02*sm02 , t35 = Sm12*sm12 t36 = sm22*sm22 t38

Symbolic and Automatic Differentiation & Code Generation

!Doug James

Page 2: Symbolic and Automatic Differentiation & Code Generation · t5 = tll = t12 t18 t19 t21 = t22 t23 t25 = t26 t31 = t32 = t31*t31; t34 = Sm02*sm02 , t35 = Sm12*sm12 t36 = sm22*sm22 t38

Motivation: Bending Force

Now take a second derivative!

Page 3: Symbolic and Automatic Differentiation & Code Generation · t5 = tll = t12 t18 t19 t21 = t22 t23 t25 = t26 t31 = t32 = t31*t31; t34 = Sm02*sm02 , t35 = Sm12*sm12 t36 = sm22*sm22 t38

Symbolic math tools

• Useful for differentiation & optimized code gen.

• Examples:

• Maple

• Matlab

• Mathematica

• ...

Page 4: Symbolic and Automatic Differentiation & Code Generation · t5 = tll = t12 t18 t19 t21 = t22 t23 t25 = t26 t31 = t32 = t31*t31; t34 = Sm02*sm02 , t35 = Sm12*sm12 t36 = sm22*sm22 t38

Motivation 2: Newton-Schulz Iteration

• See whiteboard

Page 5: Symbolic and Automatic Differentiation & Code Generation · t5 = tll = t12 t18 t19 t21 = t22 t23 t25 = t26 t31 = t32 = t31*t31; t34 = Sm02*sm02 , t35 = Sm12*sm12 t36 = sm22*sm22 t38

Example 1Evaluate the algebraic expression

where

Page 6: Symbolic and Automatic Differentiation & Code Generation · t5 = tll = t12 t18 t19 t21 = t22 t23 t25 = t26 t31 = t32 = t31*t31; t34 = Sm02*sm02 , t35 = Sm12*sm12 t36 = sm22*sm22 t38

Example 1

Page 7: Symbolic and Automatic Differentiation & Code Generation · t5 = tll = t12 t18 t19 t21 = t22 t23 t25 = t26 t31 = t32 = t31*t31; t34 = Sm02*sm02 , t35 = Sm12*sm12 t36 = sm22*sm22 t38

Example 1

Page 8: Symbolic and Automatic Differentiation & Code Generation · t5 = tll = t12 t18 t19 t21 = t22 t23 t25 = t26 t31 = t32 = t31*t31; t34 = Sm02*sm02 , t35 = Sm12*sm12 t36 = sm22*sm22 t38

Example 2

Page 9: Symbolic and Automatic Differentiation & Code Generation · t5 = tll = t12 t18 t19 t21 = t22 t23 t25 = t26 t31 = t32 = t31*t31; t34 = Sm02*sm02 , t35 = Sm12*sm12 t36 = sm22*sm22 t38

Example 2

Doh!Doh!

Doh!Doh!

Doh!

Doh!

Page 10: Symbolic and Automatic Differentiation & Code Generation · t5 = tll = t12 t18 t19 t21 = t22 t23 t25 = t26 t31 = t32 = t31*t31; t34 = Sm02*sm02 , t35 = Sm12*sm12 t36 = sm22*sm22 t38

Example 3: Newton-Schulz Iteration

• See code

Page 11: Symbolic and Automatic Differentiation & Code Generation · t5 = tll = t12 t18 t19 t21 = t22 t23 t25 = t26 t31 = t32 = t31*t31; t34 = Sm02*sm02 , t35 = Sm12*sm12 t36 = sm22*sm22 t38

Example 4: Neo-Hookean material

Page 12: Symbolic and Automatic Differentiation & Code Generation · t5 = tll = t12 t18 t19 t21 = t22 t23 t25 = t26 t31 = t32 = t31*t31; t34 = Sm02*sm02 , t35 = Sm12*sm12 t36 = sm22*sm22 t38

Example 4: Neo-Hookean material

Page 13: Symbolic and Automatic Differentiation & Code Generation · t5 = tll = t12 t18 t19 t21 = t22 t23 t25 = t26 t31 = t32 = t31*t31; t34 = Sm02*sm02 , t35 = Sm12*sm12 t36 = sm22*sm22 t38

Example 4: Ogden material

See code output(!)

Page 14: Symbolic and Automatic Differentiation & Code Generation · t5 = tll = t12 t18 t19 t21 = t22 t23 t25 = t26 t31 = t32 = t31*t31; t34 = Sm02*sm02 , t35 = Sm12*sm12 t36 = sm22*sm22 t38

Automatic Differentiation: Many compilers available

Page 15: Symbolic and Automatic Differentiation & Code Generation · t5 = tll = t12 t18 t19 t21 = t22 t23 t25 = t26 t31 = t32 = t31*t31; t34 = Sm02*sm02 , t35 = Sm12*sm12 t36 = sm22*sm22 t38

Automatic Differentiation: Many compilers available