# \#mathematics

**URL:** https://forum.elixirforum.com/tag/mathematics/183.md

[Latest](https://forum.elixirforum.com/latest.md) · [Categories](https://forum.elixirforum.com/categories.md) · [Tags](https://forum.elixirforum.com/tags.md)

---

## [Optex - mathematical optimization (LP/MILP/QP/SOCP) with in-process solvers](https://forum.elixirforum.com/t/optex-mathematical-optimization-lp-milp-qp-socp-with-in-process-solvers/76085)

<div class="topic-metadata">

**Author:** [@eduardosalaz](https://forum.elixirforum.com/u/eduardosalaz)\
**Replies:** 0\
**Last updated:** [July 23, 2026, 5:04am UTC](https://forum.elixirforum.com/t/optex-mathematical-optimization-lp-milp-qp-socp-with-in-process-solvers/76085 "2026-07-23T05:04:00Z")

</div>

I’ve released Optex, a library for modeling and solving mathematical optimization problems from Elixir, with the solvers running in-process via Rustler rather than behind a service call. If you’ve ever needed to answer …

---

## [filter\_ex - Adaptive Kalman filter implemented with Nx](https://forum.elixirforum.com/t/filter-ex-adaptive-kalman-filter-implemented-with-nx/67567)

<div class="topic-metadata">

**Author:** [@elcritch](https://forum.elixirforum.com/u/elcritch)\
**Replies:** 0\
**Last updated:** [November 19, 2024, 11:07am UTC](https://forum.elixirforum.com/t/filter-ex-adaptive-kalman-filter-implemented-with-nx/67567 "2024-11-19T11:07:09Z")

</div>

Adaptive Kalman Filter This library ports an adaptive Kalman filter from FilterPy. There was an existing Kalman filter in Elixir however it’s a simple 1D implementation without adaptive gain, which I needed. This versio…

---

## [Create all possible teams from a list of players](https://forum.elixirforum.com/t/create-all-possible-teams-from-a-list-of-players/64892)

<div class="topic-metadata">

**Author:** [@joshua.aug](https://forum.elixirforum.com/u/joshua.aug)\
**Replies:** 6\
**Last updated:** [July 14, 2024, 12:58pm UTC](https://forum.elixirforum.com/t/create-all-possible-teams-from-a-list-of-players/64892 "2024-07-14T12:58:31Z")

</div>

Say I have a list of players and I want to separate them into two teams of identical size. I want to know what are all the possibilities. Here is some code that works if I have 16 players and want to know all possible c…

---

## [Calculating element-to-element differences and sums in Nx](https://forum.elixirforum.com/t/calculating-element-to-element-differences-and-sums-in-nx/61591)

<div class="topic-metadata">

**Author:** [@al2o3cr](https://forum.elixirforum.com/u/al2o3cr)\
**Replies:** 2\
**Last updated:** [February 12, 2024, 3:09am UTC](https://forum.elixirforum.com/t/calculating-element-to-element-differences-and-sums-in-nx/61591 "2024-02-12T03:09:08Z")

</div>

Many years ago, I used a system called Yorick for doing array calculations. One feature that was really useful was a series of functions for taking differences and sums within a vector. Ref: Yorick User Manual The simpl…

---

## [Exterval - Inclusive/Exclusive Real Valued Intervals](https://forum.elixirforum.com/t/exterval-inclusive-exclusive-real-valued-intervals/58428)

<div class="topic-metadata">

**Author:** [@acalejos](https://forum.elixirforum.com/u/acalejos)\
**Replies:** 1\
**Last updated:** [January 6, 2024, 9:37pm UTC](https://forum.elixirforum.com/t/exterval-inclusive-exclusive-real-valued-intervals/58428 "2024-01-06T21:37:44Z")

</div>

I was finding myself needing a library to check for real-valued interval memberships. This was from writing libraries whose parameters must adhere to these restrictions, such as regularization terms or learning rates. T…

---

## [Any functions providing matrix multiplication?](https://forum.elixirforum.com/t/any-functions-providing-matrix-multiplication/60621)

<div class="topic-metadata">

**Author:** [@llaisdy](https://forum.elixirforum.com/u/llaisdy)\
**Replies:** 2\
**Last updated:** [December 28, 2023, 7:47pm UTC](https://forum.elixirforum.com/t/any-functions-providing-matrix-multiplication/60621 "2023-12-28T19:47:27Z")

</div>

Dear All I would like to do matrix multiplication in elixir. I haven’t found a library that does this. Nx.multiply/2 and Matrex.multiply/2 do element-wise multiplication of two tensors. I wrote this naive version tha…

---

## [Similarity - A Library for easy cosine similarity calculation](https://forum.elixirforum.com/t/similarity-a-library-for-easy-cosine-similarity-calculation/23228)

<div class="topic-metadata">

**Author:** [@preciz](https://forum.elixirforum.com/u/preciz)\
**Replies:** 8\
**Last updated:** [February 9, 2023, 5:36pm UTC](https://forum.elixirforum.com/t/similarity-a-library-for-easy-cosine-similarity-calculation/23228 "2023-02-09T17:36:05Z")

</div>

Sum: I have used in production the folllowing formula for cosine similarity calculation: (list\_a and list\_b are both the same length) cosine\_similarity(list\_a, list\_b) \* :math.sqrt(length(list\_a)) This is good becaus…

---

## [Intersection over union calculation](https://forum.elixirforum.com/t/intersection-over-union-calculation/53609)

<div class="topic-metadata">

**Author:** [@vshesh](https://forum.elixirforum.com/u/vshesh)\
**Replies:** 1\
**Last updated:** [February 2, 2023, 6:16am UTC](https://forum.elixirforum.com/t/intersection-over-union-calculation/53609 "2023-02-02T06:16:07Z")

</div>

Hi, I am trying to calculate the intersection over union for two oriented rectangles, like this picture; I know there are lots of algorithms for this so I am curious if anyone has seen an implementation. Rectangles a…

---

## [Schnorr signatures - anyone here willing to collaborate or create a lib?](https://forum.elixirforum.com/t/schnorr-signatures-anyone-here-willing-to-collaborate-or-create-a-lib/52641)

<div class="topic-metadata">

**Author:** [@RooSoft](https://forum.elixirforum.com/u/RooSoft)\
**Replies:** 18\
**Last updated:** [January 17, 2023, 3:18am UTC](https://forum.elixirforum.com/t/schnorr-signatures-anyone-here-willing-to-collaborate-or-create-a-lib/52641 "2023-01-17T03:18:37Z")

</div>

Been tinkering with nostr lately. It’s a new open protocol being built in the wild. It has a possibility to disrupt centralized social networks such as Twitter. It’s been recently funded by Jack Dorsey, which is the Twit…

---

## [Math problem. How to code \`Xn+1 = Xn + Xn \* S\`](https://forum.elixirforum.com/t/math-problem-how-to-code-xn-1-xn-xn-s/48421)

<div class="topic-metadata">

**Author:** [@KristerV](https://forum.elixirforum.com/u/KristerV)\
**Replies:** 9\
**Last updated:** [June 17, 2022, 8:59pm UTC](https://forum.elixirforum.com/t/math-problem-how-to-code-xn-1-xn-xn-s/48421 "2022-06-17T20:59:48Z")

</div>

I’m trying to generate a list of numbers, where each number is a percentage smaller than the previous. Starting with 1. In the end I’ll need 10 (or whatever amount) of items from the end of it. The math formula I came u…

---

## [Hadamard product without using a library?](https://forum.elixirforum.com/t/hadamard-product-without-using-a-library/45951)

<div class="topic-metadata">

**Author:** [@Trevorton27](https://forum.elixirforum.com/u/Trevorton27)\
**Replies:** 10\
**Last updated:** [February 14, 2022, 7:11am UTC](https://forum.elixirforum.com/t/hadamard-product-without-using-a-library/45951 "2022-02-14T07:11:17Z")

</div>

Looking for a to code the Hadamard product without using a library. Still relatively new to Elixir so feeling a bit lost.

---

## [Math/Stats library Numeric ported to Matrex](https://forum.elixirforum.com/t/math-stats-library-numeric-ported-to-matrex/28162)

<div class="topic-metadata">

**Author:** [@elcritch](https://forum.elixirforum.com/u/elcritch)\
**Replies:** 3\
**Last updated:** [May 22, 2021, 4:47pm UTC](https://forum.elixirforum.com/t/math-stats-library-numeric-ported-to-matrex/28162 "2021-05-22T16:47:18Z")

</div>

MatrexNumerix - Numeric stats library ported to (fast) nif based matrix library Matrex for fast stats and data-science. I ported the Numerix math and statistics library to use the Matrex library. A couple of convenience…

---

## [Prime sieve explanation](https://forum.elixirforum.com/t/prime-sieve-explanation/39342)

<div class="topic-metadata">

**Author:** [@stevensonmt](https://forum.elixirforum.com/u/stevensonmt)\
**Replies:** 5\
**Last updated:** [May 2, 2021, 5:48pm UTC](https://forum.elixirforum.com/t/prime-sieve-explanation/39342 "2021-05-02T17:48:46Z")

</div>

I tried to modify an example from RosettaCode.org for a prime sieve algorithm. I’m not entirely sure I understood the original code. I tried to make sense of it with more explicit variable names but I was hoping someone …

---

## [Fibonacci with dynamic programming from imperative language need help](https://forum.elixirforum.com/t/fibonacci-with-dynamic-programming-from-imperative-language-need-help/36830)

<div class="topic-metadata">

**Author:** [@kensremit](https://forum.elixirforum.com/u/kensremit)\
**Replies:** 6\
**Last updated:** [January 16, 2021, 2:53pm UTC](https://forum.elixirforum.com/t/fibonacci-with-dynamic-programming-from-imperative-language-need-help/36830 "2021-01-16T14:53:37Z")

</div>

I know elixir is a functional programming language and this means can’t make a change state in some problems? Do I am missing something? Can use any techniques to replace for solution dynamic programming Fibonacci? This…

---

## [convert binary floating and doubles in IEEE-754 format.](https://forum.elixirforum.com/t/convert-binary-floating-and-doubles-in-ieee-754-format/36408)

<div class="topic-metadata">

**Author:** [@bwanab](https://forum.elixirforum.com/u/bwanab)\
**Replies:** 7\
**Last updated:** [December 24, 2020, 9:34pm UTC](https://forum.elixirforum.com/t/convert-binary-floating-and-doubles-in-ieee-754-format/36408 "2020-12-24T21:34:24Z")

</div>

Hi. I’m new to elixir, so this could be obvious. I’m reading and writing to a device that uses a binary line format. The format is fixed. It also has integer fields, but they are easy to interpret. Floats and doubles are…

---

## [Spline / Polinomial Interpolation Library?](https://forum.elixirforum.com/t/spline-polinomial-interpolation-library/30981)

<div class="topic-metadata">

**Author:** [@mudasobwa](https://forum.elixirforum.com/u/mudasobwa)\
**Replies:** 4\
**Last updated:** [April 26, 2020, 4:04pm UTC](https://forum.elixirforum.com/t/spline-polinomial-interpolation-library/30981 "2020-04-26T16:04:56Z")

</div>

I am struggled to find any Elixir package to perform spline (or at least polynomial) interpolation. My input is very simple and although I am fine to implement it on my own, I’d rather use (and maybe contribute to) some…

---

## [Numbers: A generic wrapper to use \*any\* custom Numeric type!](https://forum.elixirforum.com/t/numbers-a-generic-wrapper-to-use-any-custom-numeric-type/2846)

<div class="topic-metadata">

**Author:** [@Qqwy](https://forum.elixirforum.com/u/Qqwy)\
**Replies:** 11\
**Last updated:** [January 20, 2020, 8:15pm UTC](https://forum.elixirforum.com/t/numbers-a-generic-wrapper-to-use-any-custom-numeric-type/2846 "2020-01-20T20:15:33Z")

</div>

Hey, everyone! Today I started writing a small library to perform computations with Complex Numbers. (ComplexNum, it is still very much unfinished). While working on that, I realized that I did not only wanted to be abl…

---

## [Simple formula processing in Elixir](https://forum.elixirforum.com/t/simple-formula-processing-in-elixir/27991)

<div class="topic-metadata">

**Author:** [@sym\_num](https://forum.elixirforum.com/u/sym_num)\
**Replies:** 0\
**Last updated:** [January 4, 2020, 7:55am UTC](https://forum.elixirforum.com/t/simple-formula-processing-in-elixir/27991 "2020-01-04T07:55:48Z")

</div>

Happy new year. I started the project during my vacation. I remembered formula processing in SICP or PAIP. I enjoy writing elementary math in Elixir. I had almost forgotten math. It’s a good chance to remember math f…

---

## [Erlang: How to see a float in its actual bitwise representation?](https://forum.elixirforum.com/t/erlang-how-to-see-a-float-in-its-actual-bitwise-representation/27942)

<div class="topic-metadata">

**Author:** [@Qqwy](https://forum.elixirforum.com/u/Qqwy)\
**Replies:** 2\
**Last updated:** [January 2, 2020, 1:06pm UTC](https://forum.elixirforum.com/t/erlang-how-to-see-a-float-in-its-actual-bitwise-representation/27942 "2020-01-02T13:06:42Z")

</div>

This is a question about a rudimentary operation on the BEAM. That is why I’ve tagged it ‘Erlang’. Recently, an issue came up on the repository of Rational, the elixir library providing rational numbers, about how float…

---

## [Defining operations using protocols](https://forum.elixirforum.com/t/defining-operations-using-protocols/26150)

<div class="topic-metadata">

**Author:** [@snunezcr](https://forum.elixirforum.com/u/snunezcr)\
**Replies:** 5\
**Last updated:** [October 18, 2019, 4:26pm UTC](https://forum.elixirforum.com/t/defining-operations-using-protocols/26150 "2019-10-18T16:26:02Z")

</div>

I need to define a protocol for a scientific application based on quantities of various types. I want to use protocols since they abstract my code nicely. Is there a valid way to re-define math operators in protocols, e.…

---

## [Kalman Filter - implemented in Elixir](https://forum.elixirforum.com/t/kalman-filter-implemented-in-elixir/25558)

<div class="topic-metadata">

**Author:** [@smedegaard](https://forum.elixirforum.com/u/smedegaard)\
**Replies:** 0\
**Last updated:** [September 21, 2019, 6:28pm UTC](https://forum.elixirforum.com/t/kalman-filter-implemented-in-elixir/25558 "2019-09-21T18:28:01Z")

</div>

Kalman Filter The Kalman Filter is often used to filter data where you expect some noise. It does so by looking at the previous data point and how certain we are about that data point to decide how much the current measu…

---

## [Reverse an integer regardless of its sign](https://forum.elixirforum.com/t/reverse-an-integer-regardless-of-its-sign/22794)

<div class="topic-metadata">

**Author:** [@Andres](https://forum.elixirforum.com/u/Andres)\
**Replies:** 13\
**Last updated:** [May 30, 2019, 5:16pm UTC](https://forum.elixirforum.com/t/reverse-an-integer-regardless-of-its-sign/22794 "2019-05-30T17:16:31Z")

</div>

Hello. Trying to reverse an integer regardless of its sign I wrote the following algorithm: int = -123456789 #=\> Expected result -987654321 def minus\_one(int) do int \* -1 end def sign(int) when int \> 0 do int…

---

## [Most performant (and lazy) way to do an operation on 2 lists](https://forum.elixirforum.com/t/most-performant-and-lazy-way-to-do-an-operation-on-2-lists/21006)

<div class="topic-metadata">

**Author:** [@grufino](https://forum.elixirforum.com/u/grufino)\
**Replies:** 6\
**Last updated:** [March 21, 2019, 10:16pm UTC](https://forum.elixirforum.com/t/most-performant-and-lazy-way-to-do-an-operation-on-2-lists/21006 "2019-03-21T22:16:15Z")

</div>

Hello! I am building a quite robust pipeline of operations that performs basically math of all types on thousands (in the future may be millions) of rows. I would like to know what’s the most performant way to do somet…

---

## [Looking for an elixir library to do linear programming](https://forum.elixirforum.com/t/looking-for-an-elixir-library-to-do-linear-programming/14781)

<div class="topic-metadata">

**Author:** [@markschultz](https://forum.elixirforum.com/u/markschultz)\
**Replies:** 2\
**Last updated:** [June 20, 2018, 11:31pm UTC](https://forum.elixirforum.com/t/looking-for-an-elixir-library-to-do-linear-programming/14781 "2018-06-20T23:31:56Z")

</div>

Just as the title says, I’m looking for a library specifically for linear programming to work in a program producing schedules. wiki I’ve googled around for a few hours without luck. Is this something I’ll have to come …

---

## [How to convert 2000 to 20.00](https://forum.elixirforum.com/t/how-to-convert-2000-to-20-00/14538)

<div class="topic-metadata">

**Author:** [@wlminimal](https://forum.elixirforum.com/u/wlminimal)\
**Replies:** 7\
**Last updated:** [June 6, 2018, 11:30am UTC](https://forum.elixirforum.com/t/how-to-convert-2000-to-20-00/14538 "2018-06-06T11:30:20Z")

</div>

I want to change format 2000 to 20.00 I want to put period “.” at last two digit in number how can I do this?

---

## [Suitability of Elixir to math-oriented apps](https://forum.elixirforum.com/t/suitability-of-elixir-to-math-oriented-apps/1981)

<div class="topic-metadata">

**Author:** [@Donovan](https://forum.elixirforum.com/u/Donovan)\
**Replies:** 31\
**Last updated:** [June 2, 2018, 1:22pm UTC](https://forum.elixirforum.com/t/suitability-of-elixir-to-math-oriented-apps/1981 "2018-06-02T13:22:07Z")

</div>

Hello everyone, I’m so glad to have discovered this awesome community. Thanks for creating it! This is my second post, and apologies for any inadvertent breach of protocol by posting this (a variation of a prior reply t…

---

## [Evaluate math from string](https://forum.elixirforum.com/t/evaluate-math-from-string/13779)

<div class="topic-metadata">

**Author:** [@jeromedoyle](https://forum.elixirforum.com/u/jeromedoyle)\
**Replies:** 3\
**Last updated:** [April 25, 2018, 2:01am UTC](https://forum.elixirforum.com/t/evaluate-math-from-string/13779 "2018-04-25T02:01:31Z")

</div>

If I have the string “12 \* 12”, how can I evaluate the expression and return the resulting 144 as an integer. The string could ultimately be any valid math equation. I’m not concerned with validating the expression, just…

---

## [Tensor, the Vector/Matrix/Tensor library has reached v1.0!](https://forum.elixirforum.com/t/tensor-the-vector-matrix-tensor-library-has-reached-v1-0/2921)

<div class="topic-metadata">

**Author:** [@Qqwy](https://forum.elixirforum.com/u/Qqwy)\
**Replies:** 8\
**Last updated:** [January 2, 2017, 12:31am UTC](https://forum.elixirforum.com/t/tensor-the-vector-matrix-tensor-library-has-reached-v1-0/2921 "2017-01-02T00:31:37Z")

</div>

With the recent addition of Numbers and some improvements of the documentation, Tensor now has reached version 1.0.0! For people that do not yet know about it: Tensor is a library that allows you to work with sparse Vec…
