@@ -858,7 +858,7 @@ defmodule Complex do
858
858
859
859
### See also
860
860
861
- `ln /1`
861
+ `log /1`
862
862
863
863
### Examples
864
864
@@ -893,38 +893,41 @@ defmodule Complex do
893
893
894
894
@ doc """
895
895
Returns a new complex that is the complex natural log of the provided
896
- complex number, $ln (z) = log_e(z)$.
896
+ complex number, $log (z) = log_e(z)$.
897
897
898
898
### See also
899
899
900
900
`exp/1`
901
901
902
902
### Examples
903
903
904
- iex> Complex.ln (Complex.from_polar(2,:math.pi))
904
+ iex> Complex.log (Complex.from_polar(2,:math.pi))
905
905
%Complex{im: 3.141592653589793, re: 0.6931471805599453}
906
906
907
907
"""
908
- @ spec ln ( t | number | non_finite_number ) :: t | number | non_finite_number
909
- def ln ( z )
910
- def ln ( :infinity ) , do: :infinity
911
- def ln ( :neg_infinity ) , do: new ( :infinity , :math . pi ( ) )
912
- def ln ( :nan ) , do: :nan
913
- def ln ( n ) when is_number ( n ) and n == 0 , do: :neg_infinity
914
- def ln ( n ) when is_number ( n ) and n < 0 , do: :nan
915
- def ln ( n ) when is_number ( n ) , do: :math . log ( n )
908
+ @ spec log ( t | number | non_finite_number ) :: t | number | non_finite_number
909
+ def log ( z )
910
+ def log ( :infinity ) , do: :infinity
911
+ def log ( :neg_infinity ) , do: new ( :infinity , :math . pi ( ) )
912
+ def log ( :nan ) , do: :nan
913
+ def log ( n ) when is_number ( n ) and n == 0 , do: :neg_infinity
914
+ def log ( n ) when is_number ( n ) and n < 0 , do: :nan
915
+ def log ( n ) when is_number ( n ) , do: :math . log ( n )
916
916
917
- def ln ( z = % Complex { } ) do
918
- new ( ln ( abs ( z ) ) , atan2 ( z . im , z . re ) )
917
+ def log ( z = % Complex { } ) do
918
+ new ( log ( abs ( z ) ) , atan2 ( z . im , z . re ) )
919
919
end
920
920
921
+ @ deprecated "Use log/1 instead"
922
+ def ln ( x ) , do: log ( x )
923
+
921
924
@ doc """
922
925
Returns a new complex that is the complex log base 10 of the provided
923
926
complex number.
924
927
925
928
### See also
926
929
927
- `ln /1`
930
+ `log /1`
928
931
929
932
### Examples
930
933
@@ -936,15 +939,15 @@ defmodule Complex do
936
939
def log10 ( z )
937
940
938
941
def log10 ( :infinity ) , do: :infinity
939
- def log10 ( :neg_infinity ) , do: divide ( ln ( :neg_infinity ) , :math . log ( 10 ) )
942
+ def log10 ( :neg_infinity ) , do: divide ( log ( :neg_infinity ) , :math . log ( 10 ) )
940
943
def log10 ( :nan ) , do: :nan
941
944
def log10 ( n ) when is_number ( n ) and n == 0 , do: :neg_infinity
942
945
def log10 ( n ) when is_number ( n ) and n < 0 , do: :nan
943
946
944
947
def log10 ( n ) when is_number ( n ) , do: :math . log10 ( n )
945
948
946
949
def log10 ( z = % Complex { } ) do
947
- divide ( ln ( z ) , new ( :math . log ( 10.0 ) , 0.0 ) )
950
+ divide ( log ( z ) , new ( :math . log ( 10.0 ) , 0.0 ) )
948
951
end
949
952
950
953
@ doc """
@@ -953,7 +956,7 @@ defmodule Complex do
953
956
954
957
### See also
955
958
956
- `ln /1`, `log10/1`
959
+ `log /1`, `log10/1`
957
960
958
961
### Examples
959
962
@@ -965,15 +968,15 @@ defmodule Complex do
965
968
def log2 ( z )
966
969
967
970
def log2 ( :infinity ) , do: :infinity
968
- def log2 ( :neg_infinity ) , do: divide ( ln ( :neg_infinity ) , :math . log ( 2 ) )
971
+ def log2 ( :neg_infinity ) , do: divide ( log ( :neg_infinity ) , :math . log ( 2 ) )
969
972
def log2 ( :nan ) , do: :nan
970
973
def log2 ( n ) when is_number ( n ) and n == 0 , do: :neg_infinity
971
974
def log2 ( n ) when is_number ( n ) and n < 0 , do: :nan
972
975
973
976
def log2 ( n ) when is_number ( n ) , do: :math . log2 ( n )
974
977
975
978
def log2 ( z = % Complex { } ) do
976
- divide ( ln ( z ) , new ( :math . log ( 2.0 ) , 0.0 ) )
979
+ divide ( log ( z ) , new ( :math . log ( 2.0 ) , 0.0 ) )
977
980
end
978
981
979
982
@ doc """
@@ -982,7 +985,7 @@ defmodule Complex do
982
985
983
986
### See also
984
987
985
- `ln /1`, `log10/1`
988
+ `log /1`, `log10/1`
986
989
987
990
### Examples
988
991
@@ -1043,7 +1046,7 @@ defmodule Complex do
1043
1046
rho = abs ( x )
1044
1047
theta = phase ( x )
1045
1048
s = multiply ( pow ( rho , y . re ) , exp ( multiply ( negate ( y . im ) , theta ) ) )
1046
- r = add ( multiply ( y . re , theta ) , multiply ( y . im , ln ( rho ) ) )
1049
+ r = add ( multiply ( y . re , theta ) , multiply ( y . im , log ( rho ) ) )
1047
1050
new ( multiply ( s , cos ( r ) ) , multiply ( s , sin ( r ) ) )
1048
1051
end
1049
1052
end
@@ -1145,11 +1148,11 @@ defmodule Complex do
1145
1148
1146
1149
def asin ( z = % Complex { } ) do
1147
1150
i = new ( 0.0 , 1.0 )
1148
- # result = -i*ln (i*z + sqrt(1.0-z*z))
1149
- # result = -i*ln (t1 + sqrt(t2))
1151
+ # result = -i*log (i*z + sqrt(1.0-z*z))
1152
+ # result = -i*log (t1 + sqrt(t2))
1150
1153
t1 = multiply ( i , z )
1151
1154
t2 = subtract ( new ( 1.0 , 0.0 ) , multiply ( z , z ) )
1152
- multiply ( negate ( i ) , ln ( add ( t1 , sqrt ( t2 ) ) ) )
1155
+ multiply ( negate ( i ) , log ( add ( t1 , sqrt ( t2 ) ) ) )
1153
1156
end
1154
1157
1155
1158
@ doc """
@@ -1220,10 +1223,10 @@ defmodule Complex do
1220
1223
def acos ( z = % Complex { } ) do
1221
1224
i = new ( 0.0 , 1.0 )
1222
1225
one = new ( 1.0 , 0.0 )
1223
- # result = -i*ln (z + sqrt(z*z-1.0))
1224
- # result = -i*ln (z + sqrt(t1))
1226
+ # result = -i*log (z + sqrt(z*z-1.0))
1227
+ # result = -i*log (z + sqrt(t1))
1225
1228
t1 = subtract ( multiply ( z , z ) , one )
1226
- multiply ( negate ( i ) , ln ( add ( z , sqrt ( t1 ) ) ) )
1229
+ multiply ( negate ( i ) , log ( add ( z , sqrt ( t1 ) ) ) )
1227
1230
end
1228
1231
1229
1232
@ doc """
@@ -1276,11 +1279,11 @@ defmodule Complex do
1276
1279
1277
1280
def atan ( z = % Complex { } ) do
1278
1281
i = new ( 0.0 , 1.0 )
1279
- # result = 0.5*i*(ln (1-i*z)-ln (1+i*z))
1282
+ # result = 0.5*i*(log (1-i*z)-log (1+i*z))
1280
1283
t1 = multiply ( new ( 0.5 , 0.0 ) , i )
1281
1284
t2 = subtract ( new ( 1.0 , 0.0 ) , multiply ( i , z ) )
1282
1285
t3 = add ( new ( 1.0 , 0.0 ) , multiply ( i , z ) )
1283
- multiply ( t1 , subtract ( ln ( t2 ) , ln ( t3 ) ) )
1286
+ multiply ( t1 , subtract ( log ( t2 ) , log ( t3 ) ) )
1284
1287
end
1285
1288
1286
1289
@ doc """
@@ -1377,11 +1380,11 @@ defmodule Complex do
1377
1380
1378
1381
def acot ( z ) do
1379
1382
i = new ( 0.0 , 1.0 )
1380
- # result = 0.5*i*(ln (1-i/z)-ln (1+i/z))
1383
+ # result = 0.5*i*(log (1-i/z)-log (1+i/z))
1381
1384
t1 = multiply ( new ( 0.5 , 0.0 ) , i )
1382
1385
t2 = subtract ( new ( 1.0 , 0.0 ) , divide ( i , z ) )
1383
1386
t3 = add ( new ( 1.0 , 0.0 ) , divide ( i , z ) )
1384
- multiply ( t1 , subtract ( ln ( t2 ) , ln ( t3 ) ) )
1387
+ multiply ( t1 , subtract ( log ( t2 ) , log ( t3 ) ) )
1385
1388
end
1386
1389
1387
1390
@ doc """
@@ -1433,15 +1436,15 @@ defmodule Complex do
1433
1436
1434
1437
def asec ( z = % Complex { } ) do
1435
1438
i = new ( 0.0 , 1.0 )
1436
- # result = -i*ln (i*sqrt(1-1/(z*z))+1/z)
1437
- # result = -i*ln (i*sqrt(1-t2)+t1)
1439
+ # result = -i*log (i*sqrt(1-1/(z*z))+1/z)
1440
+ # result = -i*log (i*sqrt(1-t2)+t1)
1438
1441
t1 = divide ( 1 , z )
1439
1442
t2 = square ( t1 )
1440
- # result = -i*ln (i*sqrt(t3)+t1)
1441
- # result = -i*ln (t4+t1)
1443
+ # result = -i*log (i*sqrt(t3)+t1)
1444
+ # result = -i*log (t4+t1)
1442
1445
t3 = subtract ( 1 , t2 )
1443
1446
t4 = multiply ( i , sqrt ( t3 ) )
1444
- multiply ( negate ( i ) , ln ( add ( t4 , t1 ) ) )
1447
+ multiply ( negate ( i ) , log ( add ( t4 , t1 ) ) )
1445
1448
end
1446
1449
1447
1450
@ doc """
@@ -1491,15 +1494,15 @@ defmodule Complex do
1491
1494
def acsc ( z = % Complex { } ) do
1492
1495
i = new ( 0.0 , 1.0 )
1493
1496
one = new ( 1.0 , 0.0 )
1494
- # result = -i*ln (sqrt(1-1/(z*z))+i/z)
1495
- # result = -i*ln (sqrt(1-t2)+t1)
1497
+ # result = -i*log (sqrt(1-1/(z*z))+i/z)
1498
+ # result = -i*log (sqrt(1-t2)+t1)
1496
1499
t1 = divide ( i , z )
1497
1500
t2 = divide ( one , multiply ( z , z ) )
1498
- # result = -i*ln (sqrt(t3)+t1)
1499
- # result = -i*ln (t4+t1)
1501
+ # result = -i*log (sqrt(t3)+t1)
1502
+ # result = -i*log (t4+t1)
1500
1503
t3 = subtract ( one , t2 )
1501
1504
t4 = sqrt ( t3 )
1502
- multiply ( negate ( i ) , ln ( add ( t4 , t1 ) ) )
1505
+ multiply ( negate ( i ) , log ( add ( t4 , t1 ) ) )
1503
1506
end
1504
1507
1505
1508
@ doc """
@@ -1565,12 +1568,12 @@ defmodule Complex do
1565
1568
def asinh ( :nan ) , do: :nan
1566
1569
1567
1570
def asinh ( z ) do
1568
- # result = ln (z+sqrt(z*z+1))
1569
- # result = ln (z+sqrt(t1))
1570
- # result = ln (t2)
1571
+ # result = log (z+sqrt(z*z+1))
1572
+ # result = log (z+sqrt(t1))
1573
+ # result = log (t2)
1571
1574
t1 = add ( multiply ( z , z ) , 1 )
1572
1575
t2 = add ( z , sqrt ( t1 ) )
1573
- ln ( t2 )
1576
+ log ( t2 )
1574
1577
end
1575
1578
1576
1579
@ doc """
@@ -1633,12 +1636,12 @@ defmodule Complex do
1633
1636
def acosh ( :nan ) , do: :nan
1634
1637
1635
1638
def acosh ( z ) do
1636
- # result = ln (z+sqrt(z*z-1))
1637
- # result = ln (z+sqrt(t1))
1638
- # result = ln (t2)
1639
+ # result = log (z+sqrt(z*z-1))
1640
+ # result = log (z+sqrt(t1))
1641
+ # result = log (t2)
1639
1642
t1 = subtract ( multiply ( z , z ) , 1 )
1640
1643
t2 = add ( z , sqrt ( t1 ) )
1641
- ln ( t2 )
1644
+ log ( t2 )
1642
1645
end
1643
1646
1644
1647
@ doc """
@@ -1695,13 +1698,13 @@ defmodule Complex do
1695
1698
def atanh ( z ) do
1696
1699
one = new ( 1.0 , 0.0 )
1697
1700
p5 = new ( 0.5 , 0.0 )
1698
- # result = 0.5*(ln ((1+z)/(1-z)))
1699
- # result = 0.5*(ln (t2/t1))
1700
- # result = 0.5*(ln (t3))
1701
+ # result = 0.5*(log ((1+z)/(1-z)))
1702
+ # result = 0.5*(log (t2/t1))
1703
+ # result = 0.5*(log (t3))
1701
1704
t1 = subtract ( one , z )
1702
1705
t2 = add ( one , z )
1703
1706
t3 = divide ( t2 , t1 )
1704
- multiply ( p5 , ln ( t3 ) )
1707
+ multiply ( p5 , log ( t3 ) )
1705
1708
end
1706
1709
1707
1710
@ doc """
@@ -1742,13 +1745,13 @@ defmodule Complex do
1742
1745
"""
1743
1746
@ spec asech ( t | number | non_finite_number ) :: t | number | non_finite_number
1744
1747
def asech ( z ) do
1745
- # result = ln (1/z+sqrt(1/z+1)*sqrt(1/z-1))
1746
- # result = ln (t1+sqrt(t1+1)*sqrt(t1-1))
1747
- # result = ln (t1+t2*t3)
1748
+ # result = log (1/z+sqrt(1/z+1)*sqrt(1/z-1))
1749
+ # result = log (t1+sqrt(t1+1)*sqrt(t1-1))
1750
+ # result = log (t1+t2*t3)
1748
1751
t1 = divide ( 1 , z )
1749
1752
t2 = sqrt ( add ( t1 , 1 ) )
1750
1753
t3 = sqrt ( subtract ( t1 , 1 ) )
1751
- ln ( add ( t1 , multiply ( t2 , t3 ) ) )
1754
+ log ( add ( t1 , multiply ( t2 , t3 ) ) )
1752
1755
end
1753
1756
1754
1757
@ doc """
@@ -1787,13 +1790,13 @@ defmodule Complex do
1787
1790
"""
1788
1791
@ spec acsch ( t | number | non_finite_number ) :: t | number | non_finite_number
1789
1792
def acsch ( z ) do
1790
- # result = ln (1/z+sqrt(1/(z*z)+1))
1791
- # result = ln (t1+sqrt(t2+1))
1792
- # result = ln (t1+t3)
1793
+ # result = log (1/z+sqrt(1/(z*z)+1))
1794
+ # result = log (t1+sqrt(t2+1))
1795
+ # result = log (t1+t3)
1793
1796
t1 = divide ( 1 , z )
1794
1797
t2 = divide ( 1 , multiply ( z , z ) )
1795
1798
t3 = sqrt ( add ( t2 , 1 ) )
1796
- ln ( add ( t1 , t3 ) )
1799
+ log ( add ( t1 , t3 ) )
1797
1800
end
1798
1801
1799
1802
@ doc """
@@ -1834,13 +1837,13 @@ defmodule Complex do
1834
1837
"""
1835
1838
@ spec acoth ( t | number | non_finite_number ) :: t | number | non_finite_number
1836
1839
def acoth ( z ) do
1837
- # result = 0.5*(ln (1+1/z)-ln (1-1/z))
1838
- # result = 0.5*(ln (1+t1)-ln (1-t1))
1839
- # result = 0.5*(ln (t2)-ln (t3))
1840
+ # result = 0.5*(log (1+1/z)-log (1-1/z))
1841
+ # result = 0.5*(log (1+t1)-log (1-t1))
1842
+ # result = 0.5*(log (t2)-log (t3))
1840
1843
t1 = divide ( 1 , z )
1841
1844
t2 = add ( 1 , t1 )
1842
1845
t3 = subtract ( 1 , t1 )
1843
- multiply ( 0.5 , subtract ( ln ( t2 ) , ln ( t3 ) ) )
1846
+ multiply ( 0.5 , subtract ( log ( t2 ) , log ( t3 ) ) )
1844
1847
end
1845
1848
1846
1849
@ doc ~S"""
0 commit comments