Questions tagged [math]
Math involves the manipulation of numbers within a program. For general math questions, please ask on math.stackexchange.com. Note: If your question is about unexpected results in floating point calculations, please read https://stackoverflow.com/questions/588004/is-floating-point-math-broken first.
44,370
questions
1
vote
1
answer
26
views
Calculating angle between 3 points in 3D give weird result
I want to calculate the angle between two segments in 3D space. The two segments are defined by AB and BC.
const pointA = [1, 1, 1];
const pointB = [0, 0, 0];
const pointC = [-1, 1, -1];
In 3D space, ...
2
votes
1
answer
35
views
2D smooth movement from scratch (javascript, pixelart)
My interest in game development led me to the idea of implementing the logic from scratch, without an engine.
Finally, I came to the point of optimizing the movement sequences of the background in an ...
0
votes
0
answers
20
views
How to link invoces and payments in several scenarios
I have a hard problem and I cannot fully solve it using PHP and/or Mysql.I have two arrays payments and invoices per user.
Some assumptions are:
Payment and invoice totals match, for each user
...
-6
votes
2
answers
83
views
math execution order in c [closed]
int a=17,b=3,r=1;
r = a - a / b * 4 % 3 + r;
in which order a C program will execute this:
A) / * % + - =
B) / * % - + =
Can you guys give me a solid explanation of the order in which a C program ...
-1
votes
1
answer
32
views
Create TimeLine field with PyQt5
I need to develop a program to enter time reports. What I do is very similar to time graphics.
I was only able to implement scaling, shuffling and pseudo-infinity fields. The main task is to somehow ...
2
votes
1
answer
33
views
What is the problem with my R code for solving and plotting a coupled system of ODE's?
I'm reasonably new to R and have this system of ODEs
\frac{dS}{dT} = -\beta(1-\mu)S(t)\frac{I(t))}{1-D(t))}
\frac{dI}{dT} = -\beta(1-\mu)S(t)\frac{I(t))}{1-D(t))}-\delta I(t))-\phi I(t))
\frac{dR}{dT}=...
-4
votes
0
answers
64
views
How to do the equivalent of floating point operations? [closed]
Im trying to make a Class which holds a .mantissa and .exponent
with these i can easily store numbers such as 1e1000 or even 1e(1e1000) (thats 1 with a 1e1000 zeros.)
the operations concerning these ...
1
vote
1
answer
83
views
Incorrect calculation of a math expression using sin and cos in C?
Why does this simple program
#include <stdio.h>
#include <math.h>
int main()
{
int res = (int)(-1 * sin(M_PI/2) + 1 * cos(M_PI/2));
printf("-1 * %f + 1 * %f = %d\n", sin(...
5
votes
3
answers
180
views
Multiplication of huge massive of numbers in python
I'm working on a small python program for myself and I need an algorithm for fast multiplication of a huge array with numbers (over 660 000 numbers, each is 9 digits). The result number is over 4 ...
0
votes
0
answers
54
views
Calculating and assigning Christoffel symbols to variables with python
I like to calculate the Christoffel symbols from a given line element and assign the expressions of each of Christoffel symbols to the variables in a user-defined function.
I am using the Python ...
-4
votes
0
answers
42
views
Hadamard Matrix Alternative Construction [closed]
I've been researching on this topic when I saw this construction in Wikipedia of the Hadamard Matrix:
Alternative Construction of Hadamard Matrixes
From the link: https://en.wikipedia.org/wiki/...
-3
votes
0
answers
29
views
How the expressions column can be aligned to left [closed]
[\begin{array}{|c|c|c|c|}\hline\text{ } & \text{ Polynomial}& \text{ }& \text{Type} \ \hline a &w^3 +15w^2 +9w+30& 3 & \text{Linear polynomial} \ \hline b & 13x^2 -30x+24 &...
1
vote
0
answers
19
views
How to check if a variable varies across timestamps or across samples
Let's assume we have some time-series data where every person (sample) has measurements for 2 variables (Var1, Var2) for three timepoints. Following is a dummy representation of the data.
Is there a ...
-3
votes
0
answers
56
views
Excel formula to compute a geometric series' ratio from initial element and sum of first N elements [closed]
I am dealing with a geometric series a[i]=ra[i-1], of which I know:
the initial element a[0], and
the sum of the first N elements a[0]+a[1]+a[2]+...+a[N-1].
I want to find the ratio between ...
2
votes
0
answers
53
views
Most efficient way of determining if a subgraph of a graph is connected
Suppose I have a graph given by a Laplacian matrix $L$ corresponding to a regular discretization of $[0,1]^2$, meaning nodes $I={(i,j),\quad i,j=1,\dots,n}$ are connected with $(i+1,j),(i,j+1),(i-1,j),...