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

717 questions
4
votes
2 answers

XOR(Exclusive OR) problem

Given 2 multisets A and B, |A| = |B|. The task is to find such X that A ^ X = B, where A ^ X means foreach element of A xor it with X; or say that theres no such X. |A| <= 10^5, elements of A, B are decimal number from [0; 10^18]. For example - If…
3
votes
1 answer

Is there some method to do mathematical deduction on computer instead of with pen?

Sorry if this question is not too fit into the website. I want to know if there're some methods that we can actually do mathematical deduction with formulae just on the computer instead of with pen and paper? I think latex is not a what you see is…
Sherlock
  • 211
2
votes
0 answers

Programming books for mathematicians

Are there any good intro to programming books for people with a strong backround in mathematics, but little experience in coding? In particular, are there any books that introduce the different features of the language through their use in solving…
Flumpo
  • 399
2
votes
1 answer

"Real Contour Integration": Code Followup

Adrian Keister had a wonderful answer to my question. In short, his answer allowed me to make a form of contour integration that picks up (some of the time) only real roots of a function $f(z)$. I started to code this in Python 3.x, but while I was…
2
votes
2 answers

There is a way to write this cases restriction within one line?

I want to write the following condition for $x\ge 0$ $$y=\begin{cases}y=x&\text{if }y>0\\y=a\neq0&\text{if }x=0\end{cases}$$ The reason is because I have a function on the form $F(x)=f(x)/x$ and I want it to be zero when $x=0$ but without using…
AlephZero
  • 750
1
vote
0 answers

How to make anything higher and lower to a base value equal to eachother.

So currently I am making a system for a game that works something like this. You have Value A/Turquoise, which is 1 You have Value B/Orange, which is 0.5 I first move Value A decimal point 2 times to the left, making Value A 100, I then divide value…
Xasthur
  • 11
1
vote
0 answers

Given a range of values (r, b), can I calculate a single number that, when subtracted, results in a consistant solution?

I'm working on some electronics calculations at the moment and I'm trying to calculate a value. I have some number of resistance values ($r$). There should be some value $W $where, when subtracted from $r$, the answer, $s$, should be relatively…
Vin
  • 155
1
vote
2 answers

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 function to start at 0 and end at 1. How would I go…
lewicki
  • 113
1
vote
0 answers

numerical ifelse

When I was studying machine learning, I came across the cost function for logistic regression written as: $ Cost(h_\theta(x), y) = -y\log(h_\theta(x)) - (1 - y)\log(1 - h_\theta(x)) $ As a rewrite of the piecewise version: $ Cost(h_\theta(x), y) =…
1
vote
1 answer

2D Plot Riemann Zeta-function

I want to plot the Riemann zeta-function as a 2 dimensional vector field. Where would be the fastest and easiest way to program this plot?
Daniel
  • 432
1
vote
1 answer

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 iteration, but currently I struggle with implementing…
1
vote
1 answer

Graphical representation of vectors in 4 dimensional space

I want to draw the 4-dimensional vectors. The vectors' restrictions are: all elements are more than 0. all vectors' sum of the all elements is the same. If 3-dim, we can draw them in an 2-dim equilateral triangle like this. figure It means that we…
Sato
  • 61
1
vote
1 answer

Line by two planes intersection

I've been wondering for a long time and I can't find, where is my fault. I write simple program to compute line of two planes intersection. function getIntersectOf2Planes ( $P1 , $P2 ) { /* Line equation in parametric form: x…
1
vote
2 answers

Why we commonly use i,j or n,m as indexes in math formulas?

What's the purpose (or the origin) of the use habit of i, j, k or for example n, m as indexes for math equations in general? Also this is carried into programing languajes. For example to do a simple for, we commonly use: for i in rows: for j in…
1
vote
1 answer

Mathematical notation of a while loop to convert two sets into one set using arithmetic based on second set being smaller than first

this is my first time posting on this forum so if this isn't acceptable, please let me know and i'll remove the post. I'm trying to convert the following Java code into a properly notated mathematical formula. However, my math skills themselves are…
1
2 3