sqrt Questions
4
Solved
Unfortunately, the standard C++ library doesn't have a single call for sincos, which gives a place for this question.
First question:
If I want to calculate a sin and a cos, is it cheaper to calc...
Universe asked 13/9, 2013 at 19:38
5
I was asked to calculate the following nested root expression using recursion only.
I wrote the code below that works, but they allowed us to use only one function and 1 input n for the purpose ...
10
Solved
I need to calculate the square root of some numbers, for example √9 = 3 and √2 = 1.4142. How can I do it in Python?
The inputs will probably be all positive integers, and relatively small (say less...
4
Solved
What is the difference between x**(1/2) , math.sqrt() and cmath.sqrt()?
Why does cmath.sqrt() get complex roots of a quadratic right alone? Should I use that for my square roots exclusively? What...
Herminiahermione asked 13/11, 2015 at 2:25
8
Solved
We find various tricks to replace std::sqrt (Timing Square Root) and some for std::exp (Using Faster Exponential Approximation) , but I find nothing to replace std::log.
It's part of loops in my pr...
Primo asked 2/10, 2016 at 20:27
14
Solved
Is there an integer square root somewhere in python, or in standard libraries? I want it to be exact (i.e. return an integer), and raise an exception if the input isn't a perfect square.
I tried us...
5
Solved
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double a = sqrt(2);
cout << a << endl;
}
hi this is the program to find sqrt of 2 it prints just...
6
I want to design a synthesizable module in Verilog which will take only one cycle in calculating square root of given input of 32 bit.
1
Solved
Specifically, this is the code I'm talking about:
float InvSqrt(float x) {
float xhalf = 0.5f*x;
int i = *(int*)&x; // warning: strict-aliasing UB, use memcpy instead
i = 0x5f375a86- (i >...
Royceroyd asked 24/3, 2022 at 19:5
2
I practice for an exam in Java.
One of the questions I faced today is:
Given an array with n numbers, I need to check if there are 2 subarrays(doesn't have to be equal) that their multiplication eq...
7
Solved
2
Solved
With Perl, one could use bignum to set the level of precision for all operators. As in:
use bignum ( p => -50 );
print sqrt(20); # 4.47213595499957939281834733746255247088123671922305
With Rak...
Poona asked 19/8, 2020 at 9:43
7
Solved
I find myself typing
double foo=1.0/sqrt(...);
a lot, and I've heard that modern processors have built-in inverse square root opcodes.
Is there a C or C++ standard library inverse square root f...
1
Solved
I wondering why the compiler let this pass and is giving the right output, although sqrt() from its prototype normally should only get an double value as argument:
In C99 the declaration of the pr...
Karleen asked 12/12, 2019 at 18:11
3
This is just to satisfy my own curiosity.
Is there an implementation of this:
float InvSqrt (float x)
{
float xhalf = 0.5f*x;
int i = *(int*)&x;
i = 0x5f3759df - (i>>1);
x = *(float...
Ischium asked 28/11, 2019 at 4:45
3
Solved
I am looking for a C++ function that returns the inverse sqrt of a float: rsqrt(x) = 1/sqrt(x) by using the exact method like the built-in XMM operation RSQRTSS (cf. https://www.felixcloutier.com/x...
Wretch asked 29/10, 2019 at 19:31
6
I am in a need of fast integer square root that does not involve any explicit division. The target RISC architecture can do operations like add, mul, sub, shift in one cycle (well - the operation's...
5
Solved
As part of a program that I'm writing, I need to compare two values in the form a + sqrt(b) where a and b are unsigned integers. As this is part of a tight loop, I'd like this comparison to run as ...
Prefatory asked 8/5, 2019 at 8:58
3
Solved
I am looking for the best inverse square root algorithm for fixed point 16.16 numbers. The code below is what I have so far(but basically it takes the square root and divides by the original number...
Connotation asked 8/6, 2011 at 23:23
9
Solved
I was finding out the algorithm for finding out the square root without using sqrt function and then tried to put into programming. I end up with this working code in C++
#include <iostream>...
2
2
I'm playing around with swift and have the following simple code
I want to check how "sqrt" function is implemented, so I tried to click on "Darwin.C.math" link but nothing happened. I googled ...
2
Solved
Please help me to write a function to compute the square root of positive real numbers using the formula:
x i+1 = (1/2) * (xi + (A / x1)),
where 'A' - input real number.
On the zero iteration n...
Causal asked 23/9, 2018 at 17:18
5
Solved
x = 16
sqrt = x**(.5) #returns 4
sqrt = x**(1/2) #returns 1
I know I can import math and use sqrt, but I'm looking for an answer to the above. What is integer division in Python 2? This beh...
Yonita asked 7/3, 2012 at 2:48
4
Solved
What causes the problem?
from math import sqrt
print "a : "
a = float(raw_input())
print "b : "
b = float(raw_input())
print "c : "
c = float(raw_input())
d = (a + b +...
1 Next >
© 2022 - 2024 — McMap. All rights reserved.