diff --git a/base/special/logaddexp/README.md b/base/special/logaddexp/README.md index 63d60e0f6..2bb582f3c 100644 --- a/base/special/logaddexp/README.md +++ b/base/special/logaddexp/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2018 The Stdlib Authors. +Copyright (c) 2024 The Stdlib Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -85,6 +85,99 @@ for ( i = 0; i < x.length; i++ ) { + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/math/base/special/logaddexp.h" +``` + +#### stdlib_base_logaddexp( x, y ) + +Evaluates the [natural logarithm][@stdlib/math/base/special/ln] of `exp(x) + exp(y)`. + +```c +double out = stdlib_base_logaddexp( 90.0, 90.0 ); +// returns ~90.6931 + +out = stdlib_base_logaddexp( -20.0, 90.0 ); +// returns 90.0 +``` + +The function accepts the following arguments: + +- **x**: `[in] double` input value. +- **y**: `[in] double` input value. + +```c +double stdlib_base_logaddexp( const double x, const double y ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/math/base/special/logaddexp.h" +#include +#include + +int main( void ) { + double x; + double y; + double v; + int i; + + for ( i = 0; i < 100; i++ ) { + x = ( ( (double)rand() / (double)RAND_MAX ) * 200.0 ) - 100.0; + y = ( ( (double)rand() / (double)RAND_MAX ) * 200.0 ) - 100.0; + v = stdlib_base_logaddexp( x, y ); + printf( "x: %lf, y: %lf, logaddexp(x, y): %lf\n", x, y, v ); + } +} +``` + +
+ + + +
+ + +