Questions tagged [programming]

For mathematical questions related to programming, and questions where a computer-aided solution is strongly suggested. A strong connection with a mathematical topic is needed to make programming questions on-topic. This should not be the only tag. Consider also using the tags (algorithms), (numerical-methods), or (linear-programming).

Filter by
Sorted by
Tagged with
0 votes
0 answers
26 views

Create an algorithm to find powers using only addition and one factorial.

Why there is this kind of relation between power and factorial? I know that there is a way to use this pattern to generate powers using just addition and one factorial, but I can't wrap my puny brain ...
P R Das's user avatar
  • 28
2 votes
1 answer
57 views

How to find the time of a sine wave based on the y position?

I'm trying to find an equation that allows me to find the time of x of the sine wave based on the y position. For example: The y position of 0.25 on the sine wave should equal to 0.0804 in x time y0....
SamYazo's user avatar
  • 31
0 votes
1 answer
69 views

Kuhn-Tucker conditions for inequality constraints

So, when we solve the optimization problem using Lagrange Multiplier method, I know that lambda can be positive or negative. Lambda is simply the rate of change in the optimal value when the ...
Confused_intense_thoughts's user avatar
4 votes
0 answers
95 views

How to calculate $N! \mod P$ fast?

Given numbers $N$ and $P$. Calculate $\:N! \mod P$. $N$ and $P$ are very large so that I can't calculate it by using Fermat's little theorem directly. But $|N - P|$ is small($\le 1000$) so I can solve ...
echocat's user avatar
  • 41
1 vote
0 answers
17 views

Are there any theorems that can be used to judge if an all-integer programming problem has a feasible solution?

Are there any theorems that can be used to judge if an all-integer programming problem has a feasible solution? I am NOT asking if we have any computational solvers that can be used to find a feasible ...
Shujun Tan's user avatar
2 votes
1 answer
32 views

Constructing complete lattices from total functions to posets

So I ran into this statement that says that the lowest upper bound of a set Y in L, a function space built like L = {f : S → L1 | f is a total function} is somehow related to the joins of the f(s)'s ...
Attila Szász's user avatar
0 votes
1 answer
82 views

Calculating the exact square root of a complex number with rational components [duplicate]

Given a complex number with rational components, I want to check if its square root also has rational components, and if so calculate the value. For example, given $-\frac{119}{225}+\frac{8}{15}i$ I ...
Elektito's user avatar
  • 109
0 votes
1 answer
27 views

how to express solution only in terms of some variables in sympy.solve?

How to express this solution in terms of r, g, and phi? ...
1.4142's user avatar
  • 73
0 votes
0 answers
18 views

How to reverse differing of natural log in R? my attempts are not working

Simple inverse differencing is easy however, after differencing the natural log I cannot get the original data back. For instance, my data is in a timeseries: ...
billysballo's user avatar
1 vote
1 answer
23 views

Schedule recurrent tasks to match a desired frequency?

I'm trying to write a small task scheduling function that takes a list of tasks, each with an assigned priority. These tasks are meant to update some values in a database, and some need to run more ...
Juan's user avatar
  • 961
0 votes
0 answers
37 views

Calculating $ \sum_{k=1}^n \lfloor k * \sqrt 2\rfloor $ [duplicate]

This is a programming question I've come across recently and it requires me to find this sum as quickly as possible since n can become very large (up to 10100 ...
rev's user avatar
  • 13
0 votes
1 answer
42 views

Why are such two methods functionally equivalent from a mathematical perspective?

To program a function that tests whether all elements in an array are greater than 5, the straightforward way will be: ...
xmh0511's user avatar
  • 155
1 vote
1 answer
64 views

Numerical integration improves when step size is smaller, but in which direction?

I am implementing a double integration of a function; numerically in Matlab. What I basically do is: ...
Neelabh Jyoti Saharia's user avatar
0 votes
1 answer
23 views

Modular square root function with Hensel's Stronger Lemma; algorithm for $\bmod 2^x$? Also $x^2 = a\pmod{p^n}$ when $\gcd(a,p) \neq $1

I'm programming a solution to HackerRank's Project Euler 100, which is a much stronger variant than the original question, so I have to essentially make a quadratic solver, which involves a lot of ...
Andy Zou's user avatar
0 votes
0 answers
23 views

How to derive the formulas of the spin-weighted spheroidal eigenvalues (2.16a)-(2.16g) in arXiv:gr-qc/0511111?

I am reading the article "Eigenvalues and eigenfunctions of spin-weighted spheroidal harmonics in four and higher dimensions", which is on https://arxiv.org/abs/gr-qc/0511111. I want to ...
amon xu's user avatar
1 vote
0 answers
27 views

Effective algorithms for finite lattices of (higher-order) monotonous functions?

I am looking for references on effective algorithms on finite lattices or posets, and in particular on lattices of monotonous functions between two lattices, with higher-order structure -- monotonous ...
gasche's user avatar
  • 111
1 vote
0 answers
57 views

Is there an algorithm for finding every isolated singular point on an algebraic variety, or a programming language that implements this?

Suppose one wishes to test if a given algebraic surface f(x,y,z,w) = 0 in projective 3 space has singular points, that is df/dx = df/dy = df/dz = 0, and one also wishes to calculate these singular ...
drfpslegend's user avatar
1 vote
1 answer
113 views

Is it possible for integer division in C++ to express a compact mathematical condition, as for Euclidean division?

I am studying integer division in C++. At the same time, I read the wikipedia article 'Euclidean division'. In this article there is such a lemma: ...
Ilya Chalov's user avatar
0 votes
1 answer
46 views

Calculate position of bouncing ball based on arbitrary time value

Usually, when you make a bouncing ball in any programming language, you have an X and Y value that updates over time, as well as an x velocity and y velocity, whose signs flip when the ball hits the ...
Archonic's user avatar
1 vote
0 answers
26 views

How to generate tangles?

In my research I need to generate tangle diagrams for with small number of crossings ($\leqslant 10$). By tangle I mean 2-tangle, that is an embedding of two arcs into a ball where endpoints of arcs ...
Turtle5's user avatar
  • 205
0 votes
0 answers
26 views

How do I rotate an image onto any arbitrary plane

Given two references points $p_{1i}$ and $p_{2i}$ that lie on plane with normal $n_i = (0,1,0)$ and their corresponding points $p_{1f}$ and $p_{2f}$ on plane with normal $n_f$, how do I find the ...
pog pogtik's user avatar
1 vote
1 answer
39 views

How does this code implement the gauss-siedel method?

I have been trying to port and understand the code used in the paper Real-Time Fluid Dynamics for Games. One function in the paper, the method to diffuse one of the vector fields is said to use the ...
Arin Bryan's user avatar
6 votes
1 answer
448 views

Taxi distance count to all lattice points at specified distance from the lattice origin and of a specified dimensionality?

Setup of the problem Description of the lattice The problem is stated on a non-negative integer ($ℤ_{\ge 0}$) lattice. The specification of distance is also a non-negative integer ($ℤ_{\ge 0}$). ...
user avatar
0 votes
0 answers
20 views

Modelling particle diffusion in a scalar potential field

I'm currently trying to write a program that models 1D particle diffusion in a potential field. The model itself consists of a 1D array of equally spaced cells where each cell has a (time-varying) ...
Tom's user avatar
  • 180
5 votes
4 answers
1k views

Does the set of all programs form a group that acts on machine state (essentially, i.e. with a few exceptions)?

Since the only thing a computer can do is modify its machine state, and you can always change from one state into another state (there exists such a program) and so each program is invertible; and if ...
MathCrackExchange's user avatar
0 votes
0 answers
39 views

Why modular exponentiations of random, coprime numbers equals to 1/3?

Why is the average of modular exponentiations of random, coprime numbers equal to 1/3 on average? A similar question for N random (not coprime) numbers, but 'Why ... equal to 1/2 on average'? C++ code ...
Ecleytt's user avatar
  • 11
0 votes
0 answers
49 views

Uniqueness of negative and positive digit representation of integers

The question is regarding to the python code for following problem. We consider two type of digits, negative and positive to represent integers in given base. We are presenting theorem (self made), ...
Pruthviraj's user avatar
  • 2,649
1 vote
0 answers
44 views

Optimization problem that is convex and bounded is said to be unbounded in implementation

I have an optimization problem that is convex and bounded: \begin{align*} \text{Minimize}_{\text{wrt} B_{\text{opt}}}\qquad &\frac{1}{2p\sigma^2}\|Y_{\text{opt}}-X_{\text{opt}}B_{\text{opt}}\|_2^2-...
Resu's user avatar
  • 694
0 votes
1 answer
44 views

Faster primality testing? [closed]

I have to make a list of primes, and I found out that all primes are of the form 6n+1 or 6n+5 (however not all numbers of this form are prime). Thus, I use it to find primes more quickly as such: <...
Mathematically Clueless's user avatar
0 votes
0 answers
32 views

How to render .obj files in a non-euclidean way?

Apologies in advance if this question is misguided or foolish; I'm learning. My goal is to write a non-euclidean renderer in the Rust programming language, and I'm wondering if anyone could tell me if ...
Kai's user avatar
  • 109
0 votes
0 answers
34 views

Where do I get started with rendering curved space?

I want to program interactive renderings of spaces of arbitrary curvature (such as spherical or hyperbolic), though I have no idea how to begin. For instance, I have no idea whether I should use ...
Kai's user avatar
  • 109
2 votes
1 answer
69 views

Coding theory graduate text and programming

I begin a PhD in coding theory next fall, and it concerns coding over certain types of rings (e.g. finite chain rings) instead of fields, and in consequence submodule codes. I have a fair amount of ...
JBuck's user avatar
  • 569
0 votes
0 answers
41 views

What is the best way to manipulate probability expressions in code?

Suppose I want to write code to derive formulas using basic algebra and rules of probability theory (general multiplication rule, inclusion-exclusion, law of total probability, conversion to odds/...
user10478's user avatar
  • 1,652
0 votes
0 answers
47 views

Signed distance functions to arbitrary implicit surfaces

I am working on something called a raymarcher. It's a type of 3D engine, and a rather peculiar one; it uses a signed distance function to describe a scene, which is surprisingly enough info to ...
zenzicubic's user avatar
1 vote
1 answer
56 views

How to convert a point on a tilted 3D plane to a point on a 2D plane?

I have an infinite plane in 3D that I only know the normal vector of. I also have a point, somewhere on this plane. Based on the normal of the plane, its center point and the coordinates of the point, ...
GoogleCoder's user avatar
1 vote
1 answer
17 views

Intersecting two graphs of modulo functions with fractional coefficients

I'm currently working on something for audio programming and in order to avoid a long post i will boil the problem down to a mathematical one. I have one function of the form: ...
MaxOuwe's user avatar
  • 11
2 votes
1 answer
67 views

Ray-cone and ray-cylinder intersections

I am writing a simple raytracer, and I want to be able to raytrace capped vertical cone and cylinder primitives. I need to be able to find intersection points and normals for use in lighting and ...
zenzicubic's user avatar
0 votes
0 answers
23 views

Can the resolution algorithm be applied to any FOL formula?

I have been searching for an automatic method (a computer program) to evaluate any first-order logic (FOL) formula given some knowledge base. The most common approach to do this is to use PROLOG. The ...
Aeryan's user avatar
  • 61
0 votes
1 answer
74 views

my function is skipping

I wrote a function in C code that calculates a polynomial value from a given array arr[] of arrsize size, where the elements are ...
S. M's user avatar
  • 13
2 votes
0 answers
21 views

Algorithm for computing the collection of all string homomorphisms $f$ such that $f(s) = t$ for fixed strings $s,t$

I'm coding on a website in Django so all my code will be implemetned in Python. Anyway, I'm interested in the most efficient algorithm to compute the following problem. Given input strings $s = ...
Dev Joshi's user avatar
0 votes
0 answers
31 views

System of matrix equations in python

I want to solve a system of matrix equations $$A_1X = XB_1,$$ $$A_2X = XB_2,$$ $$A_3X = XB_3.$$ Here $A_i$, $B_i$ and $X$ are matrices $3 \times 3$ ($A_i$ and $B_i$ are known). How can I solve it ...
David Siukaev's user avatar
1 vote
1 answer
72 views

Software Tools that allow you to do symbolic Ricci Calculus / Tensor Notation?

Here are some examples of problems that I want to be able to solve for symbolically: Let $R = \sqrt{x_k x_k}$. Calculate $\displaystyle{\partial R \over \partial x_i}$ and $\displaystyle{\partial^2 R ...
Nate's user avatar
  • 545
0 votes
0 answers
33 views

Given a 3D camera and a horizontal plane both at the origin, how can I determine the pitch of the camera to view the plane N units below the horizon?

Given a 480px x 480px screen, and a 3D camera at the origin, with a horizontal plane on the X-Z axis that cuts through it (seen as a horizontal line through the center of the screen), how can I ...
vectorttoverflow's user avatar
1 vote
0 answers
56 views

Cubic polynomials over finite fields

I was watching an introduction video on "Tangent conics and tangent quadrics" by Prof. Norbert Wildberger , where the following Taylor polynomial was introduced: $$p_r(x) = (a+br+cr^2 + dr^3)...
Imago's user avatar
  • 2,122
2 votes
1 answer
67 views

Is it fair to say that Martin Löf Type Theory is doing the same for maths as what type theory did for programming languages?

Let me clarify what I mean. I am currently writing a dissertation on ML/Homotopy type theory as someone who is more of a theoretical computer scientist than an Algebraist. My dissertation is focused ...
Dmitriy Filippov's user avatar
1 vote
1 answer
125 views

Oscillations in Newton's fractal

I'm working on a program that draws Newton's fractal for a given polynomial. Newton's fractal is a fractal derived from Newton's root-finding method, which given some initial guess $x_0$ and function $...
zenzicubic's user avatar
0 votes
0 answers
21 views

Special Case - How to generate a formula to calculate where next additional items in a set of items, in a particular row and at a particular index

I've tried to generate a simple formula to do this calculation but I've not successfully arrived at a working formula. Here, I have a list of items displayed in a grid. Let's use these symbols ...
Henry Obiaraije's user avatar
-4 votes
1 answer
86 views

Groups, Algorithms and Programming (GAP 4) lack of functions

I am a newbie in using of GAP. To learn it I downloaded a book "Groups, Algorithms and Programming" (subtitle GAP 3.4.4 of 20 Dec. 1995, gap3-jm of 19 Feb. 2018) and also Reference Manual of ...
eug100's user avatar
  • 39
0 votes
0 answers
49 views

Irreducible representation over finite field GAP

I have a finite group $G$ with $p\not \mid |G|$ and I want to compute an explicit modular representation of $G$ given a character $\chi$. I can compute a representation by ...
Acuo95's user avatar
  • 545
0 votes
0 answers
34 views

Precedence Function Call vs Power

I am currently programming a terminal calculator, and have come across an interesting problem with the precedence of function calls. How should this be evaluated: ...
RcCookie's user avatar

1
2 3 4 5
14