Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #10924
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Newsgroups | comp.programming |
| Subject | Re: are you interested in number theory AND programming |
| Date | 2020-06-13 17:02 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <87k10boswq.fsf@bsb.me.uk> (permalink) |
| References | <2122d884-f04b-42f8-b95a-a257b61fef86o@googlegroups.com> <rc03bc$pme$1@dont-email.me> <3a3b6135-9e6e-42f5-8088-2774a660f504o@googlegroups.com> <87wo4bp8xo.fsf@bsb.me.uk> <f54e9e16-de6c-4c66-8b7e-fdf40ea290dbo@googlegroups.com> |
syedanwarowais5@gmail.com writes:
> As part of a (hopefully growing) exploration in number theory, I need
> to find solutions to the following diophantine equation :
> ab(a+b)=cd(c+d) (in positive integers)
> The first solution set is a=1,b=5 and c=2,d=3.
> I know there are several more solution sets, though I don't know if
> there are an infinite number of solutions sets to this diophantine
> equation.
> Would you like to write a program to solve this puzzle?
It's quite interesting. Here's a first stab using Haskell (I always use
Haskell for this sort of investigation):
import System.Environment
psum (a, b) = a * b * (a + b)
get_b_from product a =
(floor (sqrt(fromIntegral (4*a*product + a^4))) - a^2) `div` (2*a)
possible_pairs_from product =
takeWhile (\(a, b) -> a <= b) $ map (\a -> (a, get_b_from product a)) [1..]
actual_pairs_from product =
filter ((==product).psum) $ possible_pairs_from product
solution_list = filter ((>1).length) $ map actual_pairs_from [2,4..]
main = do
[n] <- getArgs
mapM (putStrLn.showSolution) $ take (read n) $ solution_list
where showSolution s = foldl1 (\s1 s2 -> s1 ++ " " ++ s2) $ map show s
The first 10 solution sets this program finds are:
(1,5) (2,3)
(1,14) (3,7)
(1,15) (2,10) (4,6)
(2,13) (3,10)
(1,20) (5,7)
(1,21) (3,11)
(3,15) (6,9)
(2,20) (5,11)
(4,14) (7,9)
(3,17) (5,12)
and there are a few 6-pair solutions that come up:
(1,384) (6,154) (8,132) (14,96) (28,60) (40,44)
(9,231) (12,198) (21,144) (22,140) (42,90) (60,66)
(6,385) (15,238) (23,187) (46,119) (51,110) (69,85)
> Once you respond, I will go deeper into the mathematics this connects
> to.
Probably best not to hold back like this. Just make it fun with as much
information as you can. That will encourage more responses.
--
Ben.
Back to comp.programming | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
are you interested in number theory AND programming syedanwarowais5@gmail.com - 2020-06-12 02:25 -0700
Re: are you interested in number theory AND programming root <NoEMail@home.org> - 2020-06-12 14:26 +0000
Re: are you interested in number theory AND programming syedanwarowais5@gmail.com - 2020-06-12 19:34 -0700
Re: are you interested in number theory AND programming Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-06-13 11:16 +0100
Re: are you interested in number theory AND programming syedanwarowais5@gmail.com - 2020-06-13 04:07 -0700
Re: are you interested in number theory AND programming Julio Di Egidio <julio@diegidio.name> - 2020-06-13 07:20 -0700
Re: are you interested in number theory AND programming Julio Di Egidio <julio@diegidio.name> - 2020-06-13 07:47 -0700
Re: are you interested in number theory AND programming Julio Di Egidio <julio@diegidio.name> - 2020-06-13 08:29 -0700
Re: are you interested in number theory AND programming Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-06-13 17:02 +0100
Re: are you interested in number theory AND programming syedanwarowais5@gmail.com - 2020-06-13 23:11 -0700
Re: are you interested in number theory AND programming syedanwarowais5@gmail.com - 2020-06-13 23:23 -0700
Re: are you interested in number theory AND programming James Dow Allen <jdallen2000@yahoo.com> - 2020-06-17 00:55 -0700
Re: are you interested in number theory AND programming Richard Heathfield <rjh@cpax.org.uk> - 2020-06-17 09:30 +0100
Re: are you interested in number theory AND programming James Dow Allen <jdallen2000@yahoo.com> - 2020-06-17 02:32 -0700
Re: are you interested in number theory AND programming Richard Heathfield <rjh@cpax.org.uk> - 2020-06-20 08:26 +0100
Re: are you interested in number theory AND programming James Dow Allen <jdallen2000@yahoo.com> - 2020-06-20 03:58 -0700
Re: are you interested in number theory AND programming Richard Heathfield <rjh@cpax.org.uk> - 2020-06-20 14:55 +0100
Re: are you interested in number theory AND programming Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-06-17 23:11 +0100
Re: are you interested in number theory AND programming syed owais <syedanwarowais5@gmail.com> - 2020-06-20 04:44 -0700
Re: are you interested in number theory AND programming Julio Di Egidio <julio@diegidio.name> - 2020-06-20 06:27 -0700
Re: are you interested in number theory AND programming syed owais <syedanwarowais5@gmail.com> - 2020-06-21 17:31 -0700
Re: are you interested in number theory AND programming James Dow Allen <jdallen2000@yahoo.com> - 2020-06-22 02:00 -0700
Re: are you interested in number theory AND programming syed owais <syedanwarowais5@gmail.com> - 2020-06-22 05:34 -0700
Re: are you interested in number theory AND programming root <NoEMail@home.org> - 2020-06-22 14:05 +0000
Re: are you interested in number theory AND programming syed owais <syedanwarowais5@gmail.com> - 2020-06-23 04:50 -0700
Re: are you interested in number theory AND programming David Brown <david.brown@hesbynett.no> - 2020-06-23 15:50 +0200
Re: are you interested in number theory AND programming Chad <cdalten@gmail.com> - 2020-06-23 14:34 -0700
Re: are you interested in number theory AND programming syed owais <syedanwarowais5@gmail.com> - 2020-06-24 01:39 -0700
Re: are you interested in number theory AND programming David Brown <david.brown@hesbynett.no> - 2020-06-24 15:48 +0200
Re: are you interested in number theory AND programming Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-06-24 13:52 +0100
Re: are you interested in number theory AND programming David Brown <david.brown@hesbynett.no> - 2020-06-24 16:00 +0200
Re: are you interested in number theory AND programming Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-06-24 17:03 +0100
Re: are you interested in number theory AND programming David Brown <david.brown@hesbynett.no> - 2020-06-24 20:32 +0200
Re: are you interested in number theory AND programming Chad <cdalten@gmail.com> - 2020-06-24 14:19 -0700
Re: are you interested in number theory AND programming Julio Di Egidio <julio@diegidio.name> - 2020-06-26 06:24 -0700
Re: are you interested in number theory AND programming David Brown <david.brown@hesbynett.no> - 2020-06-26 16:28 +0200
Re: are you interested in number theory AND programming Julio Di Egidio <julio@diegidio.name> - 2020-06-26 06:11 -0700
Re: are you interested in number theory AND programming James Dow Allen <jdallen2000@yahoo.com> - 2020-06-22 09:39 -0700
Re: are you interested in number theory AND programming syed owais <syedanwarowais5@gmail.com> - 2020-06-23 00:50 -0700
Re: are you interested in number theory AND programming James Dow Allen <jdallen2000@yahoo.com> - 2020-06-23 05:14 -0700
Re: are you interested in number theory AND programming syed owais <syedanwarowais5@gmail.com> - 2020-06-24 02:39 -0700
Re: are you interested in number theory AND programming Richard Heathfield <rjh@cpax.org.uk> - 2020-06-25 20:48 +0100
Re: are you interested in number theory AND programming David Brown <david.brown@hesbynett.no> - 2020-06-26 08:48 +0200
Re: are you interested in number theory AND programming syed owais <syedanwarowais5@gmail.com> - 2020-06-26 01:25 -0700
Re: are you interested in number theory AND programming David Brown <david.brown@hesbynett.no> - 2020-06-26 11:10 +0200
Re: are you interested in number theory AND programming James Dow Allen <jdallen2000@yahoo.com> - 2020-06-26 03:56 -0700
Re: are you interested in number theory AND programming David Brown <david.brown@hesbynett.no> - 2020-06-26 13:34 +0200
Re: are you interested in number theory AND programming Boris Dorestand <bdorestand@example.com> - 2020-06-27 11:22 -0300
Re: are you interested in number theory AND programming David Brown <david.brown@hesbynett.no> - 2020-06-27 17:50 +0200
Re: are you interested in number theory AND programming Boris Dorestand <bdorestand@example.com> - 2020-06-27 13:42 -0300
Re: are you interested in number theory AND programming syed owais <syedanwarowais5@gmail.com> - 2020-07-04 18:44 -0700
Re: are you interested in number theory AND programming syed owais <syedanwarowais5@gmail.com> - 2020-07-09 19:51 -0700
Re: are you interested in number theory AND programming James Dow Allen <jdallen2000@yahoo.com> - 2020-07-10 05:32 -0700
Re: are you interested in number theory AND programming syed owais <syedanwarowais5@gmail.com> - 2020-07-10 09:03 -0700
Re: are you interested in number theory AND programming Julio Di Egidio <julio@diegidio.name> - 2020-06-26 06:02 -0700
Re: are you interested in number theory AND programming James Dow Allen <jdallen2000@yahoo.com> - 2020-06-26 01:58 -0700
Re: are you interested in number theory AND programming David Brown <david.brown@hesbynett.no> - 2020-06-26 11:14 +0200
Re: are you interested in number theory AND programming Richard Damon <Richard@Damon-Family.org> - 2020-06-26 13:10 -0400
Re: are you interested in number theory AND programming Julio Di Egidio <julio@diegidio.name> - 2020-06-26 06:12 -0700
Re: are you interested in number theory AND programming David Brown <david.brown@hesbynett.no> - 2020-06-13 23:28 +0200
csiph-web