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
-1
votes
1answer
24 views

I am trying to solve a non-linear equation. In the matlab program, I'm stuck up.

One of the problems could be that, I want a matrix of order 33 but the output is 44, with first row and first column consisting of zeros. Can someone help ! n=5; m=5; T=1; for i=2:n-1 for q=2:m-1 ...
-1
votes
0answers
25 views

Statistical interpretation of entropy [closed]

I am making a program in wxmaxima ,it follows as shown below : ➡️how many coins are there? ➡️how many heads up? ➡️how many would you like to flip? ➡️how many times flipping? ➡️how many tosses per ...
1
vote
1answer
23 views

Is the operation $i = x + y * \text{width}$ reversible?

In game programming, there is this very common operation we do to index positions in a two-dimensional matrix over a one-dimensional array. We basically associate the value $a_{xy}$ of some matrix $A$ ...
0
votes
2answers
40 views

How to find the GCDs of LCMs of all pairs of elements in the given sequence.

You are given a sequence $A$ of positive numbers where the number will not be larger than $200,000$. A multiset is created from the given sequence such that: $S = \{LCM(a_{i}, a_{j}) \;|\; i < j\}$....
4
votes
1answer
29 views

converging average of loop?

I ran the following script, It starts with a random number, then takes it's reciprocal and gets it's fractional part, Then it repeats it again, and takes average. ...
1
vote
0answers
29 views

Generalization of walks into graphs

When we have a graph with cycles, a walk is like a kind of path possibly unfolding some cycles. A special case in programming would be something like an execution going through some loops a certain ...
0
votes
0answers
22 views

Strongly Dependent-type languages (running on windows)

What are the best dépendent-type programming languages to learn about type-theory ? I heard about coq, agda, epigram and idris; are there any other ? And most importantly: wich one of these can easily ...
0
votes
1answer
16 views

Determine whether the combination of two legged animals and 4 legged animals are present

there are X animals in total in the garden, and they have Y legs in total." Determine whether there is a combination of numbers of cranes and turtles in which this statement is correct. if ...
2
votes
1answer
63 views

Sampling from a distribution

In many cases we use sampling from a distribution. Also in programming languages they implement it. But I wonder now what is the process of generating a sample from a probability distribution? What ...
0
votes
2answers
28 views

Extension of a Signature

I came across the following rule about signature extension in Harper's 1993 classical paper on LF (see page 5, Figure 1). $$\frac{\Sigma:sig\quad\vdash_\Sigma A:Type\quad c\not\in dom(\Sigma)}{\Sigma,...
1
vote
2answers
88 views

what difference between propositions and `if` statement of program

Consider a proposition, $$\forall x\in\mathbb{R}~(x^2<0\implies x=23)\tag{1}$$ Due to vacuous truth, Obviously it's a true proposition, However I have confused by it when transform this proposition ...
-1
votes
0answers
10 views

How to use Gaussian interpolation?

So in a three-dimensional plane, I have 3 or more points at any given x, y or z and I want to draw a straight line between these, but the major problem I'm facing is that I want to have the option to ...
0
votes
0answers
6 views

Calculating process execution time for multiple processors in a distributed memory system

A question from introduction to parallel programming - S.Pacheco Suppose a program must execute $10^{12}$ instructions in order to solve a particular problem. Suppose further that a single processor ...
0
votes
0answers
9 views

Local maxima search of a multivariable function [Repost from stackoverflow]

I am looking for an algorithm to search for local maxima of a multivariable function (unknown derivative, sadly). History: For the past three years, I have been dealing with only 6-D surfaces and ...
0
votes
1answer
44 views

Best solution for $(A+B)\cdot X = C$

Suppose I am given a matrix $A_{1×3}$ and another matrix $C$. I have to find the best possible solution of the form $(A + B)\cdot X = C$. But the solution will be considered best only if $X_{3×3}$ is ...
0
votes
1answer
56 views

Percent success based on weapon level and creature rarity

I am working on a discord bot game and there is a hunting command. Two primary factors are applied to whether you were successful in the hunt or of the animal was scared and ran away: Weapon Level - ...
0
votes
0answers
15 views

Self adjusting numerical integration precision

I've written a program to numerically calculate the area under a curve for a given interval and want to be able to give a precision goal. Let $f: [a, b] \rightarrow \mathbb{R}$ with $a,b \in \mathbb{...
0
votes
1answer
57 views

3D & Trigonometry: Rotating a Cube [closed]

I am programming a 3D game in a 2D environment, and I am trying to make a 3D cube. I did that, and I am trying to rotate said cube, so I can see all the sides of it. I found this lesson on Khan ...
0
votes
0answers
25 views

Transformation Matrix Operations

Good morning, I'm doing a matrix exercise for college. I need to get a transformation matrix that allows me to multiply the vertices of a rectangle and get the correct position of them from the ...
-2
votes
1answer
26 views

Algorithm problem - Help

I have this algorithm problem, I was wondering if there is a method to solve it in a fast and simple way, using math theorems or something like that. This is the problem: Given a number d (integer in ...
1
vote
1answer
168 views

What is the side length of smallest square which can embed a regular polygon with 2*n sides, where n is odd and n≥3.

I am trying to solve problem. I have proved that the minimum side length should be greater than or equal to radius of the circum circle of given regular polygon(by contradiction). But I am not able ...
0
votes
1answer
62 views

Is it computationally/mathematically feasible to figure out formulas such as this?

So, I am trying to write a program that figures out the correct combination to unlock something in a game. This question is going to need a bit of mathematical knowledge also. Here are examples of ...
1
vote
0answers
20 views

Language and Algorithm to Take Derivatives in Function Notation

I want to algorithmically find derivatives and partial derivatives of expressions written in function notation. For example, I can type "d/dx f(x, y(x), g(x) * h(x))" directly into Wolfram Alpha, ...
0
votes
1answer
17 views

program to find All numbers y , less than a number x having the bits set at places only where they are set in x.

consider for example 118 its binary representation is 1110110. I want to have all numbers that have bits set at places only at places where it is set in 118 as follows: 114->1110010 112->1110000 102->...
2
votes
2answers
117 views

Remove some digits and re-order the digits (if necessary) so that the resulting integer would be the maximum possible integer that is divisible by 3.

Given an integer. The task is to remove some digits and re-order the digits (if necessary) so that the resulting integer would be the maximum possible integer that is divisible by 3. I am having some ...
0
votes
0answers
29 views

Recurrence Relation : f(n) = f(1) + f(2) + f(3) + … + f(sqrt(n))

Recently I was solving a question and wondered what would be the time complexity. The function is as follows: ...
-1
votes
1answer
91 views

Max value of bitwise AND over a given range [closed]

Given a number X and integer N, give the max value for (X&i) 0<=i<=N. Example: X = 103, N = 50 ans = 44
0
votes
1answer
28 views

If the “string” $A \to B$ usually means the type of functions from $A$ to $B$ then what should the string $A\to ?$ mean?

Was thinking of a programming languages in which every string is a valid program. What is the type of the string A->? or ...
0
votes
0answers
12 views

Counting the operators execution

x=1 For i = 1 to n ( For j = 1 to i ( x = x + f(x) ) x = x * g(x) ) Determine each of the following as a function of n: (a) The number of times ...
0
votes
0answers
21 views

How to view programming dictionary as a function?

In programming class, We are given two sets $E$, $R$. We are given a subset $\zeta \subset E \times R \times E$. Then we have a method getErDic that takes takes ...
1
vote
0answers
48 views

using Vedic Mathematics to do Multiplcation operation in Computer coding

Question It is now known that the process of Multiplication is the most resource-intensive computing operation, especially of two large numbers. That's why the trivial way of writing factorial code ...
2
votes
1answer
65 views

Random number generation and collision check

I was working on a random number generator in NodeJS, I use Math.random() which gives a random number between 0 and 1. I can get a whole number between ...
0
votes
0answers
16 views

How does a TDI System change if you add non-negativity constraints

I know that if the system $Ax \leq b$ is TDI the TDI property does not change if you add redundant inequalities. My question is how does a TDI system change if you add non-negativity constraints, i.e. ...
1
vote
0answers
27 views

Find all bases such that $P$ in those bases ends with the decimal representation of $Q$

Given two numbers $P$ and $Q$ in decimal. Find all bases such that $P$ in those bases ends with the decimal representation of $Q$. I was going to write a code for this problem. The idea in my mind ...
6
votes
2answers
90 views

Doubling Point Formula of Elliptic Curve is Not Working

Let $E$ be an elliptic curve and a point $P = (x, y) \in E,$ from the duplication formula, the x-coordinate of $2P$ is - $$x_{(2P)}=(x^4-b_4*x^2-2*b_6*x-b_8)/(4*x^3+b_2*x^2+2*b_4*x+b_6)$$ The ...
0
votes
0answers
4 views

Latitude and longitude conversion formula

I am working on a program which has some logic that converts latitude and longitude values from one unit of measurement to another unit of measurement. The problem is that I just cant figure out what ...
2
votes
1answer
47 views

Why we can draw a random number $s$ in a normal distribution when we are taught that $p(s)=0$?

In various programming languages such as Matlab and Python, we can draw a random number s from virtually any continuous distribution, such as the normal and uniform. But we're also taught that $p(s)=...
1
vote
0answers
30 views

How can I estimate the required number of iterations of Gauss-Legendre algorithm?

I have the following datastructure in Haskell for computable numbers $\mathbb{M}$: data Computable = Exact Rational | Inexact (Word -> Integer) ...
1
vote
0answers
30 views

What is the biggest field extension of rational numbers with known equality comparison algorithm?

I have the following data structure in Haskell to represent computable real numbers $\mathbb{M}$: data Computable = Exact Rational | Inexact (Word -> Integer) ...
0
votes
1answer
17 views

How to prove that a nested composition of graphs is a graph?

Sorry if this is naive or really obvious, but it's not obvious to me. I'm trying to see how to apply proof techniques to software modeling. Basically, there is Graph Theory which has the definition ...
0
votes
1answer
19 views

Is there a place which has the functional (programming) definition of Numbers in various forms?

I am familiar with the Peano Natural Number definition which is what you see in intro to functional programming courses and examples. But I have also much later encountered a practical implementation ...
0
votes
0answers
54 views

Improving Excel's solver speed for differential equations

I have an Excel spreadsheet that contains a linear differential 5 DOF vehicle dynamics model. I use the built-in solver in a loop to numerically solve the equations. I used it qualitatively for a ...
4
votes
2answers
95 views

Find the average of a function defined on a Fat Cantor Set

Suppose we have $P:A\to[0,1]$, where $A$ is the fat cantor set denoted as $C$. We produce $C$ by removing $1/4$ of $[0,1]$ around mid-point $1/2$ $$C_{1}=[0,3/8]\cup [5/8,1]$$ $$C_{1,1}=[0,3/8] \ \ ...
0
votes
0answers
21 views

Finding the dual problem with exponential equation

I need to find the dual problem of this: but I have no idea how to work with the norm or the exponential function
0
votes
0answers
13 views

Binary polynomial convolution-like or-ing

I have two binary polynomials. For example $a(t)$, $b(t)$. I would like an algorithm which calculates the binary polynomial $c(t)$ such that, $$c_n = \sum_{i=0}^{n} (a_i * b_{(n-i)} ) \, > 0. $$ ...
1
vote
1answer
98 views

Program correctness in Discrete math

Given a nonzero integer a and $b∈\Bbb N$, we want to compute $a^b$. Consider the following recursive algorithm $\operatorname{POW}(a,b)$. If $b=0$, return $1$ Otherwise, if b is odd, return $a\cdot(...
2
votes
1answer
88 views

What is the function of lift(Q) in PARI/GP?

I would like to call PARI/GP from Python. I need to use ellisdivisible(E; P; n;{&Q}) function of PARI (see function no 3.15.35 on page 441 in this link:) ...
1
vote
1answer
38 views

Implementing Jacobi and Gauss-Seidel Method

I am implementing the Jacobi Method and the Gauss-Seidel Method in the C programming language right now. I successfully implemented the Jacobi Method and am getting the correct results for each ...
0
votes
2answers
27 views

How to solve linear recurrence relation based on conditions?

Given $F(n)=a\cdot F(n-1)-b$ ,$n$ even $F(n)=a\cdot F(n-1)+b$ ,$n$ odd $F(0),a,b$ are constants. How to calculate $n$-th term in $log(n)$ time? I learnt matrix exponentiation technique. But ...
0
votes
1answer
20 views

What are currently known methods of logic formula synthesis?

Suppose our goal is to produce logic function, which transforms input binary data (some input variable assignments) into one output (true or false). The only information that is known is dataset of ...

1
2 3 4 5
8