Bisection and Fixed-Point Iteration Method algorithm for finding the root of $f(x) = \ln(x) - \cos(x)$. I am trying to find the root of $f(x)=ln(x)-cos(x)$ by writing an algorithm for bisection and fixed-point iteration method. I am currently using python but whenever I'm running it using either of the two methods, it prints out "math domain error". I guess this is due to ln(x) when x becomes 0 or negative.
So, I asked myself if this manipulation is valid:
If $f(x)=ln(x)-cos(x)=0$, then $ln(x)=cos(x)$. It also follows that $x=e^{cos(x)}$ so we have a function, say $h(x)=x-e^{cos(x)}$, that has same root with $f(x)$. So, I tried using $h$ to find the root of $f$ and I resolved the error prompt I am getting whenever I use $f$ in my code. This is for bisection method, and I got the root that I want to get.
I still don't know what is the appropriate $g(x)$ should I take for fixed-point iteration method such that if $f(x)=0$, then $x=g(x)$ and $g'(x)<1$ for some open interval.
First question: Is using an alternative function $h$ to solve for the actual root of $f$ valid?
Last question: What could be a possible $g(x)$ to use to find the root using fixed-point iteration method?
Any help would be appreciated.
 A: You don't need to change the function $f(x)$. Choose $a=0.1$ and $b=e$ and you will find that $f(a)<0$ and $f(b)>0$. The bisection method will work.
If you do some iterations in the bisection method, you'll find an approximation to the root, say $c$.
Use this $c$ as initial guess to the Newton's method , as fixed point method given by $x=x-f(x)/f'(x)$.
Here is a link to my code in R.
You can find many results by searching for "\(x=x-f(x)/f'(x)\)" on SearchOnMath.
A: 
$g′(x)<1$ for some open interval

What you need is the stronger $|g′(x)|<1$ for some interval containing the zero $x_0$ of $f$.
Your choice $g(x) = e^{\cos x}$ has derivative $g'(x) = -e^{\cos x}\sin x$. But with $x_0\approx 1.303$ that evaluates to $g'(x_0)\approx -1.26$.  Hence $g$ will not work.

First question: Is using an alternative function $h$ to solve for the actual root of $f$ valid?

Yes, you can do that.  The question is for which purpose you are doing it...
One annoyance with $f$ and fixed-point methods can be that you come to a halt without a result whenever $x<0$ because $\ln x$ is not defined there. However, using $h$ instead has the issue that whenever $x<0$, the iteration will trickle to $-\infty$ an not produce a result, either.

Last question: What could be a possible $g(x)$ to use to find the root using fixed-point iteration method?

As $x=g(x)=e^{\cos x}$ does not work, you can try splits like
$$x=\alpha x + (1-\alpha)x = g(x)$$
and from there
$$ x = \frac1\alpha \big(g(x)-(1-\alpha)x\big)=g_\alpha(x)$$
for some constant $\alpha$, and then try to find some $\alpha$ such that
$$|g'_\alpha(x_0)| < 1$$
