.. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` 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 =========================== 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} .. code-block:: default from __future__ import print_function import openturns as ot import openturns.viewer as viewer from matplotlib import pylab as plt import math as m ot.Log.Show(ot.Log.NONE) create a quadratic function .. code-block:: default 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 Out: .. code-block:: none [-1,56] draw y1 with x1=2.0, x2=1.0, x0 in [0, 2] .. code-block:: default graph = ot.ParametricFunction(function, [1, 2], [2.0, 1.0]).getMarginal(1).draw(0.0, 2.0) view = viewer.View(graph) plt.show() .. image:: /auto_functional_modeling/vectorial_functions/images/sphx_glr_plot_quadratic_function_001.png :alt: y1 as a function of x0 :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.077 seconds) .. _sphx_glr_download_auto_functional_modeling_vectorial_functions_plot_quadratic_function.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_quadratic_function.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_quadratic_function.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_