Skip to main content
Version: 1.2.0

Power

Arithmetic Data Analysis

Synopsis

Raises a numeric value to a specified power and returns the result.

Schema

- power:
field: <ident>
left_operand: <string>
right_operand: <string>
description: <text>
if: <script>
ignore_failure: <boolean>
ignore_missing: <boolean>
on_failure: <processor[]>
on_success: <processor[]>
tag: <string>

Configuration

The following fields are used to define the processor:

FieldRequiredDefaultDescription
fieldY-Target field to store the power operation result
left_operandY-Base value to be raised to a power - can be a literal value or field reference
right_operandY-Exponent value - can be a literal value or field reference
descriptionN-Explanatory note
ifN-Condition to run
ignore_failureNfalseContinue processing if power operation fails
ignore_missingNfalseSkip if referenced fields don't exist
on_failureN-Error handling processors
on_successN-Success handling processors
tagN-Identifier

Details

Raises a numeric value (the base) to a specified power (the exponent) and stores the result in the target field. The processor handles various special cases and mathematical constraints associated with exponentiation.

note

The processor uses the math.Pow function from Go's standard library to perform the calculation, which provides accurate results for a wide range of inputs.

The processor is useful for exponential calculations, scaling operations, scientific computations, and implementing mathematical formulas that involve powers.

warning

The processor handles several special mathematical cases:

  • 0^0 is considered indeterminate and will cause an error
  • Negative numbers raised to non-integer powers will result in complex numbers and cause an error
  • Very large results might overflow and cause an error
  • Results that are not finite numbers (NaN or Infinity) will cause an error

Always provide appropriate error handling for operations that might encounter these edge cases.

Examples

Basic

Raising a number to a power...

{
"math": {}
}
- power:
field: math.result
left_operand: "2"
right_operand: "8"

calculates the result:

{
"math": {
"result": 256
}
}

Square and Cube

Calculating square and cube of a value...

{
"value": 5,
"calculation": {}
}
- power:
field: calculation.square
left_operand: "value"
right_operand: "2"
- power:
field: calculation.cube
left_operand: "value"
right_operand: "3"

computes common powers:

{
"value": 5,
"calculation": {
"square": 25,
"cube": 125
}
}

Scientific

Implementing scientific notation...

{
"scientific": {
"coefficient": 2.5,
"exponent": 4
}
}
- power:
field: scientific.value
left_operand: "10"
right_operand: "scientific.exponent"
- multiply:
field: scientific.result
left_operand: "scientific.coefficient"
right_operand: "scientific.value"

calculates 2.5 × 10^4:

{
"scientific": {
"coefficient": 2.5,
"exponent": 4,
"value": 10000,
"result": 25000
}
}

Area and Volume

Calculating area and volume from side length...

{
"cube": {
"side": 3.5
}
}
- power:
field: cube.face_area
left_operand: "cube.side"
right_operand: "2"
- power:
field: cube.volume
left_operand: "cube.side"
right_operand: "3"

computes geometric properties:

{
"cube": {
"side": 3.5,
"face_area": 12.25,
"volume": 42.875
}
}

Compound Interest

Calculating compound interest...

{
"finance": {
"principal": 1000,
"rate": 0.05,
"years": 10
}
}
- set:
field: finance.rate_factor
value: "{{finance.rate + 1}}"
- power:
field: finance.growth_factor
left_operand: "finance.rate_factor"
right_operand: "finance.years"
- multiply:
field: finance.final_amount
left_operand: "finance.principal"
right_operand: "finance.growth_factor"

implements compound interest formula:

{
"finance": {
"principal": 1000,
"rate": 0.05,
"years": 10,
"rate_factor": 1.05,
"growth_factor": 1.6289,
"final_amount": 1628.9
}
}