Skip to content

Commit

Permalink
Merge pull request #1205 from ChristianGruen/1196
Browse files Browse the repository at this point in the history
1196 Math Functions: math:e, math:sinh, math:cosh, math:tanh
  • Loading branch information
ndw authored May 14, 2024
2 parents a6d6d0b + bc32d5a commit 1aec9ab
Show file tree
Hide file tree
Showing 2 changed files with 180 additions and 12 deletions.
180 changes: 168 additions & 12 deletions specifications/xpath-functions-40/src/function-catalog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2647,6 +2647,32 @@ translate(value := '٢٠٢٣', replace := '٠١٢٣٤٥٦٧٨٩', with := '01234
</fos:example>
</fos:examples>
</fos:function>
<fos:function name="e" prefix="math">
<fos:signatures>
<fos:proto name="e" return-type="xs:double"/>
</fos:signatures>
<fos:properties>
<fos:property>deterministic</fos:property>
<fos:property>context-independent</fos:property>
<fos:property>focus-independent</fos:property>
</fos:properties>
<fos:summary>
<p>Returns an approximation to the mathematical constant <var>e</var>.</p>
</fos:summary>
<fos:rules>
<p>This function returns the <code>xs:double</code> value whose lexical representation is
2.718281828459045e0</p>
</fos:rules>
<fos:examples>
<fos:example>
<fos:test xslt-version="3.0">
<fos:expression>math:pow(math:e(), 0.05 * 3)</fos:expression>
<fos:result>1.161834242728283e0</fos:result>
<fos:postamble>The amount that results after 3 years at an annual rate of 5%.</fos:postamble>
</fos:test>
</fos:example>
</fos:examples>
</fos:function>
<fos:function name="exp" prefix="math">
<fos:signatures>
<fos:proto name="exp" return-type="xs:double?">
Expand Down Expand Up @@ -3269,7 +3295,7 @@ translate(value := '٢٠٢٣', replace := '٠١٢٣٤٥٦٧٨٩', with := '01234
sequence.</p>
<p>If <code>$radians</code> is positive or negative infinity, or <code>NaN</code>,
then the result is <code>NaN</code>.</p>
<p>Otherwise the result is the cosine of <code>$</code><var>radians</var> (which is treated as an angle in
<p>Otherwise the result is the cosine of <code>$radians</code> (which is treated as an angle in
radians) as defined in the <bibref
ref="ieee754-2008"
/> specification of the
Expand Down Expand Up @@ -3440,9 +3466,9 @@ translate(value := '٢٠٢٣', replace := '٠١٢٣٤٥٦٧٨٩', with := '01234
<p>If <code>$value</code> is positive or negative zero, the result is <code>$value</code>.</p>
<p>If <code>$value</code> is <code>NaN</code>, or if its absolute value is greater than one,
then the result is <code>NaN</code>.</p>
<p>In other cases the result is an <code>xs:double</code> value representing an angle
<var>θ</var> in radians in the range -<var>π</var><code>/2 &lt;=
</code><var>θ</var><code> &lt;= +</code><var>π</var><code>/2</code>. </p>
<p>In other cases, the result is an <code>xs:double</code> value representing an angle
<var>θ</var> in radians in the range <code>-math:pi() div 2</code> &lt;=
<var>θ</var> &lt;= <code>math:pi() div 2</code>. </p>
</fos:notes>
<fos:examples>
<fos:example>
Expand Down Expand Up @@ -3512,9 +3538,9 @@ translate(value := '٢٠٢٣', replace := '٠١٢٣٤٥٦٧٨٩', with := '01234
ref="op.numeric"/>. </p>
<p>If <code>$value</code> is <code>NaN</code>, or if its absolute value is greater than one,
then the result is <code>NaN</code>.</p>
<p>In other cases the result is an <code>xs:double</code> value representing an angle
<var>θ</var> in radians in the range <code>0 &lt;= </code><var>θ</var><code> &lt;=
+</code><var>π</var>. </p>
<p>In other cases, the result is an <code>xs:double</code> value representing an angle
<var>θ</var> in radians in the range <code>0</code> &lt;= <var>θ</var> &lt;=
<code>math:pi()</code>. </p>
</fos:notes>
<fos:examples>
<fos:example>
Expand Down Expand Up @@ -3586,9 +3612,9 @@ translate(value := '٢٠٢٣', replace := '٠١٢٣٤٥٦٧٨٩', with := '01234
ref="op.numeric"/>. </p>
<p>If <code>$value</code> is positive or negative zero, the result is <code>$value</code>.</p>
<p>If <code>$value</code> is <code>NaN</code> then the result is <code>NaN</code>.</p>
<p>In other cases the result is an <code>xs:double</code> value representing an angle
<var>θ</var> in radians in the range -<var>π</var><code>/2 &lt;=
</code><var>θ</var><code> &lt;= +</code><var>π</var><code>/2</code>. </p>
<p>In other cases, the result is an <code>xs:double</code> value representing an angle
<var>θ</var> in radians in the range <code>-math:pi() div 2</code> &lt;=
<var>θ</var> &lt;= <code>math:pi() div 2</code>. </p>
</fos:notes>
<fos:examples>
<fos:example>
Expand Down Expand Up @@ -3668,8 +3694,6 @@ translate(value := '٢٠٢٣', replace := '٠١٢٣٤٥٦٧٨٩', with := '01234

</fos:notes>
<fos:examples>


<fos:example>
<fos:test>
<fos:expression>math:atan2(+0.0e0, 0.0e0)</fos:expression>
Expand Down Expand Up @@ -3714,6 +3738,138 @@ translate(value := '٢٠٢٣', replace := '٠١٢٣٤٥٦٧٨٩', with := '01234
</fos:example>
</fos:examples>
</fos:function>
<fos:function name="sinh" prefix="math">
<fos:signatures>
<fos:proto name="sinh" return-type="xs:double?">
<fos:arg name="value" type="xs:double?"/>
</fos:proto>
</fos:signatures>
<fos:properties>
<fos:property>deterministic</fos:property>
<fos:property>context-independent</fos:property>
<fos:property>focus-independent</fos:property>
</fos:properties>
<fos:summary>
<p>Returns the hyperbolic sine of the argument.</p>
</fos:summary>
<fos:rules>
<p>If <code>$value</code> is the empty sequence, the function returns the empty
sequence.</p>
<p>Otherwise the result is the hyperbolic sine of <code>$value</code> as defined in the
<bibref ref="ieee754-2008"/> specification of the <code>sinh</code> function applied
to 64-bit binary floating point values. </p>
</fos:rules>
<fos:notes>
<p>The treatment of the <code>invalidOperation</code> and <code>underflow</code> exceptions
is defined in <specref ref="op.numeric"/>. </p>
<p>If <code>$value</code> is positive or negative zero, the result is
<code>$value</code>.</p>
<p>If <code>$value</code> is positive or negative infinity, or <code>NaN</code>,
the result is <code>NaN</code>.</p>
</fos:notes>
<fos:examples>
<fos:example>
<fos:test>
<fos:expression>math:sinh(1)</fos:expression>
<fos:result>1.1752011936438014</fos:result>
</fos:test>
<fos:test>
<fos:expression>math:sinh(math:pi())</fos:expression>
<fos:result>11.548739357257748</fos:result>
</fos:test>
</fos:example>
</fos:examples>
</fos:function>
<fos:function name="cosh" prefix="math">
<fos:signatures>
<fos:proto name="cosh" return-type="xs:double?">
<fos:arg name="value" type="xs:double?"/>
</fos:proto>
</fos:signatures>
<fos:properties>
<fos:property>deterministic</fos:property>
<fos:property>context-independent</fos:property>
<fos:property>focus-independent</fos:property>
</fos:properties>
<fos:summary>
<p>Returns the hyperbolic cosine of the argument.</p>
</fos:summary>
<fos:rules>
<p>If <code>$value</code> is the empty sequence, the function returns the empty
sequence.</p>
<p>Otherwise the result is the hyperbolic cosine of <code>$value</code> as defined in the
<bibref ref="ieee754-2008"/> specification of the <code>cosh</code> function applied
to 64-bit binary floating point values. </p>
</fos:rules>
<fos:notes>
<p>The treatment of the <code>invalidOperation</code> and <code>underflow</code> exceptions
is defined in <specref ref="op.numeric"/>. </p>
<p>If <code>$value</code> is positive or negative zero, the result is
<code>1</code>.</p>
<p>If <code>$value</code> is positive or negative infinity,
the result is <code>INF</code>.</p>
<p>If <code>$value</code> is <code>NaN</code>,
the result is <code>NaN</code>.</p>
<p>In other cases, the result is an <code>xs:double</code> in the range
<code>+1.0</code> to <code>INF</code>.</p>
</fos:notes>
<fos:examples>
<fos:example>
<fos:test>
<fos:expression>math:cosh(0)</fos:expression>
<fos:result>1</fos:result>
</fos:test>
<fos:test>
<fos:expression>math:cosh(math:pi())</fos:expression>
<fos:result>11.591953275521519</fos:result>
</fos:test>
</fos:example>
</fos:examples>
</fos:function>
<fos:function name="tanh" prefix="math">
<fos:signatures>
<fos:proto name="tanh" return-type="xs:double?">
<fos:arg name="value" type="xs:double?"/>
</fos:proto>
</fos:signatures>
<fos:properties>
<fos:property>deterministic</fos:property>
<fos:property>context-independent</fos:property>
<fos:property>focus-independent</fos:property>
</fos:properties>
<fos:summary>
<p>Returns the hyperbolic tangent of the argument.</p>
</fos:summary>
<fos:rules>
<p>If <code>$value</code> is the empty sequence, the function returns the empty
sequence.</p>
<p>Otherwise the result is the hyperbolic tangent of <code>$value</code> as defined in the
<bibref ref="ieee754-2008"/> specification of the <code>tanh</code> function applied
to 64-bit binary floating point values. </p>
</fos:rules>
<fos:notes>
<p>The treatment of the <code>invalidOperation</code> and <code>underflow</code> exceptions
is defined in <specref ref="op.numeric"/>. </p>
<p>If <code>$value</code> is positive or negative zero, the result is
<code>$value</code>.</p>
<p>If <code>$value</code> is positive infinity, the result is <code>+1.0</code>.</p>
<p>If <code>$value</code> is negative infinity, the result is <code>-1.0</code>.</p>
<p>In other cases, the result is an <code>xs:double</code> in the range
<code>-1.0</code> to <code>+1.0</code>.</p>
</fos:notes>
<fos:examples>
<fos:example>
<fos:test>
<fos:expression>math:tanh(1)</fos:expression>
<fos:result>0.7615941559557649</fos:result>
</fos:test>
<fos:test>
<fos:expression>math:tanh(math:pi())</fos:expression>
<fos:result>0.99627207622075</fos:result>
</fos:test>
</fos:example>
</fos:examples>
</fos:function>
<fos:function name="codepoints-to-string" prefix="fn">
<fos:signatures>
<fos:proto name="codepoints-to-string" return-type="xs:string">
Expand Down
12 changes: 12 additions & 0 deletions specifications/xpath-functions-40/src/xpath-functions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2339,6 +2339,9 @@ string conversion of the number as obtained above, and the appropriate <var>suff
<div3 id="func-math-pi">
<head><?function math:pi?></head>
</div3>
<div3 id="func-math-e">
<head><?function math:e?></head>
</div3>
<div3 id="func-math-exp">
<head><?function math:exp?></head>
</div3>
Expand Down Expand Up @@ -2378,6 +2381,15 @@ string conversion of the number as obtained above, and the appropriate <var>suff
<div3 id="func-math-atan2">
<head><?function math:atan2?></head>
</div3>
<div3 id="func-math-sinh">
<head><?function math:sinh?></head>
</div3>
<div3 id="func-math-cosh">
<head><?function math:cosh?></head>
</div3>
<div3 id="func-math-tanh">
<head><?function math:tanh?></head>
</div3>
</div2>
<div2 id="random-numbers">
<head>Random Numbers</head>
Expand Down

0 comments on commit 1aec9ab

Please sign in to comment.