acosh()#

relationalai.std.math
#acosh(number: Number|Producer) -> Expression

Calculates the inverse hyperbolic cosine (arccosh) of a number. The input number must be greater than or equal to 1. If number is a Producer, acosh() filters out any non-numeric or invalid values from the producer. Must be called in a rule or query context.

Parameters#

NameTypeDescription
numberProducer or Python Number objectThe value to calculate the inverse hyperbolic cosine of, must be >= 1.

Returns#

An Expression object.

Example#

Use acosh() to calculate the inverse hyperbolic cosine of a number:

#import relationalai as rai
from relationalai.std import math


# =====
# SETUP
# =====

model = rai.Model("MyModel")
Portfolio = model.Type("Portfolio")
Investment = model.Type("Investment")

# Define portfolios and their investments.
with model.rule():
    portfolio1 = Portfolio.add(id=1).set(name="Portfolio1")
    portfolio1.investments.extend([
        Investment.add(id=1).set(name="InvestmentA", growth_rate=1.0),
        Investment.add(id=2).set(name="InvestmentB", growth_rate=2.0),
    ])

    portfolio2 = Portfolio.add(id=2).set(name="Portfolio2")
    portfolio2.investments.extend([
        Investment.add(id=3).set(name="InvestmentC", growth_rate=1.5),
        Investment.add(id=4).set(name="InvestmentD", growth_rate=0.8),  # Out of range
    ])


# =======
# EXAMPLE
# =======

# Set a growth_acosh property to the inverse hyperbolic cosine of each investment's growth rate.
with model.rule():
    portfolio = Portfolio()
    investment = portfolio.investments
    investment.set(growth_acosh=math.acosh(investment.growth_rate))

# Since acosh() filters out non-numeric or out-of-range values, the growth_acosh
# property is not set for the investment with ID 4.
with model.query() as select:
    portfolio = Portfolio()
    investment = portfolio.investments
    response = select(portfolio.name, investment.name, investment.growth_acosh)

print(response.results)
#          name        name2  growth_acosh
# 0  Portfolio1  InvestmentA      0.000000
# 1  Portfolio1  InvestmentB      1.316958
# 2  Portfolio2  InvestmentC      0.962424
# 3  Portfolio2  InvestmentD           NaN

See Also#