From 8bd99875f247b39eb434bb43b699ee9deb05d197 Mon Sep 17 00:00:00 2001 From: Yuri Victorovich Date: Mon, 16 Jan 2023 23:56:19 -0800 Subject: math/py-pyaudi: New port: Library implementing the algebra of Taylor polynomials --- math/py-pyaudi/files/test.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 math/py-pyaudi/files/test.py (limited to 'math/py-pyaudi/files/test.py') 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 -- cgit v1.2.3