Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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).

-2
votes
0answers
14 views

Feasible solution which is not basic

Min $p= 2x+3y+4z$ $x+y+z=2$ $x-y+z=0$ $x,y,z>=0$ here $x=1,y=0,z=1$ and $p=6$ is solution not basic?? Here is we added artificial variables A and B
-1
votes
0answers
20 views

Methods to draw fractals [on hold]

What are the known methods to generate fractals mathematically other than iterated function systems and how to use these methods for programming?
0
votes
0answers
51 views

Modulo Arithmetic hidden property (a mod n+ 1)

I was solving a programming question where we need to find compact form of a number and finding difficult to understand hidden modulo property behind it . I searched a lot but could not figure out. ...
-3
votes
1answer
42 views

Using RStudio to find the probability of who wins a soccer mach?

Team A on average scores 2.1 goals/match, Team B on average scores 1.6 goals/match. Using R simulate 1000 realisations of the match and estimate the probability of team A winning, team B winning and ...
7
votes
1answer
82 views

Matt Parker mistake in cannonball stacking video [closed]

I could need someone to do a check on this problem, since it has been published in Matt Parkers book "things to make and do in the fourth dimension" and has now been featured in a numberphile video ...
0
votes
0answers
10 views

Reflecting x-axis over a line of tangent of a function

I learned about linear transformations of vectors and shapes during the linear algebra class. Amongst all the transformations, I saw the reflections over x and y axis by multiplying certain matrices. ...
0
votes
2answers
29 views

How can I extract the value of a variable using simple algebra when the max function is involved?

I have a C program that does the following calculation: int b = 16; int a = max(1, ( (b + 3) / 4 ) ) * max(1, ( (b + 3) / 4 ) ) * 16; More easily read as: $$ ...
0
votes
1answer
28 views

Local optima is small than Global optima for min objective

I developed a MIP on LINGO. My objective is minimizing makespan (time). When I run it using the LP solver using a set of data, the objective value is 237. But when I run it using the global solver and ...
0
votes
1answer
26 views

Simplifying conditions correctly mathematically

All in all, i wanted to know if if it's possible to mathematically simplify 'if expressions' in code, by replacing every condition by a set. Here's an example : I have two 'if expressions', let's ...
0
votes
1answer
28 views

Prime number function with Haskel

Given a natural number $n> 0$, define a function IsPrime(n) that tells whether it is, or not, a prime number. I tried do two functions: ...
-2
votes
1answer
18 views

Prove that the partial order ((D * D), ⊆) is a complete partial order with bottom.

Let D be a non-empty set and (D-->D) be the set of all partial functions from D to D. Prove that the partial order ((D--> D), ⊆) (i.e., the set of partial functions ordered by set inclusion) is a ...
-1
votes
1answer
36 views

How to find the next number in a sequence whose square root is a whole number

I've just rephrased the question a bit. S(i=1 to n) is a set of n whole numbers where Square_Root(Si) is always a whole number. ...
1
vote
1answer
20 views

How do I reduce this lambda expression using Alpha, Beta and Eta reductions? [closed]

The expression is: (\h.(\a.(\f.f a)h)h) (\f.f f) Anyone willing to do it step by step would be greatly appreciated, thanks!
1
vote
1answer
87 views

Why do mathematicians generally write definitions in “declarative” rather than “imperative style?

In programming, we can make the distinction between declarative / functional and procedural / imperative programming. The distinction is not exact, but nevertheless meaningful. One major difference ...
0
votes
0answers
20 views

Do we need the Gödel numbers for enumerating programs in L or could we use the pairing function instead?

We have seen the trick of using the pairing function to associate numbers not only with pairs of numbers but also triplets. For example, here we create a bijection between z and triplets (a, b, c): z =...
-2
votes
1answer
27 views

Find permutation of N numbers which gives the sum of X [closed]

Assume n = 3 //A,B,C x = 6 How to find all permutaions of three numbers which makes to the total of 6. For example how to calculate how many permutations ...
1
vote
1answer
32 views

Finding similarities between binary strings

I have been tasked with this puzzle for my programming class, it's purely a puzzle and doesn't count towards any grades, but not being able to solve it is really bugging me! We have been given two ...
1
vote
1answer
41 views

Fast method to solve transcendental equation for a range of parameters?

I have an equation of the form $t + e^{Ax} + e^{Bx} = 0$ This is a transcendental equation, and I would use a Newton-Raphson algorithm or uniroot in ...
0
votes
0answers
9 views

Skewed Function for CS project instructions help.

Hello I'm working on a programming project and I'm just really confused with the instructions in this part. I don't need pseudo code or a solution, but I would like more explanation step by step with ...
0
votes
1answer
24 views

How to create a Quaternion rotation from a forward- and up- vector? [closed]

I need the rotation Quaternion of an object, I have it's foward and up directions (as 3D vectors), so I thought it would be easy to create a Quaternion rotation from that, but I can't seem to get it ...
1
vote
1answer
41 views

Cartesian Product over a list of objects in MAGMA

I'm currently trying to create the Cartesian Product of certain objects (namely: Character Tables of different finite groups). However, it seems like I don't really understand the car<$...$> ...
0
votes
0answers
17 views

How to fix banking-drift in 3d road/path-data

I'm working on something in Unity3D (the game engine) where I have to modify a path/road in 3d space. The path consists of a collection of points that each have a position (Vector3) and orientation (...
1
vote
1answer
44 views

How to rotate a path in 3D (computer sciences)

I'm working on something in Unity3D (the game engine) where I have to modify a path/road in 3d space. The path consists of a collection of positions and quaternion-orientations (the orientation ...
0
votes
1answer
34 views

linear programming set a variable the max of another

I'm new to programming and writing models. Most of the models I studied have straightforward objective functions and easy constraints that simple inequalities. I'm trying to write a constraint that ...
1
vote
0answers
34 views

How can I find the minimum index of the array in this case?

We are given an array $a$ with $n$ values. Example: $[1,4,5,6,6]$ For each index $i$ of the array $a$ ,we construct a new array $b$ such that, $b[i]= [a[i]/1] + [a[i+1]/2] + [a[i+2]/3] + \cdots + [...
0
votes
0answers
37 views

Mutually exclusive set weighted median formula

I have been asked to provide a median value for a set of ranked groups. The groups represent different grades in a university subject: fail, pass, credit, distinction and high distinction. The sets ...
0
votes
0answers
12 views

Finding the Period/Frequency from data without plotting it.

I'm in basic trigonometry and currently learning how to find equations having been given the data only. I understand the concept pretty well, but I usually make a program on a TI-84 for solving my ...
0
votes
0answers
16 views

Naive Bayes classifier & the probability distribution

I have posted this question to the programming stackoverflow as it is something I have came upon as a programmer but it's more a math problem. I'm using PHP module called TNT Search for text ...
3
votes
1answer
67 views

Calculating “hypotenuses” of acute triangles in a circular segment

I have a sector of a circle split into 16 equal segments. I am trying to calculate the "hypotenuses" of the triangles formed by 2 intersecting straight lines (for example, triangle $LEQ$), which sort ...
1
vote
1answer
29 views

How to compute acute triangles and their values from sections of a circle?

I am working with a sensor that outputs data in forms of radial beams. In order for it to be useful for my application I have to compute a value of one side of the acute triangles that can be seen in ...
0
votes
0answers
21 views

loop over a file keeping the number of calculations constant

I have the following task: I have a file with 1.6e6 lines (only one floating point number per line), that I need to perform some calculation between each element, ...
0
votes
1answer
39 views

Sidestepping Factorial Calculations?

Please forgive me if I ramble or use weird terms to try and describe what I’m after; I’m a programmer not a mathematician. The scenario: A large number of players, playing a real-time game in 3d ...
0
votes
0answers
40 views

Greatest Common Divisor - Programming Question

You are given a number $g$. Find a sequence $A$ of length $n$ which satisfies the following condition: $GCD ( A_0, A_1, A_2, .... ,A_i, ..... ,A_{n-1} ) = g.$ $A_i > g, \ 0 \le i < n.$ $A_i \...
0
votes
1answer
37 views

How do I calculate the number of pairs/quadruples in an array such that their sum is divisible by '3'?

How do I calculate the number of pairs/quadruples in an array such that their sum is divisible by '3' ? I know the brute force approach, I am looking for a much optimized solution :-) I have solved ...
0
votes
0answers
21 views

equal-if (jbob proof assistant)

I'm trying to read through The Little Prover and the book introduces a language, ACL2, a Common Lisp derivative, for talking about proofs about programming languages. The book introduces the ...
0
votes
0answers
11 views

How to create a convex polygon which is the superset of a given polygon?

I have a JTS_footprint like this, POLYGON ((46.542770 -65.500984,54.130459 -63.660416,59.213402 -66.664993,51.004562 -68.736069,46.542770 -65.500984)) How do I ...
0
votes
2answers
53 views

How to imitate a loop statement in math?

I need to iterate through expression several times and quit iteration process when certain value is reached but use algebraic notation. Summation notation would have worked if it didn't sum the ...
0
votes
1answer
46 views

Looking for row of an element in matrix

I have a $99$x$61$ matrix. The elements are indexed $1-6039$, vertically starting from the top left. So $X[1,1]$ is indexed $1$, $X[2,1]$ is indexed $2,...,X[1,2]$ is indexed $100,..., X[99,61]$ is ...
2
votes
1answer
86 views

Logic puzzle: find negation of three logic variables using exactly two negations and any number of conjunctions and disjunctions

We're given a programming environment in which it is possible to introduce new logical variables and issue logical commands with operations AND, OR and NOT, such as A = (X AND Y) OR Z. However, TRUE ...
1
vote
2answers
38 views

Calculate the number of strings of length n containing Xs and Ys, knowing that p adjacent Xs are not allowed

Suppose we have a string of length N, containing only Xs and Ys, (example of a string of length 5: XYXYX). How can we calculate the number of strings of length N that do not contain P consecutive Xs (...
0
votes
1answer
26 views

Encoding numbers from 0 to 255 using Huffman coding.

How can I encode numbers from 0 to 255 using Huffman coding (or any other code), so that each number (especially the largest numbers such as 255) wouldn't take 8 bits of binary space? In other words, ...
0
votes
1answer
53 views

How to calculate probabilities for the next colour to be out in Wheel of Fortune Casino Game.

Recently i've been very interested in how to parse data from html into my c program. I'm now considering to calculating the probabilities for the next colour to be out in the Wheel of Fortune. But ...
0
votes
1answer
30 views

Can modulize a multiplication of some numbers

Let's suppose we have this function: $f(n)= a^n b^{n-1} c^{n-2} \mod p$, where $a,b,c,p \in Z^*$ and $p$ is also a prime. I want to create software in C, Java, etc., that calculates the function ...
0
votes
0answers
22 views

Computing coefficients of the generating function counting trees with forbidden members

How can I compute the coefficients $r^{(n)}_p$ with a Python code using the following equations? \begin{equation}\label{10} r^{(n)}(x)= S^{(n)}(x)-\frac{1}{2}\left[ (S^{(n)}(x))^2-S^{(n)}(x^2)\right] ...
1
vote
1answer
47 views

Almost all trees are cospectral (Allen Schwenk's 1973 article)

I am currently working on the following article: https://www.researchgate.net/publication/245264768_Almost_all_trees_are_cospectral. There are a few things that I don't understand, and since the ...
0
votes
0answers
21 views

Modular degree in PARI/GP

For a given elliptic curve $E$ over $\mathbb{Q}$ I'm trying to find its modular degree using the math software PARI/GP. There exists a built-in function called ellmoddegree(E), but for some reason, ...
0
votes
0answers
26 views

Are there any proof assistants based on logic programming?

Logic programming is a programming language paradigm. In it, a programmer creates a bunch of axioms in the form of horn clauses, representing computations, which the implementation of the language ...
1
vote
0answers
40 views

Linear algebra in a programming project (Preferably C)

I would like to merge both so I can improve my understanding and test my knowledge. I have been looking for ideas but I found nothing but strange research papers. Of course I am not looking for ...
1
vote
0answers
32 views

Number of Smaller permutations

I'm practicing programming and I found following problem that I don't know how to solve: We have 2 sequences A and B that both have length N. We should find number of different ways to permute ...
0
votes
0answers
64 views

How can I solve this problem with the help of dynamic programming?

I am preparing for a national algorithmic competition and I have encountered this question, You are given a string that contains only lowercase English letters. In one step, you can choose an index ...