findRootDigits ::
    (EffortIndicator effort)
    =>
    Int ->
    (Precision, effort) ->
    (effort -> RealApprox -> RealApprox) ->
    RealApprox ->
    RealApprox ->
    RealApprox
findRootDigits digits initEff fn leftEndpoint rightEndpoint =
    snd $ last $
    iterateUntilAccurate maxIncrements (maxImprecision digits) initEff $
        \eff -> findRoot eff fn leftEndpoint rightEndpoint
    where
    maxIncrements = 100

    maxImprecision :: Int -> RealApprox
    maxImprecision digits = (ensurePrecision 10 10)^^(-digits)
findRootDigits ::
    (EffortIndicator effort)
    =>
    Int ->
    (Precision, effort) ->
    (effort -> RealApprox -> RealApprox) ->
    RealApprox ->
    RealApprox ->
    RealApprox
findRootDigits digits initEff fn leftEndpoint rightEndpoint =
    snd $ last $
    iterateUntilAccurate maxIncrements (maxImprecision digits) initEff $
        \eff -> findRoot eff fn leftEndpoint rightEndpoint
    where
    maxIncrements = 100

    maxImprecision :: Int -> RealApprox
    maxImprecision digits = (ensurePrecision 10 10)^^(-digits)
findRootDigits digits initEff fn leftEndpoint rightEndpoint =
    snd $ last $
    iterateUntilAccurate maxIncrements (maxImprecision digits) initEff $
        \eff -> findRoot eff fn leftEndpoint rightEndpoint
    where
    maxIncrements = 100

    maxImprecision :: Int -> RealApprox
    maxImprecision digits = (ensurePrecision 10 10)^^(-digits)