\(\renewcommand\AA{\unicode{x212B}}\)

Power v1

Summary

The Power algorithm will raise the base workspace to a particular power. Corresponding error values will be created.

See Also

Exponential, Logarithm

Properties

Name

Direction

Type

Default

Description

InputWorkspace

Input

MatrixWorkspace

Mandatory

The name of the input workspace

OutputWorkspace

Output

MatrixWorkspace

Mandatory

The name to use for the output workspace (can be the same as the input one).

Exponent

Input

number

1

The exponent with which to raise base values in the base workspace to.

Description

The algorithm will raise the InputWorkspace to the power of the Exponent. When acting on an event workspace, the output will be a Workspace2D, with the default binning from the original workspace.

Errors

Defining the power algorithm as: \(y = \left ( a^b \right )\), we can describe the error as: \(s_{y} = by\left ( s_{a}/a \right )\), where \(s_{y}\) is the error in the result y and \(s_{a}\) is the error in the input a.

Usage

Example - Square each Y value:

# Create a 2 spectrum workspace with Y values 1->8
dataX = [0,1,2,3,4,
         0,1,2,3,4]
dataY = [1,2,3,4,
         5,6,7,8]
data_ws = CreateWorkspace(dataX, dataY, NSpec=2)
result_ws = Power(data_ws, 2)

print("Squared values of first spectrum: {}".format(result_ws.readY(0)))
print("Squared values of second spectrum: {}".format(result_ws.readY(1)))

Output:

Squared values of first spectrum: [  1.   4.   9.  16.]
Squared values of second spectrum: [ 25.  36.  49.  64.]

Categories: AlgorithmIndex | Arithmetic

Source

C++ header: Power.h

C++ source: Power.cpp