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
0
votes
0 answers

Absolute value of real part in while loop expression

I'm wondering when my while loop expression is satisfied. Err is a [1x1551] complex double. Is my loop stopping when one value satisfies the expression (abs(real(err))>1e-4)? or when all values in the array satisfies the expression. The function is…
Malthe Eisum
  • 189
  • 11
0
votes
1 answer

How to find the difference of 2 values with overflow / overwrap values, modulus

Say I have a limit of 5 meaning values from 0,1,2,3,4,5 The difference from (5 to 0) or (5 to 0) is 1 The difference from (5 to 1) or (1 to 5) is 2 The difference from (0 to 4) or (4 to 0) is 2 The way I seem to understand this is to only use the…
SSpoke
  • 5,656
  • 10
  • 72
  • 124
0
votes
1 answer

How to check if a number is not within 50 decimal places of square root of two?

I understand that double might not be precise enough. However, I couldn't find a way to do so using BigDecimal. I tried while(Math.log10(Math.abs(a.subtract(new BigDecimal(1.41421356237309504880168872420969807856967187537694))) >= -50 ||…
0
votes
3 answers

Segmentation Fault Error; Absolute Value Table

I've been hammering myself on to this homework for a while now. And I can't seem to find what's wrong with it. My question is why do I keep getting segmentation fault errors everytime I execute this program. /* Description: A program that takes an…
leovic
  • 29
  • 6
0
votes
1 answer

I need an SSE shuffle routine to avoid negative numbers in a parallel subtraction

I'm working on an SSE2 implementation of an RGB565/RGB555 Alpha Blend and I've run into an issue I haven't been able to wrap my head around. This is the Alpha Blend in C++: #define ALPHA_BLEND_X_W(dst, src, alpha)\ ts = src; td = dst;\ td =…
0
votes
1 answer

Is the absolute value function differentiable at x=0

Both Wolfram Alpha (diff abs(x)) and Maxima (diff(abs(x),x,1);) say that the absolute value function is differentiable at x=0, and that the derivative is x/abs(x). How would you go about excluding the point x=0 from the domain when formulating the…
0
votes
4 answers

type error in python

I have a list of ints (hitTableWord) and I am trying to add 1 over the absolute value of the numbers for the whole list and I keep getting this error message in python: metric = metric + 1/(abs(metricNumber)) TypeError: unsupported operand type(s)…
English Grad
  • 1,365
  • 5
  • 21
  • 40
-1
votes
1 answer

Python cplex: How do I get the absolute value of a linear expression in an optimization model?

I have a minimize problem and its objective function need to get absolute of a linear equation. But when I run these code, it raise this error TypeError: bad operand type for abs(): 'LinearExpr'. How can I fix this? I searched this error on Internet…
-1
votes
1 answer

How do I use Custom Number Formats to find Absolute Value in Google Sheets?

I am making a budget sheet, and I am importing expenses which are written as negative numbers. I want to write a custom number format in Google Sheets which will automatically change every negative number to positive, aka which will convert it to…
-1
votes
2 answers

How to find absolute value in C?

I need to lighten the code, and then eliminate the underlying if that check if the subtraction are <0 and if the condition is true I multiply * -1 in order to have subtraction >0 (absolute value). I wonder if there is a function or some operator…
user18624637
-1
votes
1 answer

sorting an array such that absolute values are sorted and positive values are printed before negative values

for the given code #include #include #include #include void swap(int *xp, int *yp) { int temp = *xp; *xp = *yp; *yp = temp; } void selectionSort(int arr[], int n) { int i, j, min_idx; for (i…
-1
votes
1 answer

ALMOST THERE: Given an integer n, return True if n is within 10 of either 100 or 200

How does "if n is within 10 of either 100 or 200" correlate with using the absolute value function? I get what absolute value is, but wouldn't there be an easier/cleaner way without using abs()? Thanks
-1
votes
1 answer

How to find the maximum x value of a function?

I need to find the maximum x value associated to the maximum y value of the following function that I plot using Python matplotlib module: # Import modules import numpy as np from matplotlib import pyplot as plt # Define the function x =…
Student.py
  • 225
  • 3
  • 14
-1
votes
1 answer

A math problem i encountered when trying to make a program

A rather simple/complicated math problem I encountered whilst programming. Here's the simplified version of it: a+c=e b=absolute value of(X-R) C=absolute value of(X-r) R-r? a,c,e,b,X,R are all known but r isn't. Edit if(x-R>0&&x-r>0)…
Icarus
  • 501
  • 2
  • 16
-1
votes
1 answer

Abs method in emgucv 3.X

I use C# and EmguCV 3.X. I need Abs method for Sobel method to make postive negative edges. Is there any method like Abs() in emgucv 3.x? Processing time is very important for me. Any help will be appreciated.
Babak.Abad
  • 2,839
  • 10
  • 40
  • 74
1 2 3
14
15