Group Abstract Group Abstract

Message Boards Message Boards

Improving calculation speed for finding perfect squares using two variables

Posted 5 years ago
POSTED BY: Jan Eerland
5 Replies
Posted 5 years ago
POSTED BY: Rohit Namjoshi
Posted 5 years ago

What is the definition of sQ[.]? Now it does not work in my Mathematica.

POSTED BY: Jan Eerland
Posted 5 years ago

Quick comparison

Simplify[123*(3*(2*x)^2 + 167*y^2*x + y*x + 4*y^3*x^2)]
(* 123 x (y (1 + 167 y) + 4 x (3 + y^3) *)

f[x_, y_] := 123 x (y (1 + 167 y) + 4 x (3 + y^3);

Table[If[TrueQ[Sqrt[f[x, y]] \[Element] Integers], {x, y}, Nothing], {x, 2000, 5000},
  {y, 2000, 5000}] // AbsoluteTiming // First
(* I gave up after waiting for 6 minutes *)

Table[If[sQ[f[x, y]], {x, y}, Nothing], {x, 2000, 5000}, {y, 2000, 5000}] // 
 AbsoluteTiming // First
(* 49.3531 *)
POSTED BY: Rohit Namjoshi
Posted 5 years ago

Can you show me how to imply that in om my problem?

POSTED BY: Jan Eerland
Posted 5 years ago
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