Skip to main contentIBM Quantum Documentation
This page is from an old version of Qiskit SDK. Go to the latest version

ParameterExpression

class ParameterExpression(symbol_map, expr)

GitHub

Bases: object

ParameterExpression class to enable creating expressions of Parameters.

Create a new ParameterExpression.

Not intended to be called directly, but to be instantiated via operations on other Parameter or ParameterExpression objects.

Parameters

  • symbol_map (Dict[Parameter, [ParameterExpression, float, or int]]) – Mapping of Parameter instances to the sympy.Symbol serving as their placeholder in expr.
  • expr (sympy.Expr) – Expression of sympy.Symbol s.

Methods

arccos

ParameterExpression.arccos()

Arccos of a ParameterExpression

arcsin

ParameterExpression.arcsin()

Arcsin of a ParameterExpression

arctan

ParameterExpression.arctan()

Arctan of a ParameterExpression

assign

ParameterExpression.assign(parameter, value)

Assign one parameter to a value, which can either be numeric or another parameter expression.

Parameters

  • parameter (Parameter) – A parameter in this expression whose value will be updated.
  • value (Union[ParameterExpression, float]) – The new value to bind to.

Return type

ParameterExpression

Returns

A new expression parameterized by any parameters which were not bound by assignment.

bind

ParameterExpression.bind(parameter_values)

Binds the provided set of parameters to their corresponding values.

Parameters

parameter_values (Dict) – Mapping of Parameter instances to the numeric value to which they will be bound.

Raises

  • CircuitError

    • If parameter_values contains Parameters outside those in self. - If a non-numeric value is passed in parameter_values.
  • ZeroDivisionError

    • If binding the provided values requires division by zero.

Return type

ParameterExpression

Returns

A new expression parameterized by any parameters which were not bound by parameter_values.

conjugate

ParameterExpression.conjugate()

Return the conjugate.

Return type

ParameterExpression

cos

ParameterExpression.cos()

Cosine of a ParameterExpression

exp

ParameterExpression.exp()

Exponential of a ParameterExpression

gradient

ParameterExpression.gradient(param)

Get the derivative of a parameter expression w.r.t. a specified parameter expression.

Parameters

param (Parameter) – Parameter w.r.t. which we want to take the derivative

Return type

Union[ParameterExpression, complex]

Returns

ParameterExpression representing the gradient of param_expr w.r.t. param or complex or float number

is_real

ParameterExpression.is_real()

Return whether the expression is real

log

ParameterExpression.log()

Logarithm of a ParameterExpression

sin

ParameterExpression.sin()

Sine of a ParameterExpression

subs

ParameterExpression.subs(parameter_map)

Returns a new Expression with replacement Parameters.

Parameters

parameter_map (Dict) – Mapping from Parameters in self to the ParameterExpression instances with which they should be replaced.

Raises

CircuitError

  • If parameter_map contains Parameters outside those in self. - If the replacement Parameters in parameter_map would result in a name conflict in the generated expression.

Return type

ParameterExpression

Returns

A new expression with the specified parameters replaced.

sympify

ParameterExpression.sympify()

Return symbolic expression as a raw Sympy or Symengine object.

Symengine is used preferentially; if both are available, the result will always be a symengine object. Symengine is a separate library but has integration with Sympy.

Note

This is for interoperability only. Qiskit will not accept or work with raw Sympy or Symegine expressions in its parameters, because they do not contain the tracking information used in circuit-parameter binding and assignment.

tan

ParameterExpression.tan()

Tangent of a ParameterExpression


Attributes

parameters

Returns a set of the unbound Parameters in the expression.

Return type

Set

Was this page helpful?
Report a bug or request content on GitHub.