Skip to content

Commit 6fd8643

Browse files
committed
Add new LogarithmicMean function to Maths category
Added source code .dat file for the function. Added meta data for the function to maths.ini.
1 parent b50ec8a commit 6fd8643

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

collection/690.dat

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
function LogarithmicMean(const X, Y: Double): Double;
2+
begin
3+
if (X <= 0) or (Y <= 0) then
4+
raise SysUtils.EArgumentException.Create(
5+
'Parameters X & Y must both be positive'
6+
);
7+
if Math.SameValue(X, Y) then
8+
Result := X
9+
else
10+
Result := (Y - X) / (System.Ln(Y) - System.Ln(X));
11+
end;

collection/maths.ini

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2211,3 +2211,17 @@ AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tes
22112211
Snip=689.dat
22122212
DelphiXE=Y
22132213
Delphi12A=Y
2214+
2215+
[LogarithmicMean]
2216+
DisplayName="LogarithmicMean"
2217+
DescEx="<p>Returns the logarithmic mean of two positive floating point values, <var>X</var> and <var>Y</var>.</p><p>Raises <var>EArgumentException</var> if either <var>X</var> or <var>Y</var> is not positive.</p>"
2218+
Extra="<p>See <a href="https://www.ryantoomey.org/wiki/Logarithmic_mean_average">Chemepedia</a> for information about the logarithmic mean.</p>"
2219+
Kind=routine
2220+
Units=SysUtils,Math
2221+
SeeAlso=ArithmeticMean_Double,GeometricMean_Double,HarmonicMean_Double
2222+
TestInfo=advanced
2223+
AdvancedTest.Level=unit-tests
2224+
AdvancedTest.URL="https://github.com/delphidabbler/code-snippets/tree/master/tests/Cat-Maths"
2225+
Snip=690.dat
2226+
DelphiXE=Y
2227+
Delphi12A=Y

0 commit comments

Comments
 (0)