Questions tagged [math]

Math involves the manipulation of numbers within a program. For general math questions, please ask on math.stackexchange.com. Note: If your question is about unexpected results in floating point calculations, please read https://stackoverflow.com/questions/588004/is-floating-point-math-broken first.

Mathematics is the study of quantity, structure, space, and change. Mathematicians seek out patterns, formulate new conjectures, and establish truth by rigorous deduction from appropriately chosen axioms and definitions.

Through the use of abstraction and logical reasoning, mathematics evolved from counting, calculation, measurement, and the systematic study of the shapes and motions of physical objects. Practical mathematics has been a human activity for as far back as written records exist.

Mathematics is behind all programming at some level, but math questions here should be specifically related to a programmed implementation. General math questions can be asked at Mathematics. Research level mathematics questions can be asked at MathOverflow.

Notable questions that may be dupe targets. Check these questions before asking again!

43708 questions
15
votes
1 answer

Ease Out Cubic - Function Arguments Explanation

On this great web page I found a list of easing algorithms that can add nice visual appeal to my webpages. Despite, I found there brief mention of the function arguments (see below), the algorithm does not behave as I would wish. Can I kindly ask…
Bunkai.Satori
  • 4,698
  • 13
  • 49
  • 77
15
votes
4 answers

Signed angle between two vectors without a reference plane

(In three dimensions) I'm looking for a way to compute the signed angle between two vectors, given no information other than those vectors. As answered in this question, it is simple enough to compute the signed angle given the normal of a plane to…
metatheorem
  • 568
  • 1
  • 3
  • 14
15
votes
2 answers

Resize UITableViewCell to UILabel's height dynamically

I want to resize cell's height according to the label's height and label's height according to text. Or is there any way I can resize the cell's height according to the text entered in UITextView?
Rahul Vyas
  • 28,260
  • 49
  • 182
  • 256
14
votes
4 answers

Evaluate Mathematical Function from String

Can you give me some ideas about how can I make a simple mathematical expression parser in C? User enters a mathematical function in a string and from the string I want to create the function in C. eg. x + sin(2*x) -> return x + sin(2x); Thanks in…
bokarinho
  • 193
  • 1
  • 1
  • 6
14
votes
4 answers

Which numerical library to use for porting from Matlab to C++?

I am currently prototyping some algorithms in Matlab that rely on matrix, DSP, statistics and image analysis functionality. Some examples of what I may need: eigenvectors convolution in 2D and 3D FFT Short Time Fourier Transform Hilbert…
Andy
  • 3,251
  • 4
  • 32
  • 53
14
votes
5 answers

Fastest way to calculate the distance between two CGPoints?

Distance between two points: sqrt((x1-x2)^2 + (y1-y2)^2) Is there a way to do this math faster in objective-C ? EDIT: I think I need to clarify above. I wrote the formula above just to clarify what formula I am using to calculate the distance. ^ is…
xcoder
  • 967
  • 2
  • 11
  • 24
14
votes
2 answers

carry/overflow & subtraction in x86

I'm trying to wrap my head around overflow & carry flags in x86. As I understand it, for addition of signed 2's complement numbers, the flags can only be generated in one of four ways (my examples are 4-bit numbers): pos+pos = neg (overflow) 0111…
Robz
  • 1,747
  • 5
  • 21
  • 35
14
votes
6 answers

Calculate Nth root with integer arithmetic

There are a couple of ways to find integer square roots using only integer arithmetic. For example this one. It makes for interesting reading and also a very interesting theory, particularly for my generation where such techniques aren't so useful…
Matt
  • 7,100
  • 3
  • 28
  • 58
14
votes
9 answers

Which floor is redundant in floor(sqrt(floor(x)))?

I have floor(sqrt(floor(x))). Which is true: The inner floor is redundant. The outer floor is redundant.
unj2
  • 52,135
  • 87
  • 247
  • 375
14
votes
10 answers

Max square size for unknown number inside rectangle

If I have a set of tiles (squares) which can be any number and they are to fill a container (rectangle) of an unknown size how do I work out the maximum size of the tiles without having any of them overlap. So if I have 2 tiles and the rectangle is…
kenneth
  • 1,055
  • 1
  • 8
  • 15
14
votes
3 answers

Why is the sum of an empty set null?

If I do: int updateGamePlays = db.tblArcadeGames.Where(c => c.ParentGameID == GameID).Sum(c => c.Plays); If no records are returned in this query it throws: System.InvalidOperationException: The null value cannot be assigned to a member with…
Tom Gullen
  • 61,249
  • 84
  • 283
  • 456
14
votes
2 answers

Addition and multiplication in a Galois Field

I am attempting to generate QR codes on an extremely limited embedded platform. Everything in the specification seems fairly straightforward except for generating the error correction codewords. I have looked at a bunch of existing implementations,…
captncraig
  • 22,118
  • 17
  • 108
  • 151
14
votes
6 answers

Algorithm to find which numbers from a list of size n sum to another number

I have a decimal number (let's call it goal) and an array of other decimal numbers (let's call the array elements) and I need to find all the combinations of numbers from elements which sum to goal. I have a preference for a solution in C# (.Net…
Sam Meldrum
  • 13,835
  • 6
  • 33
  • 40
14
votes
1 answer

Merge 2d line segments

I am looking for a way to join together 2D line segments. A line segment is made of up two vector points, the start of the line segment and the end point of the line segment. I want to join line segments that look like they should form the same…
Jkh2
  • 1,010
  • 1
  • 13
  • 25
14
votes
15 answers

Recursive Fibonacci memoization

I need some help with a program I'm writing for my Programming II class at universtiy. The question asks that one calculates the Fibonacci sequence using recursion. One must store the calculated Fibonacci numbers in an array to stop unnecessary…
Eogcloud
  • 1,335
  • 4
  • 19
  • 44
1 2 3
99
100