@@ -528,3 +528,81 @@ pub fn subtract_test() {
528
528
|> float . subtract ( 2.0 , _)
529
529
|> should . equal ( -1.0 )
530
530
}
531
+
532
+ pub fn logarithm_test ( ) {
533
+ float . logarithm ( 1.0 )
534
+ |> result . unwrap ( or : 1.0 )
535
+ |> float . loosely_equals ( with : 0.0 , tolerating : 0.001 )
536
+ |> should . be_true
537
+
538
+ float . logarithm ( 2.718281828459045 )
539
+ |> result . unwrap ( or : 0.0 )
540
+ |> float . loosely_equals ( with : 1.0 , tolerating : 0.001 )
541
+ |> should . be_true
542
+
543
+ float . logarithm ( 10.0 )
544
+ |> result . unwrap ( or : 0.0 )
545
+ |> float . loosely_equals ( with : 2.302585092994046 , tolerating : 0.001 )
546
+ |> should . be_true
547
+
548
+ float . logarithm ( 100.0 )
549
+ |> result . unwrap ( or : 0.0 )
550
+ |> float . loosely_equals ( with : 4.605170185988092 , tolerating : 0.001 )
551
+ |> should . be_true
552
+
553
+ float . logarithm ( 0.5 )
554
+ |> result . unwrap ( or : 0.0 )
555
+ |> float . loosely_equals ( with : -0.6931471805599453 , tolerating : 0.001 )
556
+ |> should . be_true
557
+
558
+ float . logarithm ( 0.1 )
559
+ |> result . unwrap ( or : 0.0 )
560
+ |> float . loosely_equals ( with : -2.3025850929940455 , tolerating : 0.001 )
561
+ |> should . be_true
562
+
563
+ float . logarithm ( 0.0 )
564
+ |> should . equal ( Error ( Nil ) )
565
+
566
+ float . logarithm ( -1.0 )
567
+ |> should . equal ( Error ( Nil ) )
568
+
569
+ float . logarithm ( -100.0 )
570
+ |> should . equal ( Error ( Nil ) )
571
+
572
+ float . logarithm ( -0.1 )
573
+ |> should . equal ( Error ( Nil ) )
574
+ }
575
+
576
+ pub fn exponential_test ( ) {
577
+ float . exponential ( 0.0 )
578
+ |> float . loosely_equals ( with : 1.0 , tolerating : 0.001 )
579
+ |> should . be_true
580
+
581
+ float . exponential ( 1.0 )
582
+ |> float . loosely_equals ( with : 2.718281828459045 , tolerating : 0.001 )
583
+ |> should . be_true
584
+
585
+ float . exponential ( 2.0 )
586
+ |> float . loosely_equals ( with : 7.38905609893065 , tolerating : 0.001 )
587
+ |> should . be_true
588
+
589
+ float . exponential ( -1.0 )
590
+ |> float . loosely_equals ( with : 0.36787944117144233 , tolerating : 0.001 )
591
+ |> should . be_true
592
+
593
+ float . exponential ( 5.0 )
594
+ |> float . loosely_equals ( with : 148.4131591025766 , tolerating : 0.001 )
595
+ |> should . be_true
596
+
597
+ float . exponential ( -5.0 )
598
+ |> float . loosely_equals ( with : 0.006737946999085467 , tolerating : 0.001 )
599
+ |> should . be_true
600
+
601
+ float . exponential ( 0.000001 )
602
+ |> float . loosely_equals ( with : 1.0000010000005 , tolerating : 0.001 )
603
+ |> should . be_true
604
+
605
+ float . exponential ( -100.0 )
606
+ |> float . loosely_equals ( with : 3.720075976020836e-44 , tolerating : 0.001 )
607
+ |> should . be_true
608
+ }
0 commit comments