You might be interested to try my library Numerical for this. Among other useful numerical methods it has root finding. It's setup as a Swift Package Manager package.

Let's take an example where you want to know the cube root of 30. In this case x^3 = 30, so the function you want to find a root of is f(x) = x * x * x - 30. In root finding it's useful to have a starting guess, so let's say your guess is 3.0.

If you know how to write your function but not its first derivative you may write:

```
let a = root(guess: 3.0) { x in x * x * x - 30 }
```

This uses Brent's method by default but you can specify secant or one of a few other methods if you know that is a better fit.

In this example we also know that the first derivative of f(x) is f'(x) = 3 * x * x. Now we can use Newton's method like so:

```
let b = root(guess: 3.0,
f: { x in x * x * x - 30 },
f1: { x in 3 * x * x })
```

We can also take it one step further in this example because we also know that the second derivative of our function is f''(x) = 6 * x. This lets us use Halley's method like so:

```
let c = rootSecondOrder(guess: 3.0,
f: { x in x * x * x - 30 },
f1: { x in 3 * x * x },
f2: { x in 6 * x })
```

There are a few other options in there as well allowing you to specify a one or two sided interval to restrict your search, a maximum number of iterations you can afford, and a tolerance you can accept.

If you try it out let me know if you have questions.