Questions tagged [absolute-value]

Absolute value is a mathematical function that returns the non-negative value of a number without regard to its sign.

Absolute value is a mathematical function that returns the non-negative value of a number without regard to its sign.

For example, both 7 and -7 will have an absolute value of 7.

Many programming languages include a function for absolute value in their standard math libraries, often named abs() or similar.

More information: http://en.wikipedia.org/wiki/Absolute_value

219 questions
1
vote
1 answer

Solving an equation containing absolute value, with python 3

I'm trying to solve the following equation, with python 3.6.3: I did from sympy import * x = Symbol('x', real=True) solve(abs((abs(x**2-1)-x))-x) but I get the following message: Traceback (most recent call last): File "", line 1, in…
Luo Kaisa
  • 147
  • 5
1
vote
3 answers

Consolidating panda dataframes: Choose the smaller absolute value

I have two panda DataFrames: Dataframe A: date ticker return 2017-01-03 CRM 0.018040121229614625 2017-01-03 MSFT -0.0033444816053511683 2017-01-04 CRM 0.024198086662915008 2017-01-04 MSFT -0.0028809218950064386 2017-01-05 …
Alfonso_MA
  • 537
  • 5
  • 26
1
vote
0 answers

What is the fastest fabsf (floating point absolute value function) implementation in c#?

I am in the process of optimizing the most demanding function in a Unity 3d game. The most costly subroutine is the unity Mathf.Abs method which is being called on floating point values(NEVER DOUBLES). In cases, calls to this function are adding…
1
vote
5 answers

unable to convert negative values to positive in array?

I need to return true/false if there was any integer converted to positive in an array, I am able to return true or false however I am not able to convert the negative integers into positive? #include using namespace std; int…
Sarah_Xx
  • 123
  • 2
  • 10
1
vote
1 answer

Absolute value of variable in CPLEX api for matlab

I am trying to solve a model on Matlab by using CPLEX. When the objective is Maximize x1 + 2 x2 + 3 x3 + x4 Introducing cplex.Model.obj = [ 1; 2; 3; 1]; is enough. What shall I do when the objective is Maximize abs(x1) + 2 x2 + 3 x3 +…
1
vote
1 answer

How to get abs Mat in Android Opencv c++?

I would like to get absolute matrix in Android Opencv c++ library. I am using abs(Mat m) function but it will return MatExpr object. Do you know how to get Mat object just with absolute values of matrix? Mat * laplacian = getMat(byteArray,…
smeidak
  • 285
  • 1
  • 3
  • 13
1
vote
1 answer

Error when finding MAX ABS using indirect function in VLOOKUP

I am trying to set up a sheet that I can use as a template to sort data, find perticular values and create a chart. Everything is working fine for the maximum magnitude and average magnitude values I am looking for. I am running into an issue in the…
1
vote
1 answer

Scilab - How to get the maximum absolute value in a Matrix with its original sign?

I am using Scilab 5.5.2 I am trying to get the maximum absolute value in a vector. See this example a = [-9;-19;11] If I type: max(abs(a)) I get: 19 That's close to what I want. Yes, 19 is the maximum absolute value. However, I would like to have…
user7120460
1
vote
0 answers

How to sum absolute values from columns in dplyr?

I have this dataset with two columns and four rows x <- c(-1, -2, 2, 3) y <- c(0, -3, 2, -2) cbind(x, y) I want to sum the absolute values of columns x and y using dplyr and add results in column z. It should look like this z <- c(1, 5,…
user7476990
  • 11
  • 1
  • 7
1
vote
0 answers

How to copy a batch of relative Google Sheet formulas and paste in different location with original cell references?

I need to copy a load of rows of cells which contain various relative formulas and to past them in a different location but with those same cell references as in the original location. I understand that the '$' char does this at an individual level,…
jbk
  • 1,911
  • 19
  • 36
1
vote
1 answer

C++ fabs(long double) compiler warning

I want to have the absolute value of a long double. According to or , the following is available: double fabs (double x); float fabs (float x); long double fabs (long double x); However, when doing long double ld =…
Stingery
  • 432
  • 4
  • 16
1
vote
1 answer

Linear Programming - Absolute value greater than a constant

How would you convert the constraint |x| >= 2 so that it would work in a Linear Program (in particular, solving using Simplex). I understand how to convert |x| <= 2 as that would become x <= 2 and -x <= 2 However the same logic does not work when…
llll0
  • 95
  • 11
1
vote
1 answer

Absolute values in Matlab symbolic expressions

In a paper I'm reading, they write |x-y|^2 I'm trying to code this in Matlab using symbolic tools and I'm not quite sure how to read this, but I want to be sure to capture the proper interpretation. They don't really specify in the paper, but from…
ThatsRightJack
  • 721
  • 6
  • 29
1
vote
4 answers

Find closest value to 0 in range of values in Excel (with non-numeric fields)

I have a range of cells in Excel with various positive and negative numbers. The value of the cell is determined by an IF formula, and some of the cells in the range have no value (""). I need to find the absolute value of the nearest cell to 0. So…
Michael Mankus
  • 4,628
  • 9
  • 37
  • 63
1
vote
1 answer

ARM NEON: How does VQABS determine overflow conditon

Can somebody explain to me how the ARM NEON instruction VQABS operates. Per the documentation: "VQABS returns the absolute value of each element in a vector. If any of the results overflow, they are saturated and the sticky QC flag (FPSCR bit[27])…
Rocky
  • 11
  • 1