# Difference between f(1.0e-7) & f(1.0e-8)

**URL:** https://discourse.julialang.org/t/difference-between-f-1-0e-7-f-1-0e-8/32779
**Category:** New to Julia
**Tags:** question
**Created:** [December 29, 2019, 10:09am UTC](https://discourse.julialang.org/t/difference-between-f-1-0e-7-f-1-0e-8/32779 "2019-12-29T10:09:15Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![longemen3000](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/longemen3000/32/7298_2.png) [@longemen3000](https://discourse.julialang.org/u/longemen3000)
#### Post date: [December 29, 2019, 2:39pm UTC](https://discourse.julialang.org/t/difference-between-f-1-0e-7-f-1-0e-8/32779/5 "2019-12-29T14:39:34Z")

</div>

you can also take the fact of the existence of `expm1` and expanding each term:

```julia
f1(x)= 2*(1-x*exp(-x)-exp(-x))/(1-exp(-x))^2 #for comparison
function f2(x)
    denom= -expm1(-x)
    return 2/denom+ 2*x/denom- 2*x/(denom*denom)
end

```

Testing for equality on other number

```julia
julia> f1(4)
1.885271061051406

julia> f2(4)
1.8852710610514052

```

near zero:

```julia
julia> f1(1e-7)
0.9992008230547272

julia> f2(1e-7)
1.0000000335276127

julia> f2(1e-8)
1.0

julia> f1(1e-8)
0.0

```

to be fair it also fails, but around `1e-11`

---

_[View the full topic](https://discourse.julialang.org/t/difference-between-f-1-0e-7-f-1-0e-8/32779)._
