This module contains Math utility functions Introduced in DataWeave 2.4.0. Supported by Mule 4.4.0 and later.

Functions

acos

acos(Number): Number | NaN

Returns the arc cosine of a value; the returned angle is in the range 0.0 through pi. Special case: - Argument absolute value is greater than 1, then the result is NaN.

Introduced in DataWeave 2.4.0. Supported by Mule 4.4.0 and later. ===== Parameters

Name Description

angle

the value whose arc cosine is to be returned.

Example

This example shows how the acos behaves under different inputs.

Source
1
2
3
4
5
6
7
8
9
%dw 2.0
import * from dw::util::Math
output application/json
---
{
  "acos0": acos(0),
  "acos13": acos(0.13),
  "acos-1": acos(-1)
}
Output
1
2
3
4
5
{
   "acos0": 1.5707963267948966,
   "acos13": 1.440427347091751,
   "acos-1": 3.141592653589793
 }

asin

asin(Number): Number

Returns the arc sine of a value; the returned angle is in the range -pi/2 through pi/2. Special cases: - Argument absolute value is greater than 1, then the result is NaN.

Introduced in DataWeave 2.4.0. Supported by Mule 4.4.0 and later.

Parameters
Name Description

angle

the value whose arc sine is to be returned.

Example

This example shows how the asin behaves under different inputs.

Source
1
2
3
4
5
6
7
8
9
10
11
12
%dw 2.0
output application/json
---
%dw 2.0
import * from dw::util::Math
output application/json
---
{
  "asin0": asin(0),
  "asin13": asin(0.13),
  "asin-1": asin(-1)
}
Output
1
2
3
4
5
{
   "asin0": 0.0,
   "asin13": 0.1303689797031455,
   "asin-1": -1.5707963267948966
 }

atan

atan(Number): Number

Returns the arc tangent of a value; the returned angle is in the range -pi/2 through pi/2.

Introduced in DataWeave 2.4.0. Supported by Mule 4.4.0 and later. ===== Parameters

Name Description

angle

the value whose arc tangent is to be returned.

Example

This example shows how the atan behaves under different inputs.

Source
1
2
3
4
5
6
7
8
9
%dw 2.0
import * from dw::util::Math
output application/json
---
{
  "atan0":  atan(0),
  "atan13": atan(0.13),
  "atan-1": atan(-1)
}
Output
1
2
3
4
5
{
  "atan0": 1.5707963267948966,
  "atan13": 1.440427347091751,
  "atan-1": 3.141592653589793
}

cos

cos(Number): Number

Returns the trigonometric cosine of an angle.

Introduced in DataWeave 2.4.0. Supported by Mule 4.4.0 and later.

Parameters
Name Description

angle

an angle, in radians

Example

This example shows how the cos behaves under different inputs.

Source
1
2
3
4
5
6
7
8
9
10
11
12
%dw 2.0
output application/json
---
%dw 2.0
import * from dw::util::Math
output application/json
---
{
  "cos0": cos(0),
  "cos13": cos(0.13),
  "cos-1": cos(-1)
}
Output
1
2
3
4
5
{
  "cos0": 1.0,
  "cos13": 0.9915618937147881,
  "cos-1": 0.5403023058681398
}

log10

log10(Number): Number | NaN

Returns the base 10 logarithm of a double value

Introduced in DataWeave 2.4.0. Supported by Mule 4.4.0 and later. ===== Parameters

Name Description

a

a value

Example

This example shows how the log10 behaves under different inputs.

Source
1
2
3
4
5
6
7
8
9
%dw 2.0
import * from dw::util::Math
output application/json
---
{
  "log1010":  log10(10),
  "log1013": log10(0.13),
  "log10-20": log10(-20)
}
Output
1
2
3
4
5
 {
    "log1010": 2.302585092994046,
    "log1013": -2.0402208285265546,
    "log10-20": null
  }

logn

logn(Number): Number | NaN

Returns the natural logarithm (base e) of a double value. Special cases: - Argument less or equal to zero , then the result is NaN.

Introduced in DataWeave 2.4.0. Supported by Mule 4.4.0 and later. ===== Parameters

Name Description

a

a value

Example

This example shows how the logn behaves under different inputs.

Source
1
2
3
4
5
6
7
8
9
10
11
12
%dw 2.0
output application/json
---
%dw 2.0
import * from dw::util::Math
output application/json
---
{
   "logn10":  logn(10),
   "logn13": logn(0.13),
   "logn-20": logn(-20)
 }
Output
1
2
3
4
5
{
   "logn10": 2.302585092994046,
   "logn13": -2.0402208285265546,
   "logn-20": null
 }

sin

sin(Number): Number

Returns the trigonometric sine of an angle.

Introduced in DataWeave 2.4.0. Supported by Mule 4.4.0 and later.

Parameters
Name Description

angle

an angle, in radians.

Example

This example shows how the sin behaves under different inputs.

Source
1
2
3
4
5
6
7
8
9
%dw 2.0
import * from dw::util::Math
output application/json
---
{
  "sin0": sin(0),
  "sin13": sin(0.13),
  "sin-1": sin(-1)
}
Output
1
2
3
4
5
{
  "sin0": 0.0,
  "sin13": 0.12963414261969486,
  "sin-1": -0.8414709848078965
}

tan

tan(Number): Number

Returns the trigonometric tangent of an angle.

Introduced in DataWeave 2.4.0. Supported by Mule 4.4.0 and later.

Parameters
Name Description

angle

an angle, in radians

Example

This example shows how the tan behaves under different inputs.

Source
1
2
3
4
5
6
7
8
9
10
11
12
%dw 2.0
output application/json
---
%dw 2.0
 import * from dw::util::Math
 output application/json
 ---
 {
   "tan0": tan(0),
   "tan13": tan(0.13),
   "tan-1": tan(-1)
 }
Output
1
2
3
4
5
{
   "tan0": 0.0,
   "tan13": 0.13073731800446006,
   "tan-1": -1.5574077246549023
 }

toDegrees

toDegrees(Number): Number

Converts an angle measured in radians to an approximately equivalent angle measured in degrees.

Introduced in DataWeave 2.4.0. Supported by Mule 4.4.0 and later. ===== Parameters

Name Description

angrad

an angle, in radians

Example

This example shows how the toDegrees behaves under different inputs.

Source
1
2
3
4
5
6
7
8
9
%dw 2.0
import * from dw::util::Math
output application/json
---
{
  "toDegrees0.17":  toDegrees(0.174),
  "toDegrees0": toDegrees(0),
  "toDegrees-20": toDegrees(-0.20)
}
Output
1
2
3
4
5
{
   "toDegrees0.17": 9.969465635276323832571267395889251,
   "toDegrees0": 0E+19,
   "toDegrees-20": -11.45915590261646417536927286883822
 }

toRadians

toRadians(Number): Number

Converts an angle measured in degrees to an approximately equivalent angle measured in radians

Introduced in DataWeave 2.4.0. Supported by Mule 4.4.0 and later. ===== Parameters

Name Description

angdeg

an angle, in degree

Example

This example shows how the toRadians behaves under different inputs.

Source
1
2
3
4
5
6
7
8
9
%dw 2.0
import * from dw::util::Math
output application/json
---
{
  "toRadians10":  toRadians(10),
  "toRadians013": toRadians(0.13),
  "toRadians-20": toRadians(-20)
}
Output
1
2
3
4
5
6
{
   "toRadians10": 0.1745329251994329576922222222222222,
   "toRadians013": 0.002268928027592628449998888888888889,
   "toRadians-20": -0.3490658503988659153844444444444444
 }

Variables

E

The constant value of E, the base of the natural logarithms.

Introduced in DataWeave 2.4.0. Supported by Mule 4.4.0 and later.

PI

The constant value of PI, the ratio of the circumference of a circle to its diameter.

Introduced in DataWeave 2.4.0. Supported by Mule 4.4.0 and later.