diophantine

Finding all combinations of multiple variables summing to 1

混江龙づ霸主 提交于 2021-02-19 04:09:13
问题 I am trying to solve the equation x1 + x2 + x3 + .... + xn = 1 where the values of all xi are restricted to [0, 0.1, 0.2, ..., 0.9, 1] . Currently, I am solving the problem by first generating an n-dimensional array mat , where at each element location the value is the sum of the axis values, which vary in axisValues = 0:0.1:1 : mat(i,j,k,...,q) = axisValues(i) + axisValues(j) + ... + axisValues(q). Then I search for all entries of the resulting array that are equal to one. The code (shown

Finding all combinations of multiple variables summing to 1

感情迁移 提交于 2021-02-19 04:05:14
问题 I am trying to solve the equation x1 + x2 + x3 + .... + xn = 1 where the values of all xi are restricted to [0, 0.1, 0.2, ..., 0.9, 1] . Currently, I am solving the problem by first generating an n-dimensional array mat , where at each element location the value is the sum of the axis values, which vary in axisValues = 0:0.1:1 : mat(i,j,k,...,q) = axisValues(i) + axisValues(j) + ... + axisValues(q). Then I search for all entries of the resulting array that are equal to one. The code (shown

Project Euler Problem 233

半腔热情 提交于 2019-12-20 19:50:10
问题 I've decided to tackle Project Euler problem 233 next but I'm having some major problems! I've done some analysis and have made some quite nice progress but I've become stuck now. Here's my working: Lemma 1 : Since the circle goes through the 4 corner points there are at least 4 solutions for any n. But for each point on the circumference there are 7 others found with reflection. Therefore there are always 8k+4 lattice points. Lemma 2 : The circle has radius (√2)n and center (n/2, n/2) so its

Project Euler Problem 233

大兔子大兔子 提交于 2019-12-03 06:14:34
I've decided to tackle Project Euler problem 233 next but I'm having some major problems! I've done some analysis and have made some quite nice progress but I've become stuck now. Here's my working: Lemma 1 : Since the circle goes through the 4 corner points there are at least 4 solutions for any n. But for each point on the circumference there are 7 others found with reflection. Therefore there are always 8k+4 lattice points. Lemma 2 : The circle has radius (√2)n and center (n/2, n/2) so its equation is (x-n/2)^2 + (y-n/2)^2 = [n/√2]^2. This reduces down to x^2+y^2 = n(x+y). Lemma 3 : If a