Questions tagged [linear-equation]

An algebraic equation of the form y = mx+b

A linear equation is an algebraic equation in which each term is either a constant or the product of a constant and (the first power of) a single variable. More on Wolfram and Wikipedia.

173 questions
47
votes
10 answers

Solving a linear equation

I need to programmatically solve a system of linear equations in C, Objective C, or (if needed) C++. Here's an example of the equations: -44.3940 = a * 50.0 + b * 37.0 + tx -45.3049 = a * 43.0 + b * 39.0 + tx -44.9594 = a * 52.0 + b * 41.0 +…
Adam Ernst
  • 45,666
  • 17
  • 55
  • 71
18
votes
1 answer

2D isometric - SFML - Right formulas, wrong coordinate range

I don't work with tiles but cubes drawn with sf::Vertex. Each cubes have 6 sides with 4 points each. So i just have to cubes[numCube].sides()[numSide].... to select a side. I create cubes layer.cpp : for(int J = 0; J < mapSize; J++) { …
Madz
  • 287
  • 3
  • 14
9
votes
2 answers

Linear fitting in python with uncertainty in both x and y coordinates

Hi I would like to ask my fellow python users how they perform their linear fitting. I have been searching for the last two weeks on methods/libraries to perform this task and I would like to share my experience: If you want to perform a linear…
Delosari
  • 736
  • 1
  • 13
  • 25
8
votes
0 answers

Photo collage algorithm

I am trying to build a script that will dynamically arrange photos like a collage very similar to what is done on http://lightbox.com/explore#spotlight. I can off course write code that would handle each case with different sets of photos but I…
Surfer
  • 131
  • 1
  • 3
7
votes
4 answers

Solving a system of linear equations in a non-square matrix

I have a system of linear equations that make up an NxM matrix (i.e. Non-square) which I need to solve - or at least attempt to solve in order to show that there is no solution to the system. (more likely than not, there will be no solution) As I…
DAVco
  • 185
  • 1
  • 2
  • 9
7
votes
1 answer

Inequalities implied by a system of linear inequalities/equalities in Matlab: numerical arguments or counterexample?

I have a system of linear inequalities/equalities to solve in Matlab and I use linprog. As some of the inequalities are strict I use a very small costant eps to get get the strict inclusion as explained here The function solve below solves the…
TEX
  • 2,098
  • 15
  • 36
7
votes
1 answer

sympy - symbolic sum over symbolic number of elements

What is the most appropriate way to express the following in 'sympy': A sum over samples 'x[i]' with 'i' going from concrete 0 to symbolic 'N'. 'x[i]' itself shall be symbolic, i.e. always appear as variable. The goal is to use these…
Frank-Rene Schäfer
  • 2,586
  • 17
  • 38
7
votes
3 answers

resolve a system of linked equations with different modulo

Is there any algorithm to solve a system of equations expressed in different modulo spaces? For exemple, consider this system of equations: (x1 + x2 ) % 2 = 0 ( x2 + x3) % 2 = 0 (x1 + x2 + x3) % 3 = 2 One of the solutions of this system…
6
votes
4 answers

Correct way to standardize/scale/normalize multiple variables following power law distribution for use in linear combination

I'd like to combine a few metrics of nodes in a social network graph into a single value for rank ordering the nodes: in_degree + betweenness_centrality = informal_power_index The problem is that in_degree and betweenness_centrality are…
Jacob Rigby
  • 1,123
  • 2
  • 13
  • 20
6
votes
1 answer

Create and solve different combinations of linear equation systems using data stored in several matrices in python

I want to give an easy example for what I would like to do. I have some data which is calculated prior to this step and stored in matrices. In this easy case let’s take only two 2x2 matrices. They could look like this: A1=np.array([[1, 2], [0.5,…
David_D
  • 63
  • 5
6
votes
2 answers

Why permutation matrices are used to swap rows of an array?

What are the advantages of using a permutation matrix to swap rows? Why one would create a permutation matrix and then apply a matrix multiplication, is it easier and more efficient than just swapping rows with a for loop?
erkangur
  • 1,918
  • 5
  • 20
  • 31
6
votes
3 answers

Library for finding any solution of any number of linear equations with any number of variables

I have to finding any solution (there may exist many or none) of any number of given liner equations with any number of variables. In Java. What libraries and method use? What to implement? I want to make it with at least work as possible.
adf88
  • 3,931
  • 21
  • 21
6
votes
2 answers

How to solve systems of XOR equations?

I have to solve a system that consists of 32 xor equations, each involving 15 of 32 variables. One would look like this: i[0] = p[0] ^ p[4] ^ p[5] ^ p[10] ^ p[11] ^ p[20] ^ p[21] ^ p[22] ^ p[23] ^ p[25] ^ p[26] ^ p[27] ^ p[28] ^ p[30] ^ p[31] i[n]…
awpsoleet
  • 247
  • 3
  • 11
6
votes
4 answers

Eliminating rounding errors from matrix

My problem is that I have a Matrix where the sum of all rows, and the sum of all columns is zero. All numbers are rounded to x decimals. Then I multiply the entire matrix with a number between 0 and 1 (eg. 1/6) and round all the numbers to x…
6
votes
3 answers

linear equation java

I am trying to convert the equation below into programming code. The purpose is to find the intersecting point of the two lines. And to pront (y1 - y2)x - (x1 - x2)y = (y1 - y2)x1 - (x1 - x2)y1 (y3 - y4)x - (x3 - x4)y = (y3 - y4)x3 - (x3 -…
xdaimon
  • 88
  • 2
  • 8
1
2 3
11 12