Questions tagged [algebra]

Algebra is the branch of mathematics concerning the study of the rules of operations and relations, and the constructions and concepts arising from them. Questions about algebra that are not related to programming are off-topic at Stack Overflow.

Together with geometry, analysis, topology, combinatorics, and number theory, algebra is one of the main branches of pure mathematics.

Elementary algebra, often part of the curriculum in secondary education, introduces the concept of variables representing numbers. Statements based on these variables are manipulated using the rules of operations that apply to numbers, such as addition. This can be done for a variety of reasons, including equation solving. Algebra is much broader than elementary algebra and studies what happens when different rules of operations are used and when operations are devised for things other than numbers. Addition and multiplication can be generalized and their precise definitions lead to structures such as groups, rings and fields, studied in the area of mathematics called abstract algebra.

873 questions
19
votes
4 answers

C# library for algebra simplification and solving

There are quite a few algebra solvers and simplifiers on the web (for example, the decent one at algebra.com). However, I'm looking for something I can plug into C# as part of a larger project (I'm making my own calculator, but obviously I'd ask…
Dan W
  • 3,520
  • 7
  • 42
  • 69
19
votes
4 answers

Calculating 1^X + 2^X + ... + N^X mod 1000000007

Is there any algorithm to calculate (1^x + 2^x + 3^x + ... + n^x) mod 1000000007? Note: a^b is the b-th power of a. The constraints are 1 <= n <= 10^16, 1 <= x <= 1000. So the value of N is very large. I can only solve for O(m log m) if m =…
square1001
  • 1,402
  • 11
  • 26
18
votes
6 answers

How can I remove a column from a sparse matrix efficiently?

If I am using the sparse.lil_matrix format, how can I remove a column from the matrix easily and efficiently?
Brandon Pelfrey
  • 2,449
  • 6
  • 22
  • 22
17
votes
1 answer

Simplify Regular Expression in Mathematica

I recently found out about Kleene algebra for manipulating and simplifying regular expressions. I'm wondering if this has been build into any computational software programs like Mathematica? It would be great to have a computational tool for doing…
Thomas Ahle
  • 30,774
  • 21
  • 92
  • 114
13
votes
6 answers

How could I implement logical implication with bitwise or other efficient code in C?

I want to implement a logical operation that works as efficient as possible. I need this truth table: p q p → q T T T T F F F T T F F T This, according to wikipedia is called "logical implication" I've been…
alvatar
  • 3,340
  • 6
  • 38
  • 50
13
votes
2 answers

Can I model a list of successes with short circuiting failure via the composition of applicative functors?

The user 'singpolyma' asked on reddit if there was some general structure underlying: data FailList a e = Done | Next a (FailList a e) | Fail e A free monad was suggested, but I wondered if this could be modeled more generally via applicative…
ocharles
  • 6,172
  • 2
  • 35
  • 46
13
votes
6 answers

What is a formula to get a vector perpendicular to another vector?

What is a formula to get a three dimensional vector B lying on the plane perpendicular to a vector A? That is, given a vector A, what is a formula f(angle,modulus) which gives a vector that is perpendicular to A, with said modulus and rotated…
MaiaVictor
  • 51,090
  • 44
  • 144
  • 286
12
votes
2 answers

How to make catamorphisms work with parameterized/indexed types?

I recently learned a bit about F-algebras: https://www.fpcomplete.com/user/bartosz/understanding-algebras. I wanted to lift this functionality to more advanced types (indexed and higher-kinded). Furthermore, I checked "Giving Haskell a Promotion"…
Mathijs Kwik
  • 1,227
  • 9
  • 12
11
votes
3 answers

Expansion of algebraic term

I am trying to expand an algebraic term. (x+1)(x+1)/x => x + 2 + x^-1 (x+1)^3 => x^3 + 3x^2 + 3x + 1 (x^2*x)(x^2) => x^5 This is my attempt at it. I have tried a lot of ways trying to fix the problems below. Problems: Like terms should be added…
user7633250
11
votes
7 answers

Greatest GCD between some numbers

We've got some nonnegative numbers. We want to find the pair with maximum gcd. actually this maximum is more important than the pair! For example if we have: 2 4 5 15 gcd(2,4)=2 gcd(2,5)=1 gcd(2,15)=1 gcd(4,5)=1 gcd(4,15)=1 gcd(5,15)=5 The answer is…
user182513
11
votes
4 answers

Math.Pow() vs Math.Exp() C# .Net

Can anyone provide an explanation of the difference between using Math.Pow() and Math.Exp() in C# and .net ? Is Exp()just taking a number to the Power using itself as the Exponent?
CraigJSte
  • 912
  • 6
  • 17
  • 33
10
votes
3 answers

Does the functionality of Grouping operator `()` in JavaScript differ from Haskell or other programming languages?

Grouping operator ( ) in JavaScript The grouping operator ( ) controls the precedence of evaluation in expressions. Does the functionality ( ) in JavaScript itself differ from Haskell or any other programming languages? In other words, Is the…
smiknof
  • 129
  • 5
10
votes
5 answers

Wanting to write a raytracer, stuck on what algebra library to use (C++)

I've been wanting to write my own multithreaded realtime raytracer in C++, but I don't want to implement all the vector and matrix logic that comes with it. I figured I'd do some research to find a good library for this, but I haven't had much…
robrene
  • 359
  • 3
  • 14
10
votes
4 answers

Initial algebra for rose trees

As far as I understand, recursive data types from Haskell correspond to initial algebras of endofunctors from the Hask category [1, 2]. For example: Natural numbers, data Nat = Zero | Succ Nat, correspond to the initial algebra of the endofunctor…
10
votes
1 answer

Writing generic instances for Fix/Mu in F-algebras

After reading Milewski's F-algebra article, I tried to implement it and use for a real-world problem. However, I can't seem to figure out how to write instances for Fix, newtype Fix f = Fx { unFix :: f (Fix f) } cata :: Functor f => (f a -> a) ->…
1
2
3
58 59