Create a symbolic functionΒΆ

In this basic example we are going to create a function from mathematical formulas:

f(x) = [x_0+x_1+x_2, (x_1-1)*e^{x_0} * x_2]

In [1]:
from __future__ import print_function
import openturns as ot
import math as m
In [2]:
# create a symbolic function
function = ot.SymbolicFunction(['x0', 'x1', 'x2'],
                               ['x0 + x1 + x2', '(x1 - 1.0) * exp(x0) * x2'])
x = [1.0, 2.0, 3.0]
print('x=', x, 'f(x)=', function(x))
x= [1.0, 2.0, 3.0] f(x)= [6,8.15485]
In [3]:
# draw y1 with x1=2.0, x2=1.0, x0 in [0, 2]
ot.ParametricFunction(function, [1, 2], [2.0, 1.0]).getMarginal(1).draw(0.0, 2.0)
Out[3]:
../../_images/examples_functional_modeling_symbolic_function_4_0.svg