#include <stdio.h>
#include <math.h>
double f( double x, double a, double k) {
double result;
if ( a == 0 || x == 0 || x == a) {
printf ( "Cannot compute a function for x = %.2lf\n " , x
) ; return 0 ;
}
result
= pow ( cos ( a
* x
) , 1 .
/ 3 ) + ( k
* log ( a
- x
) ) / log ( a
* x
) ; return result;
}
int main( ) {
double xmin, xmax, dx;
double a, k;
double x, y;
printf ( "Enter the value xmin: " ) ; printf ( "Enter the value xmax: " ) ; printf ( "Enter the value step dx: " ) ; printf ( "Enter the value a: " ) ; printf ( "Enter the value k: " ) ;
printf ( "Tabulation function f(x):\n " ) ; printf ( "-----------------------\n " ) ; printf ( "-----------------------\n " ) ;
for ( x = xmin; x <= xmax; x += dx) {
y = f( x, a, k) ;
printf ( "%8.2lf | %10.4lf\n " , x
, y
) ; }
return 0 ;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxtYXRoLmg+CmRvdWJsZSBmKGRvdWJsZSB4LCBkb3VibGUgYSwgZG91YmxlIGspIHsKICAgIGRvdWJsZSByZXN1bHQ7CiAgICBpZiAoYSA9PSAwIHx8IHggPT0gMCB8fCB4ID09IGEpIHsKICAgICAgICBwcmludGYoIkNhbm5vdCBjb21wdXRlIGEgZnVuY3Rpb24gZm9yIHggPSAlLjJsZlxuIiwgeCk7CiAgICAgICAgcmV0dXJuIDA7CiAgICB9CiAgICByZXN1bHQgPSBwb3coY29zKGEgKiB4KSwgMS4gLyAzKSArIChrICogbG9nKGEgLSB4KSkgLyBsb2coYSAqIHgpOwogICAgcmV0dXJuIHJlc3VsdDsKfQppbnQgbWFpbigpIHsKICAgIGRvdWJsZSB4bWluLCB4bWF4LCBkeDsKICAgIGRvdWJsZSBhLCBrOwogICAgZG91YmxlIHgsIHk7CgogICAgcHJpbnRmKCJFbnRlciB0aGUgdmFsdWUgeG1pbjogIik7CiAgICBzY2FuZigiJWxmIiwgJnhtaW4pOwogICAgcHJpbnRmKCJFbnRlciB0aGUgdmFsdWUgeG1heDogIik7C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