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
0answers
42 views

Is there a word to represent the Domain and the Range of a function?

Is there a word that represents both the domain and the range of a function? I am looking for a good variable name for a program we are creating and we need a word that encompasses both of these ...
2
votes
1answer
50 views

Algorithm that finds all the recurring substrings in a string [closed]

I need to find all the recurring substrings in a string without considering the "overlapping" recurring substrings. For example if I have ABCDABCDACCACCACCABDC, here the recurring substrings ...
1
vote
2answers
53 views

How to create variations of a function that have the same start/end point?

I need to create some fake data that sort of conforms to the slow start, randomness in the middle, then a slow finish. I've screwed around with a graphing calculator and normalized this simple ...
3
votes
1answer
51 views

Why does consecutive averaging not lead to a good solution to a linear system?

I have been working on a program which requires me to get a solution for a huge system of linear equations (3,132 variables and 3030 equations). I was having trouble finding a previous implementation ...
1
vote
2answers
40 views

Slope of the bisector given 3 points

Diagram: You have 3 points: A, B, C and there are 2 lines: AB and AC that form an angle in the triangle. Then the bisector line of those 2 lines goes through A. I want the slope of that bisector. I ...
0
votes
0answers
23 views

How to define the shapes and orientations of orbitals mathematically in a cartesian coordinate system?

I am not able to match the $d$ and $f$ orbitals in atomic structure worksheet given as homework in Science (see the attached image). I was able to match the $p_{x}$ , $p_{y}$ , and $p_{z}$ orbitals. ...
-2
votes
1answer
40 views

How to find all the lines which passes through n number of bars.

This is a geometry question, a generalized form of another problem i am trying to solve. The data sets given are as follows Every bar on Y axis has a two coordinates given (starting and ending) the ...
0
votes
0answers
24 views

Stuck solving a minimum problem

I was doing some studying to improve my chances for an upcoming programming test, and I came across this problem. Trying to understand this leaves me quite confused about the correct answer and ...
1
vote
1answer
73 views

GAP on Jupyter Notebook

I wanted to learn GAP as it is certain that it will be helpful in the future for my research. I wanted to try GAP in Jupyter notebook in GitHub. I have tried following the step i.e. launch binder and ...
0
votes
0answers
16 views

Estimate optimal parameters in multidimensional model

Suppose we have a model which predicts a set of variables $\vec{Y} \in \mathbb{R}^n$ depending on some input model parameters $\vec{x} \in \mathbb{R}^m$, i.e. we have a mapping from $\mathbb{R}^m \...
0
votes
0answers
10 views

Is it possible to create connected and undirected simple graph without labels in MATLAB?

I created a program in MATLAB that automatically assigns values to adjacent matrices. But graphs are labeled graphs, so as the number of vertices increases, the amount of graph and the computation ...
1
vote
1answer
42 views

Given positive definite $X$, how to generate Hermitian $H$ such that $X\geq H\geq -X$

For simulation purpose I need to generate $n\times n$ Hermitian matrix $H$ many times. However, all $H$ must satisfy the following inequalities: $$X\geq H\geq-X,$$ where $X$ is known $n\times n$ ...
0
votes
1answer
22 views

Given a NxN grid and an integer calculate the row and column [closed]

I know this is most likely elementary school math, but I am having hard time finding a good algorithm. Given a NxN grid and a number which represents the nth tile counting left to right like a ...
2
votes
0answers
27 views

How to chose parameters for implementing a root bound in code

I am trying to implement Fujiwara's bound for the roots of a complex polynomial in Python. It states that the maximum absolute value of the roots of a polynomial $f(z) = a_n z^n + \cdots + a_0$ is no ...
0
votes
1answer
13 views

Linear programming formulation question

This problem is driving me mad, it's supposed to be really simple but I hate word problems such as this. I have the answer and can formulate other problems fine but for the life of me can't figure ...
1
vote
0answers
26 views

How to turn the behaviour of a pythonic function into a proper formal notation

Coming from a python function I would like to describe a certain behavior in a more formal and general way: Suppose I have a set of $n$ data points $X = \lbrace x_{1}, ..., x_{n} \rbrace$ where each ...
0
votes
0answers
36 views

Saving FORTRAN code listings in FORTRAN-compatible formats

Suppose I have an online book or paper containing some whiz-bang FORTRAN code listings. In MS/WINDOWS I can use ctrl-a to grab that text. Now I want to save that text in a form that is compatible with ...
0
votes
0answers
20 views

Minimum cost required to cover a line with line segments.

We are given a line segment $[1, n]$ with $m$ smaller line segments $[l_{i}, r_{i}]$. An example being $[1, 4]$ and line segments ${[1,2], [2,3], [3,4]}$. We can cover this using first and third ...
0
votes
1answer
18 views

Does the magnitude of $2$ line need to be the same to use Dot product?

Was programming and was trying to find angle of $2$ point but got $0.0$ but I know that looks like a $45$ degree angle but when I even out the length of one of the lines then it works. I dont remember ...
1
vote
0answers
23 views

Explaining vector projection in layman terms

I've been working on a project that includes the need to project vectors as outlined here: https://gamedev.stackexchange.com/questions/90609/how-can-i-check-if-a-player-drawn-line-follows-a-path. One ...
1
vote
1answer
64 views

Conversion from epoch time to (dd/mm/yyyy) date format

The title pretty much explains my problem. I´m given the number of seconds that have passed since the 1st of January 1970 and I have to return today´s date in (dd/mm/yyyy) format. I know how to ...
0
votes
1answer
35 views

Convex optimization problem with similarity constraint between variables

Let $x_i,y_i\in\mathbb{R}$, $a_i\in[0,1]$, with $y_1>y_2$ and $y_3>y_4$. We also have $(y_1-y_3)^2 + (y_2 -y_4)^2 <\varepsilon $. I need to solve the following constrained optimization ...
1
vote
0answers
20 views

How to determine the variable in a integral function for linear fitting

I want to apply my data to the equation $$ \frac{D_t-D_0}{D_m-D_t} = V_0 \int \exp\left(-\frac{E_a}{RT_\mathrm{mean}(t)}\right)\ \mathrm{d}t $$ and determine the $E_a$ for linear regression between ...
0
votes
0answers
18 views

Characterization of efficiency set in multicriteria optimization

Lately I have studied Multicriteria Programming. I have studied some properties of efficient optimal and nondominated point, weakly efficient solutions. Here is a problem I have met when I study. Let $...
0
votes
3answers
123 views

How helpful is learning Python to mathematicians? [closed]

How helpful is learning Python to mathematicians, may it be pure or applied mathematicians? I'm interested to pursue a career in mathematics. If I learn Python will it be helpful?
3
votes
1answer
168 views

How can I calculate $\rho_\alpha(z)$?

I am trying to design a group of complex functions $\rho_\alpha$ that have a type of symmetry that might look nice if it exists. This is what "symmetry" I want to try. $$\alpha=a+bi\space\...
0
votes
0answers
9 views

General pattern search optimization for 2 variables

First, I do not have any mathematics background and am self-teaching, but have come to a problem that I cannot quite solve. I am trying to optimize the following equation using generalized pattern ...
0
votes
1answer
25 views

How many times has the $S$ value changed during the program? If $n = 20$. Get the general formula $f(n)$ for calculating the number of operations [closed]

How many times has the $S$ value changed during the program? If $n = 20$. Get the general formula $f(n)$ for calculating the number of operations ...
1
vote
1answer
72 views

Algorithm for sampling items fails the tests

I was looking into a coding exercise which asks the following: Given an array of positive integers $w$ where each $w_i$ describes the weight of the $i^{th}$ element, implement an algorithm that ...
0
votes
0answers
29 views

Create tesselation of a hexagonal lattice (arm chair pattern)

I am creating a graph which consists of edges between nodes. I am given a function which inserts an edge between node1 and node2 insertEdge(node1, node2). The ...
3
votes
2answers
68 views

“[T]he assignment statement $X=X+1$ makes no sense […] in mathematics.” Why not?

Taken from Programming Languages and Principles, Chapter 1, by Tucker and Noonan: ... the assignment statement $X = X + 1$ makes no sense either in functional programming or in mathematics. Why does ...
0
votes
0answers
14 views

numerical integration - midpoint / trapezoidal / simpson's rule

I'm not sure if this is the right place to post this as it is a coding problem. Since it is part of my numerical analysis course however, I'll try it here. Let $I(f) = \int_{0}^{1} f(x) dx$. Code the ...
1
vote
1answer
34 views

How does this version of an equation of a line work: $E(x, y)=aX+bY+C$

I'm reading this article to understand hardware triangle rasterization, but I'm getting stuck in a particular part that defines line equations (that make up a triangle) as follows: Note that when we ...
1
vote
1answer
33 views

how many ways can you place items on this board

This is a programming (C#) and math related question. I have a 4x4 battleship grid which contains 3 ships. These 3 ships have the size's 3x1, 2x1, 1x1. I have to find out have many ship placements are ...
1
vote
0answers
84 views

Mathematica for computing number and diameter of closed curves in the Riemann Sphere

I am currently learning Python but I don't know (YET!) any language like Mathematica, Matlab, Maple, Octave and so on. I have a Math problem I would like to attack numerically and I need to know which ...
2
votes
0answers
51 views

Finding the coordinates of Fibonacci spiral, given a fixed distance between points

So I am doing this coding project for fun ; I have a set of $n$ particles of diameter $d$ scattered across the screen on the canvas. By clicking a button I want them to rearrange into a Fibonacci ...
-1
votes
1answer
35 views

Are there similar Mathematics behind moving a ternary to the inner function in programming languages and moving a $\lim$ inside a continuous function?

A common thing in programming, a good example being JavaScript, is using ternary if statements to assign values to a variable. For example: ...
0
votes
0answers
23 views

In a n-sided polygon with length of side L, can you find the distance between 2 vertices v1,v2?

Assume that you are asked to draw an equilateral n-gon. And you start always from (0,0) and you first draw a horizontal line to the right. Given the length and the number of sides of an equilateral n-...
2
votes
2answers
55 views

Differences in book definitions of $\beta$-reduction leading to confusion on when an abstraction needs to be $\alpha$-converted

I've been learning Lambda Calculus in my free time recently to try and learn how to make programming languages & interpreters. I am struggling a little bit with some inconsistencies on different ...
0
votes
0answers
27 views

Plotting a summation with 3 variables.

How would one convert the following into a graph (programmatically): $$ \sum_{n=0}^{\infty} \frac{\left(-x^{2}\right)^{n}}{n !^{2 s}} $$ ... given that only the n ...
-1
votes
2answers
96 views

How to for loop in Math like C? [closed]

In C, we can for loop easily. But I don't know how we can loop in Math like C. For example, I want to loop in Math like this C code: ...
0
votes
0answers
31 views

Roll four 6D. Ignore the largest result. Will the sum of the remaining results be less than 8?

I thought I could make an overview of possible outcomes when rolling four dice. So look at possible sums when rolling four dice, 4-24, and which combinations that give these sums. Then one can exclude ...
1
vote
0answers
30 views

Two points weighting formula

This has maybe an obvious answer, but I think I will ask it here since I don't have enough math to compensate for solving this problem. I'm creating recommendation systems and wants to assign weights ...
0
votes
2answers
32 views

Convert a range of integers to another range of integers while keeping an even distribution

I have a random integer x in the range [A, B] (inclusive). Is it always possible to convert x...
0
votes
0answers
29 views

Accept reject sampling for univariate pdf

I am working on generating near uniform samples from an arbitrary univariate truncated pdf (from $[x_1, x_2]$) using Python, the form of the unnormalized pdf is $\sqrt{P(x)}$, where P(x) is a ...
0
votes
0answers
22 views

Solving PDE and simulating in R

I'd like to simulate the following PDE in R, but I'm rather new to this topic and don't know how to do it or which package to use. The PDE is about a process $u_t(x)$ and originates from a diffusion ...
0
votes
1answer
26 views

How to deal with Statistical outliers in Rstudio

I have some outliers in a data set that I would like to deal with. After doing some reading into the topic I came to the conclusion that the trimmed mean function and the boxplot (in rstudio) function ...
1
vote
1answer
21 views

Parameterise a line represented by n points

I'm trying to write a program where I draw points at constant increments, regardless of how curvy a road is. For example, a straight line of length 10 and increment 2 would have 5 points spaced 2 ...
1
vote
1answer
41 views

Determinate perimeter and area of an n-angle in c++

Okay, so this is what the textbook says: "The user will input n points in $R^2$, the program needs to determine wether or not this is a n-angle polygon and if so calculate the area and perimeter ...
0
votes
1answer
41 views

Numerically solving a system of linear ODEs with different time conditions?

I am interested in solving the following system of ODEs numerically \begin{align} x'=2x+3y+z\\ y'=x-3y+2z\\ z'=x+2y-4z \end{align} with conditions at distinct times, even at time at infinity. \begin{...

1
2 3 4 5
11