summaryrefslogtreecommitdiff
path: root/math/py-pyaudi/files/test.py
diff options
context:
space:
mode:
Diffstat (limited to 'math/py-pyaudi/files/test.py')
-rw-r--r--math/py-pyaudi/files/test.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/math/py-pyaudi/files/test.py b/math/py-pyaudi/files/test.py
new file mode 100644
index 000000000000..a88096364d54
--- /dev/null
+++ b/math/py-pyaudi/files/test.py
@@ -0,0 +1,39 @@
+# from http://darioizzo.github.io/audi/notebooks/example00.html
+
+from pyaudi import gdual_double as gdual
+from pyaudi import sin, cos, tan
+
+# Define some variables (gduals)
+x,y,z = [gdual(0.,_,3) for _ in "xyz"]
+
+# Create a function of these variables
+f = x*x+2*tan(x/(y+1))-sin(z)
+print(f)
+
+# Extracting the derivatives
+print(f.get_derivative([0,0,1]))
+print(f.get_derivative({"dz": 1}))
+print(f.get_derivative({"dx":1, "dy":1}))
+
+# Changing the point
+x = gdual(1.,"x",3)
+y = gdual(2.,"y",3)
+z = gdual(3.,"z",3)
+f = x*x+2*tan(x/(y+1))-sin(z)
+print(f)
+
+print(f.get_derivative([0,0,1]))
+
+print(-cos(3.))
+
+# Encapsulating f in a function call
+
+def f(x,y,z):
+ return x*x+2*tan(x/(y+1))-sin(z)
+
+
+x = gdual(1.,"x",3)
+y = gdual(2.,"y",3)
+z = gdual(3.,"z",3)
+print(f(x,y,z)) #Call with gduals
+print(f(1.,2.,3.)) #Call with floats