function call trace
DESCRIPTION
Function Call Trace. public class Newton { public static double sqrt ( double c ) { double epsilon = 1E-15 ; if ( c < 0 ) return Double . NaN ; double t = c ; while ( Math . abs ( t - c / t ) > epsilon * t ) t = ( c / t + t ) / 2.0 ; - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Function Call Trace](https://reader034.vdocuments.net/reader034/viewer/2022051215/568143a3550346895db02565/html5/thumbnails/1.jpg)
1
public class Newton {
public static double sqrt(double c) { double epsilon = 1E-15; if (c < 0) return Double.NaN; double t = c; while (Math.abs(t - c/t) > epsilon * t) t = (c/t + t) / 2.0; return t; }
public static void main(String[] args) { double[] a = new double[args.length]; for (int i = 0; i < args.length; i++) a[i] = Double.parseDouble(args[i]); for (int i = 0; i < a.length; i++) System.out.println(Newton.sqrt(a[i])); }}
Function Call Trace
![Page 2: Function Call Trace](https://reader034.vdocuments.net/reader034/viewer/2022051215/568143a3550346895db02565/html5/thumbnails/2.jpg)
2
public class Newton {
public static double sqrt(double c) { double epsilon = 1E-15; if (c < 0) return Double.NaN; double t = c; while (Math.abs(t - c/t) > epsilon * t) t = (c/t + t) / 2.0; return t; }
public static void main(String[] args) { double[] a = new double[args.length]; for (int i = 0; i < args.length; i++) a[i] = Double.parseDouble(args[i]); for (int i = 0; i < a.length; i++) System.out.println(Newton.sqrt(a[i])); }}
Function Call Trace
% java Newton 1 2 3
![Page 3: Function Call Trace](https://reader034.vdocuments.net/reader034/viewer/2022051215/568143a3550346895db02565/html5/thumbnails/3.jpg)
3
public class Newton {
public static double sqrt(double c) { double epsilon = 1E-15; if (c < 0) return Double.NaN; double t = c; while (Math.abs(t - c/t) > epsilon * t) t = (c/t + t) / 2.0; return t; }
public static void main(String[] args) { double[] a = new double[args.length]; for (int i = 0; i < args.length; i++) a[i] = Double.parseDouble(args[i]); for (int i = 0; i < a.length; i++) System.out.println(Newton.sqrt(a[i])); }}
Function Call Trace
% java Newton 1 2 3
{ "1", "2", "3" } args[]
{ "1", "2", "3" }
![Page 4: Function Call Trace](https://reader034.vdocuments.net/reader034/viewer/2022051215/568143a3550346895db02565/html5/thumbnails/4.jpg)
4
public class Newton {
public static double sqrt(double c) { double epsilon = 1E-15; if (c < 0) return Double.NaN; double t = c; while (Math.abs(t - c/t) > epsilon * t) t = (c/t + t) / 2.0; return t; }
public static void main(String[] args) { double[] a = new double[args.length]; for (int i = 0; i < args.length; i++) a[i] = Double.parseDouble(args[i]); for (int i = 0; i < a.length; i++) System.out.println(Newton.sqrt(a[i])); }}
Function Call Trace
% java Newton 1 2 3
args[]
{ "1", "2", "3" }
a[]
{ 0.0, 0.0, 0.0 }
![Page 5: Function Call Trace](https://reader034.vdocuments.net/reader034/viewer/2022051215/568143a3550346895db02565/html5/thumbnails/5.jpg)
5
public class Newton {
public static double sqrt(double c) { double epsilon = 1E-15; if (c < 0) return Double.NaN; double t = c; while (Math.abs(t - c/t) > epsilon * t) t = (c/t + t) / 2.0; return t; }
public static void main(String[] args) { double[] a = new double[args.length]; for (int i = 0; i < args.length; i++) a[i] = Double.parseDouble(args[i]); for (int i = 0; i < a.length; i++) System.out.println(Newton.sqrt(a[i])); }}
Function Call Trace
% java Newton 1 2 3
args[]
{ "1", "2", "3" }
a[]
{ 0.0, 0.0, 0.0 }
i
0
![Page 6: Function Call Trace](https://reader034.vdocuments.net/reader034/viewer/2022051215/568143a3550346895db02565/html5/thumbnails/6.jpg)
6
public class Newton {
public static double sqrt(double c) { double epsilon = 1E-15; if (c < 0) return Double.NaN; double t = c; while (Math.abs(t - c/t) > epsilon * t) t = (c/t + t) / 2.0; return t; }
public static void main(String[] args) { double[] a = new double[args.length]; for (int i = 0; i < args.length; i++) a[i] = Double.parseDouble(args[i]); for (int i = 0; i < a.length; i++) System.out.println(Newton.sqrt(a[i])); }}
Function Call Trace
% java Newton 1 2 3
a[]
{ 1.0, 0.0, 0.0 }
args[]
{ "1", "2", "3" }
i
0
![Page 7: Function Call Trace](https://reader034.vdocuments.net/reader034/viewer/2022051215/568143a3550346895db02565/html5/thumbnails/7.jpg)
7
public class Newton {
public static double sqrt(double c) { double epsilon = 1E-15; if (c < 0) return Double.NaN; double t = c; while (Math.abs(t - c/t) > epsilon * t) t = (c/t + t) / 2.0; return t; }
public static void main(String[] args) { double[] a = new double[args.length]; for (int i = 0; i < args.length; i++) a[i] = Double.parseDouble(args[i]); for (int i = 0; i < a.length; i++) System.out.println(Newton.sqrt(a[i])); }}
Function Call Trace
% java Newton 1 2 3
a[]
{ 1.0, 0.0, 0.0 }
args[]
{ "1", "2", "3" }
i
1
![Page 8: Function Call Trace](https://reader034.vdocuments.net/reader034/viewer/2022051215/568143a3550346895db02565/html5/thumbnails/8.jpg)
8
public class Newton {
public static double sqrt(double c) { double epsilon = 1E-15; if (c < 0) return Double.NaN; double t = c; while (Math.abs(t - c/t) > epsilon * t) t = (c/t + t) / 2.0; return t; }
public static void main(String[] args) { double[] a = new double[args.length]; for (int i = 0; i < args.length; i++) a[i] = Double.parseDouble(args[i]); for (int i = 0; i < a.length; i++) System.out.println(Newton.sqrt(a[i])); }}
Function Call Trace
% java Newton 1 2 3
a[]
{ 1.0, 2.0, 0.0 }
args[]
{ "1", "2", "3" }
i
1
![Page 9: Function Call Trace](https://reader034.vdocuments.net/reader034/viewer/2022051215/568143a3550346895db02565/html5/thumbnails/9.jpg)
9
public class Newton {
public static double sqrt(double c) { double epsilon = 1E-15; if (c < 0) return Double.NaN; double t = c; while (Math.abs(t - c/t) > epsilon * t) t = (c/t + t) / 2.0; return t; }
public static void main(String[] args) { double[] a = new double[args.length]; for (int i = 0; i < args.length; i++) a[i] = Double.parseDouble(args[i]); for (int i = 0; i < a.length; i++) System.out.println(Newton.sqrt(a[i])); }}
Function Call Trace
% java Newton 1 2 3
a[]
{ 1.0, 2.0, 0.0 }
args[]
{ "1", "2", "3" }
i
2
![Page 10: Function Call Trace](https://reader034.vdocuments.net/reader034/viewer/2022051215/568143a3550346895db02565/html5/thumbnails/10.jpg)
10
public class Newton {
public static double sqrt(double c) { double epsilon = 1E-15; if (c < 0) return Double.NaN; double t = c; while (Math.abs(t - c/t) > epsilon * t) t = (c/t + t) / 2.0; return t; }
public static void main(String[] args) { double[] a = new double[args.length]; for (int i = 0; i < args.length; i++) a[i] = Double.parseDouble(args[i]); for (int i = 0; i < a.length; i++) System.out.println(Newton.sqrt(a[i])); }}
Function Call Trace
% java Newton 1 2 3
a[]
{ 1.0, 2.0, 3.0 }
args[]
{ "1", "2", "3" }
i
2
![Page 11: Function Call Trace](https://reader034.vdocuments.net/reader034/viewer/2022051215/568143a3550346895db02565/html5/thumbnails/11.jpg)
11
public class Newton {
public static double sqrt(double c) { double epsilon = 1E-15; if (c < 0) return Double.NaN; double t = c; while (Math.abs(t - c/t) > epsilon * t) t = (c/t + t) / 2.0; return t; }
public static void main(String[] args) { double[] a = new double[args.length]; for (int i = 0; i < args.length; i++) a[i] = Double.parseDouble(args[i]); for (int i = 0; i < a.length; i++) System.out.println(Newton.sqrt(a[i])); }}
Function Call Trace
% java Newton 1 2 3
a[]
{ 1.0, 2.0, 3.0 }
args[]
{ "1", "2", "3" }
i
3goes outof scope
![Page 12: Function Call Trace](https://reader034.vdocuments.net/reader034/viewer/2022051215/568143a3550346895db02565/html5/thumbnails/12.jpg)
12
public class Newton {
public static double sqrt(double c) { double epsilon = 1E-15; if (c < 0) return Double.NaN; double t = c; while (Math.abs(t - c/t) > epsilon * t) t = (c/t + t) / 2.0; return t; }
public static void main(String[] args) { double[] a = new double[args.length]; for (int i = 0; i < args.length; i++) a[i] = Double.parseDouble(args[i]); for (int i = 0; i < a.length; i++) System.out.println(Newton.sqrt(a[i])); }}
Function Call Trace
i
0
% java Newton 1 2 3
a[]
{ 1.0, 2.0, 3.0 }
args[]
{ "1", "2", "3" }
![Page 13: Function Call Trace](https://reader034.vdocuments.net/reader034/viewer/2022051215/568143a3550346895db02565/html5/thumbnails/13.jpg)
13
public class Newton {
public static double sqrt(double c) { double epsilon = 1E-15; if (c < 0) return Double.NaN; double t = c; while (Math.abs(t - c/t) > epsilon * t) t = (c/t + t) / 2.0; return t; }
public static void main(String[] args) { double[] a = new double[args.length]; for (int i = 0; i < args.length; i++) a[i] = Double.parseDouble(args[i]); for (int i = 0; i < a.length; i++) System.out.println(Newton.sqrt(a[i])); }}
Function Call Trace
1.0
1.0
% java Newton 1 2 3
i
0
a[]
{ 1.0, 2.0, 3.0 }
args[]
{ "1", "2", "3" }
![Page 14: Function Call Trace](https://reader034.vdocuments.net/reader034/viewer/2022051215/568143a3550346895db02565/html5/thumbnails/14.jpg)
14
public class Newton {
public static double sqrt(double c) { double epsilon = 1E-15; if (c < 0) return Double.NaN; double t = c; while (Math.abs(t - c/t) > epsilon * t) t = (c/t + t) / 2.0; return t; }
public static void main(String[] args) { double[] a = new double[args.length]; for (int i = 0; i < args.length; i++) a[i] = Double.parseDouble(args[i]); for (int i = 0; i < a.length; i++) System.out.println(Newton.sqrt(a[i])); }}
Function Call Trace
1.0
1.0
c
1.0
% java Newton 1 2 3
i
0
a[]
{ 1.0, 2.0, 3.0 }
args[]
{ "1", "2", "3" }
![Page 15: Function Call Trace](https://reader034.vdocuments.net/reader034/viewer/2022051215/568143a3550346895db02565/html5/thumbnails/15.jpg)
15
public class Newton {
public static double sqrt(double c) { double epsilon = 1E-15; if (c < 0) return Double.NaN; double t = c; while (Math.abs(t - c/t) > epsilon * t) t = (c/t + t) / 2.0; return t; }
public static void main(String[] args) { double[] a = new double[args.length]; for (int i = 0; i < args.length; i++) a[i] = Double.parseDouble(args[i]); for (int i = 0; i < a.length; i++) System.out.println(Newton.sqrt(a[i])); }}
Function Call Trace
% java Newton 1 2 3
i
0
a[]
{ 1.0, 2.0, 3.0 }
args[]
{ "1", "2", "3" }
c
1.0
![Page 16: Function Call Trace](https://reader034.vdocuments.net/reader034/viewer/2022051215/568143a3550346895db02565/html5/thumbnails/16.jpg)
16
public class Newton {
public static double sqrt(double c) { double epsilon = 1E-15; if (c < 0) return Double.NaN; double t = c; while (Math.abs(t - c/t) > epsilon * t) t = (c/t + t) / 2.0; return t; }
public static void main(String[] args) { double[] a = new double[args.length]; for (int i = 0; i < args.length; i++) a[i] = Double.parseDouble(args[i]); for (int i = 0; i < a.length; i++) System.out.println(Newton.sqrt(a[i])); }}
Function Call Trace
% java Newton 1 2 3
i
0
a[]
{ 1.0, 2.0, 3.0 }
args[]
{ "1", "2", "3" }
c
1.0
![Page 17: Function Call Trace](https://reader034.vdocuments.net/reader034/viewer/2022051215/568143a3550346895db02565/html5/thumbnails/17.jpg)
17
public class Newton {
public static double sqrt(double c) { double epsilon = 1E-15; if (c < 0) return Double.NaN; double t = c; while (Math.abs(t - c/t) > epsilon * t) t = (c/t + t) / 2.0; return t; }
public static void main(String[] args) { double[] a = new double[args.length]; for (int i = 0; i < args.length; i++) a[i] = Double.parseDouble(args[i]); for (int i = 0; i < a.length; i++) System.out.println(Newton.sqrt(a[i])); }}
Function Call Trace
% java Newton 1 2 3
i
0
a[]
{ 1.0, 2.0, 3.0 }
args[]
{ "1", "2", "3" }
c
1.0
t
1.0
![Page 18: Function Call Trace](https://reader034.vdocuments.net/reader034/viewer/2022051215/568143a3550346895db02565/html5/thumbnails/18.jpg)
18
public class Newton {
public static double sqrt(double c) { double epsilon = 1E-15; if (c < 0) return Double.NaN; double t = c; while (Math.abs(t - c/t) > epsilon * t) t = (c/t + t) / 2.0; return t; }
public static void main(String[] args) { double[] a = new double[args.length]; for (int i = 0; i < args.length; i++) a[i] = Double.parseDouble(args[i]); for (int i = 0; i < a.length; i++) System.out.println(Newton.sqrt(a[i])); }}
Function Call Trace
% java Newton 1 2 3
i
0
a[]
{ 1.0, 2.0, 3.0 }
args[]
{ "1", "2", "3" }
c
1.0
t
1.0
![Page 19: Function Call Trace](https://reader034.vdocuments.net/reader034/viewer/2022051215/568143a3550346895db02565/html5/thumbnails/19.jpg)
19
public class Newton {
public static double sqrt(double c) { double epsilon = 1E-15; if (c < 0) return Double.NaN; double t = c; while (Math.abs(t - c/t) > epsilon * t) t = (c/t + t) / 2.0; return t; }
public static void main(String[] args) { double[] a = new double[args.length]; for (int i = 0; i < args.length; i++) a[i] = Double.parseDouble(args[i]); for (int i = 0; i < a.length; i++) System.out.println(Newton.sqrt(a[i])); }}
Function Call Trace
% java Newton 1 2 31.0
1.0
i
0
a[]
{ 1.0, 2.0, 3.0 }
args[]
{ "1", "2", "3" }
c
1.0
t
1.0
![Page 20: Function Call Trace](https://reader034.vdocuments.net/reader034/viewer/2022051215/568143a3550346895db02565/html5/thumbnails/20.jpg)
20
public class Newton {
public static double sqrt(double c) { double epsilon = 1E-15; if (c < 0) return Double.NaN; double t = c; while (Math.abs(t - c/t) > epsilon * t) t = (c/t + t) / 2.0; return t; }
public static void main(String[] args) { double[] a = new double[args.length]; for (int i = 0; i < args.length; i++) a[i] = Double.parseDouble(args[i]); for (int i = 0; i < a.length; i++) System.out.println(Newton.sqrt(a[i])); }}
Function Call Trace
% java Newton 1 2 31.0
1.0
i
0
a[]
{ 1.0, 2.0, 3.0 }
args[]
{ "1", "2", "3" }
![Page 21: Function Call Trace](https://reader034.vdocuments.net/reader034/viewer/2022051215/568143a3550346895db02565/html5/thumbnails/21.jpg)
21
public class Newton {
public static double sqrt(double c) { double epsilon = 1E-15; if (c < 0) return Double.NaN; double t = c; while (Math.abs(t - c/t) > epsilon * t) t = (c/t + t) / 2.0; return t; }
public static void main(String[] args) { double[] a = new double[args.length]; for (int i = 0; i < args.length; i++) a[i] = Double.parseDouble(args[i]); for (int i = 0; i < a.length; i++) System.out.println(Newton.sqrt(a[i])); }}
Function Call Trace
% java Newton 1 2 31.0
i
1
a[]
{ 1.0, 2.0, 3.0 }
args[]
{ "1", "2", "3" }
![Page 22: Function Call Trace](https://reader034.vdocuments.net/reader034/viewer/2022051215/568143a3550346895db02565/html5/thumbnails/22.jpg)
22
public class Newton {
public static double sqrt(double c) { double epsilon = 1E-15; if (c < 0) return Double.NaN; double t = c; while (Math.abs(t - c/t) > epsilon * t) t = (c/t + t) / 2.0; return t; }
public static void main(String[] args) { double[] a = new double[args.length]; for (int i = 0; i < args.length; i++) a[i] = Double.parseDouble(args[i]); for (int i = 0; i < a.length; i++) System.out.println(Newton.sqrt(a[i])); }}
Function Call Trace
% java Newton 1 2 31.0
i
1
a[]
{ 1.0, 2.0, 3.0 }
args[]
{ "1", "2", "3" }
2.0
2.0
c
2.0
![Page 23: Function Call Trace](https://reader034.vdocuments.net/reader034/viewer/2022051215/568143a3550346895db02565/html5/thumbnails/23.jpg)
23
public class Newton {
public static double sqrt(double c) { double epsilon = 1E-15; if (c < 0) return Double.NaN; double t = c; while (Math.abs(t - c/t) > epsilon * t) t = (c/t + t) / 2.0; return t; }
public static void main(String[] args) { double[] a = new double[args.length]; for (int i = 0; i < args.length; i++) a[i] = Double.parseDouble(args[i]); for (int i = 0; i < a.length; i++) System.out.println(Newton.sqrt(a[i])); }}
Function Call Trace
% java Newton 1 2 31.0
i
1
a[]
{ 1.0, 2.0, 3.0 }
args[]
{ "1", "2", "3" }
c
2.0
![Page 24: Function Call Trace](https://reader034.vdocuments.net/reader034/viewer/2022051215/568143a3550346895db02565/html5/thumbnails/24.jpg)
24
public class Newton {
public static double sqrt(double c) { double epsilon = 1E-15; if (c < 0) return Double.NaN; double t = c; while (Math.abs(t - c/t) > epsilon * t) t = (c/t + t) / 2.0; return t; }
public static void main(String[] args) { double[] a = new double[args.length]; for (int i = 0; i < args.length; i++) a[i] = Double.parseDouble(args[i]); for (int i = 0; i < a.length; i++) System.out.println(Newton.sqrt(a[i])); }}
Function Call Trace
% java Newton 1 2 31.0
i
1
a[]
{ 1.0, 2.0, 3.0 }
args[]
{ "1", "2", "3" }
c
2.0
![Page 25: Function Call Trace](https://reader034.vdocuments.net/reader034/viewer/2022051215/568143a3550346895db02565/html5/thumbnails/25.jpg)
25
public class Newton {
public static double sqrt(double c) { double epsilon = 1E-15; if (c < 0) return Double.NaN; double t = c; while (Math.abs(t - c/t) > epsilon * t) t = (c/t + t) / 2.0; return t; }
public static void main(String[] args) { double[] a = new double[args.length]; for (int i = 0; i < args.length; i++) a[i] = Double.parseDouble(args[i]); for (int i = 0; i < a.length; i++) System.out.println(Newton.sqrt(a[i])); }}
Function Call Trace
% java Newton 1 2 31.0
i
1
a[]
{ 1.0, 2.0, 3.0 }
args[]
{ "1", "2", "3" }
c
2.0
t
2.0
![Page 26: Function Call Trace](https://reader034.vdocuments.net/reader034/viewer/2022051215/568143a3550346895db02565/html5/thumbnails/26.jpg)
26
public class Newton {
public static double sqrt(double c) { double epsilon = 1E-15; if (c < 0) return Double.NaN; double t = c; while (Math.abs(t - c/t) > epsilon * t) t = (c/t + t) / 2.0; return t; }
public static void main(String[] args) { double[] a = new double[args.length]; for (int i = 0; i < args.length; i++) a[i] = Double.parseDouble(args[i]); for (int i = 0; i < a.length; i++) System.out.println(Newton.sqrt(a[i])); }}
Function Call Trace
% java Newton 1 2 31.0
i
1
a[]
{ 1.0, 2.0, 3.0 }
args[]
{ "1", "2", "3" }
c
2.0
t
2.0
![Page 27: Function Call Trace](https://reader034.vdocuments.net/reader034/viewer/2022051215/568143a3550346895db02565/html5/thumbnails/27.jpg)
27
public class Newton {
public static double sqrt(double c) { double epsilon = 1E-15; if (c < 0) return Double.NaN; double t = c; while (Math.abs(t - c/t) > epsilon * t) t = (c/t + t) / 2.0; return t; }
public static void main(String[] args) { double[] a = new double[args.length]; for (int i = 0; i < args.length; i++) a[i] = Double.parseDouble(args[i]); for (int i = 0; i < a.length; i++) System.out.println(Newton.sqrt(a[i])); }}
Function Call Trace
% java Newton 1 2 31.0
i
1
a[]
{ 1.0, 2.0, 3.0 }
args[]
{ "1", "2", "3" }
c
2.0
t
1.41
![Page 28: Function Call Trace](https://reader034.vdocuments.net/reader034/viewer/2022051215/568143a3550346895db02565/html5/thumbnails/28.jpg)
28
public class Newton {
public static double sqrt(double c) { double epsilon = 1E-15; if (c < 0) return Double.NaN; double t = c; while (Math.abs(t - c/t) > epsilon * t) t = (c/t + t) / 2.0; return t; }
public static void main(String[] args) { double[] a = new double[args.length]; for (int i = 0; i < args.length; i++) a[i] = Double.parseDouble(args[i]); for (int i = 0; i < a.length; i++) System.out.println(Newton.sqrt(a[i])); }}
Function Call Trace
% java Newton 1 2 31.0
i
1
a[]
{ 1.0, 2.0, 3.0 }
args[]
{ "1", "2", "3" }
c
2.0
t
1.41
![Page 29: Function Call Trace](https://reader034.vdocuments.net/reader034/viewer/2022051215/568143a3550346895db02565/html5/thumbnails/29.jpg)
29
public class Newton {
public static double sqrt(double c) { double epsilon = 1E-15; if (c < 0) return Double.NaN; double t = c; while (Math.abs(t - c/t) > epsilon * t) t = (c/t + t) / 2.0; return t; }
public static void main(String[] args) { double[] a = new double[args.length]; for (int i = 0; i < args.length; i++) a[i] = Double.parseDouble(args[i]); for (int i = 0; i < a.length; i++) System.out.println(Newton.sqrt(a[i])); }}
Function Call Trace
% java Newton 1 2 31.0
i
1
a[]
{ 1.0, 2.0, 3.0 }
args[]
{ "1", "2", "3" }
c
2.0
t
1.41
1.414213562373095
1.414213562373095
![Page 30: Function Call Trace](https://reader034.vdocuments.net/reader034/viewer/2022051215/568143a3550346895db02565/html5/thumbnails/30.jpg)
30
public class Newton {
public static double sqrt(double c) { double epsilon = 1E-15; if (c < 0) return Double.NaN; double t = c; while (Math.abs(t - c/t) > epsilon * t) t = (c/t + t) / 2.0; return t; }
public static void main(String[] args) { double[] a = new double[args.length]; for (int i = 0; i < args.length; i++) a[i] = Double.parseDouble(args[i]); for (int i = 0; i < a.length; i++) System.out.println(Newton.sqrt(a[i])); }}
Function Call Trace
% java Newton 1 2 31.01.414213562373095
i
1
a[]
{ 1.0, 2.0, 3.0 }
args[]
{ "1", "2", "3" }
1.414213562373095
![Page 31: Function Call Trace](https://reader034.vdocuments.net/reader034/viewer/2022051215/568143a3550346895db02565/html5/thumbnails/31.jpg)
31
public class Newton {
public static double sqrt(double c) { double epsilon = 1E-15; if (c < 0) return Double.NaN; double t = c; while (Math.abs(t - c/t) > epsilon * t) t = (c/t + t) / 2.0; return t; }
public static void main(String[] args) { double[] a = new double[args.length]; for (int i = 0; i < args.length; i++) a[i] = Double.parseDouble(args[i]); for (int i = 0; i < a.length; i++) System.out.println(Newton.sqrt(a[i])); }}
Function Call Trace
% java Newton 1 2 31.01.414213562373095
i
2
a[]
{ 1.0, 2.0, 3.0 }
args[]
{ "1", "2", "3" }
![Page 32: Function Call Trace](https://reader034.vdocuments.net/reader034/viewer/2022051215/568143a3550346895db02565/html5/thumbnails/32.jpg)
32
public class Newton {
public static double sqrt(double c) { double epsilon = 1E-15; if (c < 0) return Double.NaN; double t = c; while (Math.abs(t - c/t) > epsilon * t) t = (c/t + t) / 2.0; return t; }
public static void main(String[] args) { double[] a = new double[args.length]; for (int i = 0; i < args.length; i++) a[i] = Double.parseDouble(args[i]); for (int i = 0; i < a.length; i++) System.out.println(Newton.sqrt(a[i])); }}
Function Call Trace
% java Newton 1 2 31.01.414213562373095
i
2
a[]
{ 1.0, 2.0, 3.0 }
args[]
{ "1", "2", "3" }
3.0
3.0
c
3.0
![Page 33: Function Call Trace](https://reader034.vdocuments.net/reader034/viewer/2022051215/568143a3550346895db02565/html5/thumbnails/33.jpg)
33
public class Newton {
public static double sqrt(double c) { double epsilon = 1E-15; if (c < 0) return Double.NaN; double t = c; while (Math.abs(t - c/t) > epsilon * t) t = (c/t + t) / 2.0; return t; }
public static void main(String[] args) { double[] a = new double[args.length]; for (int i = 0; i < args.length; i++) a[i] = Double.parseDouble(args[i]); for (int i = 0; i < a.length; i++) System.out.println(Newton.sqrt(a[i])); }}
Function Call Trace
% java Newton 1 2 31.01.414213562373095
i
2
a[]
{ 1.0, 2.0, 3.0 }
args[]
{ "1", "2", "3" }
c
3.0
1.7320508075688772
1.7320508075688772
![Page 34: Function Call Trace](https://reader034.vdocuments.net/reader034/viewer/2022051215/568143a3550346895db02565/html5/thumbnails/34.jpg)
34
public class Newton {
public static double sqrt(double c) { double epsilon = 1E-15; if (c < 0) return Double.NaN; double t = c; while (Math.abs(t - c/t) > epsilon * t) t = (c/t + t) / 2.0; return t; }
public static void main(String[] args) { double[] a = new double[args.length]; for (int i = 0; i < args.length; i++) a[i] = Double.parseDouble(args[i]); for (int i = 0; i < a.length; i++) System.out.println(Newton.sqrt(a[i])); }}
Function Call Trace
% java Newton 1 2 31.01.4142135623730951.7320508075688772
i
2
a[]
{ 1.0, 2.0, 3.0 }
args[]
{ "1", "2", "3" }
![Page 35: Function Call Trace](https://reader034.vdocuments.net/reader034/viewer/2022051215/568143a3550346895db02565/html5/thumbnails/35.jpg)
35
public class Newton {
public static double sqrt(double c) { double epsilon = 1E-15; if (c < 0) return Double.NaN; double t = c; while (Math.abs(t - c/t) > epsilon * t) t = (c/t + t) / 2.0; return t; }
public static void main(String[] args) { double[] a = new double[args.length]; for (int i = 0; i < args.length; i++) a[i] = Double.parseDouble(args[i]); for (int i = 0; i < a.length; i++) System.out.println(Newton.sqrt(a[i])); }}
Function Call Trace
% java Newton 1 2 31.01.4142135623730951.7320508075688772
a[]
{ 1.0, 2.0, 3.0 }
args[]
{ "1", "2", "3" }
i
3
![Page 36: Function Call Trace](https://reader034.vdocuments.net/reader034/viewer/2022051215/568143a3550346895db02565/html5/thumbnails/36.jpg)
36
public class Newton {
public static double sqrt(double c) { double epsilon = 1E-15; if (c < 0) return Double.NaN; double t = c; while (Math.abs(t - c/t) > epsilon * t) t = (c/t + t) / 2.0; return t; }
public static void main(String[] args) { double[] a = new double[args.length]; for (int i = 0; i < args.length; i++) a[i] = Double.parseDouble(args[i]); for (int i = 0; i < a.length; i++) System.out.println(Newton.sqrt(a[i])); }}
Function Call Trace
% java Newton 1 2 31.01.4142135623730951.7320508075688772
a[]
{ 1.0, 2.0, 3.0 }
args[]
{ "1", "2", "3" }