#include <stdio.h>
#include <math.h>
float implementation_1( float x)
{
return powf( x, 4 ) - 10 * powf( x, 3 ) + 35 * powf( x, 2 ) - 50 * x + 24 ;
}
float implementation_2( float x)
{
return ( x - 1 ) * ( x - 2 ) * ( x - 3 ) * ( x - 4 ) ;
}
float implementation_3( float x)
{
return x * ( x * ( ( x - 10 ) * x + 35 ) - 50 ) + 24 ;
}
int main( )
{
float x = 3.14159263f ;
printf ( "Implementation 1: %a\n " , implementation_1
( x
) ) ; printf ( "Implementation 2: %a\n " , implementation_2
( x
) ) ; printf ( "Implementation 3: %a\n " , implementation_3
( x
) ) ;
printf ( "Does implementation 1 match 2? %d\n " , implementation_1
( x
) == implementation_2
( x
) ) ; printf ( "Does implementation 1 match 3? %d\n " , implementation_1
( x
) == implementation_3
( x
) ) ; printf ( "Does implementation 2 match 3? %d\n " , implementation_2
( x
) == implementation_3
( x
) ) ; return 0 ;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxtYXRoLmg+CiAKZmxvYXQgaW1wbGVtZW50YXRpb25fMShmbG9hdCB4KQp7CglyZXR1cm4gcG93Zih4LCA0KSAtIDEwICogcG93Zih4LCAzKSArIDM1ICogcG93Zih4LCAyKSAtIDUwICogeCArIDI0Owp9CiAKZmxvYXQgaW1wbGVtZW50YXRpb25fMihmbG9hdCB4KQp7CglyZXR1cm4gKHggLSAxKSAqICh4IC0gMikgKiAoeCAtIDMpICogKHggLSA0KTsKfQogCmZsb2F0IGltcGxlbWVudGF0aW9uXzMoZmxvYXQgeCkKewoJcmV0dXJuIHggKiAoeCAqICgoeCAtIDEwKSAqIHggKyAzNSkgLSA1MCkgKyAyNDsKfQogCmludCBtYWluKCkKewoJZmxvYXQgeCA9IDMuMTQxNTkyNjNmOwoJcHJpbnRmICgiSW1wbGVtZW50YXRpb24gMTogJWFcbiIsIGltcGxlbWVudGF0aW9uXzEoeCkpOwoJcHJpbnRmICgiSW1wbGVtZW50YXRpb24gMjogJWFcbiIsIGltc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