On this page

cook_function

symbolica.community.idenso Function

cook_function(self_: Expression) -> Expression

Convert a single function call into a flattened variable symbol.

Transforms a function expression with arguments into a single symbolic variable whose name encodes both the function name and its arguments. This is the atomic version of cook_indices(), operating on individual function calls rather than complete expressions.

Function Cooking Transform:

  • Simple function: f(a, b)f_a_b
  • Nested arguments: tensor(rep(mu))tensor_rep_mu
  • Multiple arguments: gamma(mu, alpha, beta)gamma_mu_alpha_beta
  • Complex names: my_function(x, y)my_function_x_y

Constraints:

  • Input must be a single function call (not sum, product, etc.)
  • Arguments must be cookable (symbols, numbers, simple functions)
  • Cannot cook expressions containing polynomials or complex structures

Arguments

  • self_: expression representing a single function call to cook

Returns

Expression containing the flattened variable symbol.

Raises

TypeError if input is not a cookable function or contains invalid argument types.

Examples

import symbolica as sp
from symbolica.community.idenso import cook_function

# Simple function cooking
f = sp.S('f')
a, b = sp.S('a','b')

cooked = cook_function(f(a, b))
print(cooked)  # Outputs: f_a_b