Using the Math package (in different programming languages) method sqrt to calculate the square root of a value.
Questions tagged [math.sqrt]
77 questions
1
vote
4 answers
Distinguishing large integers from near integers in python
I want to avoid my code mistaking a near integer for an integer. For example, 58106601358565889 has as its square root 241,053,109.00000001659385359763188, but when I used the following boolean test, 58106601358565889 fooled me into thinking it was…

Jeptha
- 65
- 8
1
vote
1 answer
How do you find sine, cosine, etc. in Minitran?
When using the Minitran language (used by Monash University in Australia to teach Fortran in around 1970) how do you ask for trigonometric functions like Sin, Cos, Tan, Log, Sqrt, etc?
The cards with which you submit your programs are like…

Nick Gammon
- 1,173
- 10
- 22
1
vote
3 answers
Why does Math.sqrt return 0 instead of the length of a vector?
public static double[] creeVec(double x, double y, double z){
//cree et retourne un tableau
double[] tab = new double[3];
tab[0]=x;
tab[1]=y;
tab[2]=z;
return tab;
}
public static double longueur(double[] tab){
…

Atala
- 1
- 6
1
vote
2 answers
How can i print native symbols on my android application?
I made a square root calculator on android platform. I added different language in my app and my issue starts from here.
In languages with different symbols, like Chinese, I can print symbols. But when I touch to calculate button, app shuts down. I…
user5280387
1
vote
2 answers
ValueError: Math domain error (for a 2nd grade equation function)
I've tried to solve the problem myself but i cant. Its a function in order to solve 2nd grade equations when y=0 like 'ax2+bx+c=0'. when i execute it it says me there is math domain error. if u can help me it will be nice thx.
a=raw_input('put a…

Albert
- 13
- 3
0
votes
3 answers
Fastest way to get square root in float value
I am trying to find a fastest way to make square root of any float number in C++. I am using this type of function in a huge particles movement calculation like calculation distance between two particle, we need a square root etc. So If any…

Gautam Jangid
- 109
- 8
0
votes
2 answers
I can't use "from math import sqrt" on Visual Studio Code
I'm new to this site, I'm recently trying to learn how to code in Python again, and now I'm doing an exercise that I could complete, but it's happening something that is annoying me.
I can import math successfully, but somehow, VSCode just doesn't…

Lucca Monteiro
- 7
- 2
0
votes
2 answers
How to do a arithmetic sequence with roots using a loop
What I want to do is by using a for loop, calculate the sum of roots under roots (not a math guy, don't know how you call that).
The sequence should go like this:
Sqrt(2 + Sqrt(2 + ... + Sqrt(2))), where n > 0.
For example, if n = 3 on the for loop…

Linascts
- 159
- 8
0
votes
0 answers
How compute the RMSE between two 3D array giving as output another 3D array?
I have two 3-dimension arrays actual.shape = [333,71,57] and predicted_cnn.shape = [333,71,57] [time, latitude, longitude]. Keeping the time fixed I can plot those two arrays as a 2-D map.
When I compute the RMSE root mean squared error between two…

onehalf
- 47
- 2
- 9
0
votes
1 answer
Math.sqrt showing an unexplained error in eclipse when trying to solve a second degree equation
I'm trying to create a program that solves second degree equations (ax 2 + bx + c = 0). It works fine when I remove Math.sqrt(delta) but having it is a very important part of the process and I can't figure out why it doesnt work.
When I run the…

ProgEnthusiast
- 59
- 1
- 1
- 5
0
votes
0 answers
pandas sqrt and roots do not work and yield NaN
I have dataframe with two numerical float values.
I want to do some math based on those columns values to calculate new columns.
those are the calculation I want to…

Reut
- 1,555
- 4
- 23
- 55
0
votes
0 answers
Difference in performance between Math.sqrt and Math.pow against Math.abs in JavaScript?
I was doing a programming task in JavaScript when I found out that a formula that involves an absolute value between substractions and a sum (Manhattan distance) is less efficient in execution time than a formula that involves the square root of the…
0
votes
0 answers
Why is this method saying the square of 1 is 3?
I am writing a function that takes in two parameters: alpha and beta. It then calculates N, which is the square root of (alpha^2 + beta^2). And then it returns a list [x, y] where x = alpha / N and y = beta /N. However, when I write out this code…

dancer103
- 11
- 1
0
votes
1 answer
Need to use extra option while compiling c code which includes
Whenever I include math.h to my c code I can't compile without the -lm option. I get this error message:
d.o: In function `refresh_position':
d.c:(.text+0x4df): undefined reference to `sqrt'
d.c:(.text+0x524): undefined reference to `sqrt'
collect2:…

Baran
- 131
- 8
0
votes
3 answers
Is there a way to align both these values from different languages?
Having issues with the sqrt function in two languages.
I have a JAVA API and C++ client, I'm trying to use the sqrt functions in both but they give me slightly different numbers.
The inputs are:
x = 25.0
y = 5625.0
Java:
double distance =…

VortexFX
- 127
- 7