From 88fc0b666c58334009bc274105ea0d2b90edf75d Mon Sep 17 00:00:00 2001 From: Benjamin Culkin Date: Mon, 9 Apr 2018 15:42:35 -0700 Subject: Initial commit --- CSMath/src/bisection/Dual.java | 55 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 CSMath/src/bisection/Dual.java (limited to 'CSMath/src/bisection/Dual.java') diff --git a/CSMath/src/bisection/Dual.java b/CSMath/src/bisection/Dual.java new file mode 100644 index 0000000..de5b004 --- /dev/null +++ b/CSMath/src/bisection/Dual.java @@ -0,0 +1,55 @@ +package bisection; + +/** + * Represents a 'dual' number. + * + * Think imaginary numbers, where instead of i, we add a value d such that d^2 = + * 0. + */ +public class Dual { + /** + * The real part of the dual number. + */ + public double real; + /** + * The dual part of the dual number. + */ + public double dual; + + /** + * Create a new dual with both parts zero. + */ + public Dual() { + real = 0; + dual = 0; + } + + /** + * Create a new dual number with a zero dual part. + * + * @param real + * The real part of the number. + */ + public Dual(double real) { + this.real = real; + this.dual = 0; + } + + /** + * Create a new dual number with a specified dual part. + * + * @param real + * The real part of the number. + * @param dual + * The dual part of the number. + */ + public Dual(double real, double dual) { + this.real = real; + this.dual = dual; + } + + @Override + public String toString() { + return String.format("<%f, %f>", real, dual); + } +} \ No newline at end of file -- cgit v1.2.3