Download benchmarks/quixbugs/java/SQRT.java from SevdanurGenc/LLM-Automated-Test-Generation-Agent: direct link, hf CLI and curl.
- Browser
- Download file 633 Bytes
-
https://huggingface.co/SevdanurGenc/LLM-Automated-Test-Generation-Agent/resolve/main/benchmarks/quixbugs/java/SQRT.java
- Command line
-
hf download hf://SevdanurGenc/LLM-Automated-Test-Generation-Agent/benchmarks/quixbugs/java/SQRT.java
-
curl -L -o SQRT.java https://huggingface.co/SevdanurGenc/LLM-Automated-Test-Generation-Agent/resolve/main/benchmarks/quixbugs/java/SQRT.java
633 Bytes
| import java.util.*; | |
| /** | |
| * Square Root | |
| * | |
| * Newton-Raphson method implementation. | |
| * | |
| * | |
| * Input: | |
| * x: A float | |
| * epsilon: A float | |
| * | |
| * Precondition: | |
| * x >= 1 and epsilon > 0 | |
| * | |
| * Output: | |
| * A float in the interval [sqrt(x) - epsilon, sqrt(x) + epsilon] | |
| * | |
| * Example: | |
| * >>> sqrt(2, 0.01) | |
| * 1.4166666666666665 | |
| * | |
| * @author derricklin | |
| */ | |
| public class SQRT { | |
| public static double sqrt(double x, double epsilon) { | |
| double approx = x / 2d; | |
| while (Math.abs(x-approx*approx) > epsilon) { | |
| approx = 0.5d * (approx + x / approx); | |
| } | |
| return approx; | |
| } | |
| } | |