I'm trying to optimize a logarithmic fit to a data set with `scipy.optimize.curve_fit`. Before trying it on an actual data set, I wrote code to run on a dummy data set.

```
def do_fitting():
    x = np.linspace(0, 4, 100)
    y = func(x, 1.1, .4, 5)
    y2 = y + 0.2 * np.random.normal(size=len(x))

    popt, pcov = curve_fit(func, x, y2, p0=np.array([2, 0.5, 1]))

    plt.figure()
    plt.plot(x, y, 'bo', label="Clean Data")
    plt.plot(x, y2, 'ko', label="Fuzzed Data")
    plt.plot(x, func(x, *popt), 'r-', label="Fitted Curve")
    plt.legend()
    plt.show()

```

Of course, `do_fitting()` relies on `func()`, which it passes to `curve_fit`. Here's the problem. When I pass a `func()` that contains `np.log`, i.e. the function that I actually want to fit to, `curve_fit` declares that `p0` (the initial condition) is the optimal solution and returns immediately with an infinite covariance. 

Here's what happens if I run `do_fitting()` with a non-logarithmic `func()`:

```
def func(x, a, b, c):
    return a * np.exp(x*b) + c

```

[![exponential fit](https://i.stack.imgur.com/lr6TL.png)](https://i.stack.imgur.com/lr6TL.png)

```
popt = [ 0.90894173  0.44279212  5.19928151]
pcov = [[ 0.02044817 -0.00471525 -0.02601574]
        [-0.00471525  0.00109879  0.00592502]
        [-0.02601574  0.00592502  0.0339901 ]]

```

Here's what happens when I run `do_fitting()` with a logarithmic `func()`:

```
def func(x, a, b, c):
    return a * np.log(x*b) + c

```

[![logarithmic fit](https://i.stack.imgur.com/8wp5f.png)](https://i.stack.imgur.com/8wp5f.png)

```
popt = [ 2.   0.5  1. ]
pcov = inf

```

You'll notice that the logarithmic solution for `popt` is equal to the value I gave `curve_fit` for `p0` in the above `do_fitting()`. This is true, and `pcov` is infinite, for every value of `p0` I have tried.

What am I doing wrong here?