Message Boards Message Boards

0
|
3788 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Increasing running time of solve (in integers) function using certain condi

Posted 4 years ago

Well, I have the following Mathematica code:

n = 857097;
x = 100;
Solve[{n == n1^3 + n2^3 + n3^3 + n4^3 + n5^3, 
  1 <= n1 < x && 1 <= n2 < x && 1 <= n3 < x && 1 <= n4 < x && 
   1 <= n5 < x && n1 != n2 && n1 != n3 && n1 != n4 && n1 != n5 && 
   n2 != n3 && n2 != n4 && n2 != n5 && n3 != n4 && n3 != n5 && 
   n4 != n5}, {n1, n2, n3, n4, n5}, Integers]

This takes a lot of time to run because I would like to know all the possible solutions and not just one. Is there a way to speed this calculation up?

POSTED BY: Jan Eerland
2 Replies
Posted 4 years ago

Edit Related post was deleted.

Related post.

POSTED BY: Rohit Namjoshi
Posted 4 years ago

Hi Jan,

There is a built-in WL function to do this PowersRepresentations. This takes ~30s to run on my machine.

solutions = PowersRepresentations[857097, 5, 3];
solutions // Length
(* 84 *)

Verify

solutions // Map[#^3 & /* Total] // Union
(* {857097} *)
POSTED BY: Rohit Namjoshi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract