- #1
ver_mathstats
- 260
- 21
- Homework Statement
- We are required to explain the values of g(x) and h(x).
The script for Matlab is:
g = @(x) (exp(x)-1-x)./x.^2;
h = @(x) (exp(x)-x-1)./x.^2;
x = 1e-10;
fprintf(’x=%.16e\ng(x)=%.16e\nh(x)=%.16e\n’, x, g(x), h(x))
x = 2^(-33);
fprintf(’x=%.16e\ng(x)=%.16e\nh(x)=%.16e\n’, x, g(x), h(x))
The output is:
x=1.0000000000000000e-10
g(x)=8.2740370962658164e+02
h(x)=0.0000000000000000e+00
x=1.1641532182693481e-10
g(x)=0.0000000000000000e+00
h(x)=0.0000000000000000e+00
- Relevant Equations
- -
I am having a bit of trouble understanding what the values of g(x) and h(x) mean. I went through it by hand and here is information that I gathered about the values and questions I am trying to answer to gain a better understanding. Firstly, for the value of x=1e-10 both the numerator of g(x) and the numerator of h(x) equate to the same number on my calculator and of course they have the same denominator, but then I don't understand why g(x) equals a positive number whereas h(x) equals 0, does this all just come from the error? I get the answer I am expecting for g(x) but not h(x).
Secondly, when I calculate g(x) for x=2-33 I get a negative number and when I calculate h(x) when x=2-33 I get 0. But why would the output for g(x) be 0 on MATLAB but when I calculate it I obtain a negative number? Is this simply only due to the precision of using 16 decimals whereas on my calculator it's much less?
Any help would be appreciated, thanks.
Secondly, when I calculate g(x) for x=2-33 I get a negative number and when I calculate h(x) when x=2-33 I get 0. But why would the output for g(x) be 0 on MATLAB but when I calculate it I obtain a negative number? Is this simply only due to the precision of using 16 decimals whereas on my calculator it's much less?
Any help would be appreciated, thanks.