.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_functional_modeling/vectorial_functions/plot_quadratic_function.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_functional_modeling_vectorial_functions_plot_quadratic_function.py: Create a quadratic function =========================== .. GENERATED FROM PYTHON SOURCE LINES 6-12 In this example we are going to create a quadratic function of the form .. math:: f : \underline{X} \mapsto \underline{\underline{A}} ( \underline{X} - \underline{b} ) + \underline{c} + \frac{1}{2} \underline{X}^T \times \underline{\underline{\underline{M}}} \times \underline{X} .. GENERATED FROM PYTHON SOURCE LINES 14-20 .. code-block:: Python import openturns as ot import openturns.viewer as viewer from matplotlib import pylab as plt ot.Log.Show(ot.Log.NONE) .. GENERATED FROM PYTHON SOURCE LINES 21-22 create a quadratic function .. GENERATED FROM PYTHON SOURCE LINES 22-33 .. code-block:: Python inputDimension = 3 outputDimension = 2 center = [1.0] * inputDimension constant = [-1.0, 2.0] # c linear = ot.Matrix(inputDimension, outputDimension) # A quadratic = ot.SymmetricTensor(inputDimension, outputDimension) # M quadratic[0, 0, 1] = 3.0 function = ot.QuadraticFunction(center, constant, linear, quadratic) x = [7.0, 8.0, 9.0] print(function(x)) .. rst-class:: sphx-glr-script-out .. code-block:: none [-1,56] .. GENERATED FROM PYTHON SOURCE LINES 34-35 draw y1 with x1=2.0, x2=1.0, x0 in [0, 2] .. GENERATED FROM PYTHON SOURCE LINES 35-40 .. code-block:: Python graph = ( ot.ParametricFunction(function, [1, 2], [2.0, 1.0]).getMarginal(1).draw(0.0, 2.0) ) view = viewer.View(graph) plt.show() .. image-sg:: /auto_functional_modeling/vectorial_functions/images/sphx_glr_plot_quadratic_function_001.png :alt: y1 as a function of x0 :srcset: /auto_functional_modeling/vectorial_functions/images/sphx_glr_plot_quadratic_function_001.png :class: sphx-glr-single-img .. _sphx_glr_download_auto_functional_modeling_vectorial_functions_plot_quadratic_function.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_quadratic_function.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_quadratic_function.py `