Calculating forward error of a function in c -


i'd understand how calculate forward, , backward error of function using c double (64bit) type.

for example, how identify forward error of following function:

double func(double x){     return (pow(x,2.0)/cos(x)); } 

if relative error known = 10^-15.

i know forward error difference in value between exact answer f(x), , computed answer ^f(x). , backward error difference in value between value ^x, used compute ^f(x), , true value of x give calculated value ^f(x).

the problem have have no idea how calculate these errors in practice.

thank you.

sample forward difference using extended precision.

use volatile prevent double code using extended precision calculations.

#include <assert.h> #include <float.h> #include <math.h>  long double func_test_forward(volatile double x) {   #ifdef ldbl_dig     assert(ldbl_dig > dbl_dig);   #endif   volatile double y = func(x);   long double ly = powl(x, 2.0)/cosl(x);   return y - ly; } 

Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -