main =
    do
    -- print each line asap:
    hSetBuffering stdout LineBuffering
    -- boilerplate to process arguments:
    [digitsS] <- getArgs
    let digits = read digitsS -- desired accuracy in decimal digits
    
    -- sqrt(2) to the given number of digits:
    putStrLn $ "findRootDigits(fn(x)=x^2-2, leftEndpoint=0, rightEndpoint=2, digits=" ++ show digits ++ ") = "
    putStrLn $ showRealApprox digits $ findRootDigits digits (100,()) xSquareMinus2 0 2
    
    -- log(3) to the given number of digits:
    putStrLn $ "findRootDigits(fn(x)=exp(x)-3, leftEndpoint=0, rightEndpoint=2, digits=" ++ show digits ++ ") = "
    putStrLn $ showRealApprox digits $ findRootDigits digits (100,()) expXMinus3 0 2
    where
    showRealApprox digits = showInternals shouldShowInternals
        where
        shouldShowInternals = (digitsW+2, False)
        digitsW = fromIntegral digits
    
    xSquareMinus2 _eff x = x * x - 2
        -- the effort parameter is not required in this case, using the unit type ()
    expXMinus3 _eff x = (exp x) - 3
        -- the effort parameter is not required in this case, using the unit type ()
main =
    do
    -- print each line asap:
    hSetBuffering stdout LineBuffering
    -- boilerplate to process arguments:
    [digitsS] <- getArgs
    let digits = read digitsS -- desired accuracy in decimal digits
    
    -- sqrt(2) to the given number of digits:
    putStrLn $ "findRootDigits(fn(x)=x^2-2, leftEndpoint=0, rightEndpoint=2, digits=" ++ show digits ++ ") = "
    putStrLn $ showRealApprox digits $ findRootDigits digits (100,()) xSquareMinus2 0 2
    
    -- log(3) to the given number of digits:
    putStrLn $ "findRootDigits(fn(x)=exp(x)-3, leftEndpoint=0, rightEndpoint=2, digits=" ++ show digits ++ ") = "
    putStrLn $ showRealApprox digits $ findRootDigits digits (100,()) expXMinus3 0 2
    where
    showRealApprox digits = showInternals shouldShowInternals
        where
        shouldShowInternals = (digitsW+2, False)
        digitsW = fromIntegral digits
    
    xSquareMinus2 _eff x = x * x - 2
        -- the effort parameter is not required in this case, using the unit type ()
    expXMinus3 _eff x = (exp x) - 3
        -- the effort parameter is not required in this case, using the unit type ()
main =
    do
    -- print each line asap:
    hSetBuffering stdout LineBuffering
    -- boilerplate to process arguments:
    [digitsS] <- getArgs
    let digits = read digitsS -- desired accuracy in decimal digits
    
    -- sqrt(2) to the given number of digits:
    putStrLn $ "findRootDigits(fn(x)=x^2-2, leftEndpoint=0, rightEndpoint=2, digits=" ++ show digits ++ ") = "
    putStrLn $ showRealApprox digits $ findRootDigits digits (100,()) xSquareMinus2 0 2
    
    -- log(3) to the given number of digits:
    putStrLn $ "findRootDigits(fn(x)=exp(x)-3, leftEndpoint=0, rightEndpoint=2, digits=" ++ show digits ++ ") = "
    putStrLn $ showRealApprox digits $ findRootDigits digits (100,()) expXMinus3 0 2
    where
    showRealApprox digits = showInternals shouldShowInternals
        where
        shouldShowInternals = (digitsW+2, False)
        digitsW = fromIntegral digits
    
    xSquareMinus2 _eff x = x * x - 2
        -- the effort parameter is not required in this case, using the unit type ()
    expXMinus3 _eff x = (exp x) - 3
        -- the effort parameter is not required in this case, using the unit type ()