I strongly suggest to first get a "feeling" for the graph.
1) sin(x) is periodically in 2⋅π and has roots every n⋅π (∀ n ∈ Ν
0)
2) sin(x) ≈ x (x much smaller than π/2)
3) e
-x goes monotoinc to zero (∀ x ∈ R, x ≥ 0)
4) e
-x has sample values at: e
0 = 1, e
-π ≈ 0.0432, e
-2⋅π ≈ 0.0019, e
-3⋅π ≈ 0.00008, e
-4⋅π ≈ 0.0000034, ...
From this, you can postulate that the roots for e
-x - sin(x) are
- ≈ n⋅π (∀ n ∈ Ν) (since e-x for values x=π and above can be neglected)
- ≈ 0.59 (for the root between 0 and π) (found by setting e-x ≈ x and estimating and roughly calculating some value between π/6 and π/4)
Knowing that, you can compare your numeric calculation with the aproximately estimated roots from above.
Your immediate problem was that x was not set to 0 initially.
My understanding is that you don't calculate the roots with your solution #1. It's calculating "something" but not the roots.
Describe first in your own words how you want to calculate the roots (e.g. by Regula Falsi, Newton, ...) and then only code that choosen approach.
Cheers
Andi