sqrt Questions

2

Solved

If you take a number, take its square root, drop the decimal, and then raise it to the second power, the result should always be less than or equal to the original number. This seems to hold...
Reichel asked 22/1, 2018 at 1:21

2

bc, a Linux command-line calculator, is proficient enough to calculate 3^2 9 Even a negative exponent doesn't confuse it: 3^-2 0.11111 Yet it fails when it encounters 9^0.5 Runtime warning (...
Diaper asked 23/4, 2013 at 8:49

4

Solved

Why does the math module return the wrong result? First test A = 12345678917 print 'A =',A B = sqrt(A**2) print 'B =',int(B) Result A = 12345678917 B = 12345678917 Here, the result is correc...
Plowshare asked 9/1, 2017 at 15:39

1

Solved

I've been told this code snippet is equivalent to (int)sqrt(n) int s(int n) { for (int i = 1, k = 0; n > 0; i += 2) { if (k + i > n) return i / 2; k += i; } return 0; } And it ...
Philomel asked 17/12, 2016 at 0:43

2

Solved

I have playing around with basic math function implementations in C++ for academic purposes. Today, I benchmarked the following code for Square Root: inline float sqrt_new(float n) { __asm { fld...
Hoehne asked 22/9, 2016 at 6:8

2

Consider the following code: #include <cstdio> #include <cmath> const int COUNT = 1000000000; int main() { double sum = 0; for (int i = 1; i <= COUNT; ++i) { sum += sqrt(i); ...
Bruton asked 5/5, 2016 at 6:31

4

Solved

So i have this homework to do "Using functions overloading define 3 functions with the same name but with different prams type (int, int*, int&) that will return the square root of the value." ...
Teenateenage asked 5/3, 2016 at 21:10

6

Solved

In an app I'm profiling, I found that in some scenarios this function is able to take over 10% of total execution time. I've seen discussion over the years of faster sqrt implementations using sne...
Furnishings asked 14/4, 2010 at 13:29

3

I have to check an inequality containing square roots. To avoid incorrect results due to floating point inaccuracy and rounding, I use std::nextafter() to get an upper/lower bound: #include <cf...
Cornucopia asked 25/8, 2015 at 15:25

1

Solved

Do you know how to do this simple line of code without error using Boost::multiprecison ? boost::multiprecision::cpp_int v, uMax, candidate; //... v += 6 * ceil((sqrt(uMax * uMax - candidate) - v)...
Haematoma asked 5/4, 2015 at 13:29

3

Solved

Is it possible to compute the square root of an integer with a metafunction with the following signature : template<unsigned int N> inline double sqrt(); (or maybe using the constexpr keyw...
Sudarium asked 2/9, 2012 at 3:44

3

I'm working with very large numbers (1,000,000 digits) and I need to calculate their square root. I seem to be hitting on a limit in my code. y = 10**309 x = y**0.5 print(x) And I'm getting this e...
Sector asked 30/1, 2015 at 16:8

2

Solved

I have several questions with the following algorithms to tell if a number is prime, I also know that with the sieve of Eratosthenes can be faster response. Why is faster to compute i i * sqrt (...
Refill asked 24/11, 2014 at 18:58

1

Solved

Consider the following code: #include <cmath> #include <cstdio> const int COUNT = 100000000; int main() { double sum = 0; for (int i = 1; i <= COUNT; ++i) sum += sqrt(i); prin...
Clavius asked 24/10, 2014 at 11:35

9

Solved

I need a simple function is_square :: Int -> Bool which determines if an Int N a perfect square (is there an integer x such that x*x = N). Of course I can just write something like is_squar...
Funk asked 11/5, 2010 at 2:23

7

Solved

I don't know if I'm missing something obvious, but it appears that I'm unable to compute square roots of a variable in C; the sqrt() function only seems to work on constants. This is my code:...
Gunas asked 20/8, 2010 at 18:5

1

Solved

def ellipse(numPoints, genX=np.linspace, HALF_WIDTH=10, HALF_HEIGHT=6.5): xs = 10.*genX(-1,1,numPoints) ys = 6.5*np.sqrt(1-(xs**2)) return(xs, ys, "-") I am getting an error that states that a...
Pip asked 8/4, 2014 at 23:6

2

Solved

Everyone knows sqrt function from math.h/cmath in C/C++ - it returns square root of its argument. Of course, it has to do it with some error, because not every number can be stored precisely. But a...
Dulcy asked 7/3, 2014 at 19:57

1

Solved

I have MinGW GCC 4.8.1 and the following code: #include <iostream> #include <cmath> double eval(int a, int b){ return std::sqrt(a) + std::sqrt(b); } int main(){ double first ...
Sublimity asked 18/1, 2014 at 6:49

3

Solved

I would like to look at the way Python does computes square roots, so I tried to find the definition for math.sqrt(), but I can't find it anywhere. I have looked in _math.c, mathmodule.c, and elsew...
Tram asked 29/3, 2011 at 17:3

2

Solved

I have the following C++ test program called test.cpp: #include <cmath> #include <iostream> double sqrt(double d) { return std::sqrt(d); } int main() { std::cout << "sqrt(4): ...
Plainclothesman asked 31/10, 2013 at 1:16

3

Solved

I was wondering why there is sqrt() function in C/c++ as we can achieve the same using pow(x,0.5); how is sqrt(x) different for pow(x,0.5) . Is there a specific reason of having sqrt func...
Eurystheus asked 2/7, 2013 at 4:37

3

Solved

I'm trying to implement Fast Inverse Square Root on java in order to speed up vector normalization. However, when I implement the single-precision version in Java, I get speeds about the same as 1F...
Testify asked 14/5, 2013 at 19:19

2

Solved

I compile my program in Linux - it has the following line: std::sqrt((double)num); On Windows, it is ok. However, on Linux, I get an error: sqrt is not a member of std I have already included ma...
Amanita asked 13/5, 2013 at 8:58

1

Solved

>>> np.__version__ '1.7.0' >>> np.sqrt(10000000000000000000) 3162277660.1683793 >>> np.sqrt(100000000000000000000.) 10000000000.0 >>> np.sqrt(1000000000000000000...
Tallage asked 13/3, 2013 at 16:22

© 2022 - 2024 — McMap. All rights reserved.