From 8f42378c707c8c962082e394fe67ac3bb5cd557b Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Sun, 14 Oct 2018 11:42:53 -0400 Subject: General cleanup --- CSMath/src/bisection/Bisection.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'CSMath/src/bisection/Bisection.java') diff --git a/CSMath/src/bisection/Bisection.java b/CSMath/src/bisection/Bisection.java index edca743..324d127 100644 --- a/CSMath/src/bisection/Bisection.java +++ b/CSMath/src/bisection/Bisection.java @@ -8,12 +8,21 @@ package bisection; * Use the bisection method to find bracketed roots of arbitrary real-valued functions. */ +/** + * Bisect a curve to find bracketed roots of arbitrary real-valued functions. + * @author bjculkin + * + */ public class Bisection { /** * Maximum number of iterations to attempt. */ public static final int MAXITR = 500; + /** + * Main method. + * @param args Unused CLI args. + */ public static void main(String[] args) { /* The variable to manipulate in the expressions. */ Dual varX = new Dual(); @@ -115,6 +124,15 @@ public class Bisection { return newmid; } + /** + * Bisect an arbitrary expression using the secant method. + * @param func The expression to bisect. + * @param var The variable to manipulate. + * @param lo The lower bounding value. + * @param hi The higher bounding value. + * @param tol The tolerance to find the answer to. + * @return The bisected root for the expression, within the specified tolerance. + */ public static double secant(DualExpr func, Dual var, double lo, double hi, double tol) { /* Initial guesses for root. */ double guess1 = (lo + hi) / 3; // 1/3 into the range -- cgit v1.2.3