Writing a program that will filter the integer solutionsNSolve gives additional solutions that don't satisfy the equations!How to find integer solutions?why doesn't NSolve find all the solutions that Solve finds?On finding all the positive integral solutions of $x^2+y^2=z^2+1$Solve doesn't give me all the solutions I expectShowing that an integer solution does not existHow to convert an expression a + b*Sqrt[c] to a simpler format?FindInstance fails to find integer solutions to glaringly obvious problemsFind multiple solutions of a non-linear system with more variables that equationsHow to solve equation in integer numbers
How to identify whether a publisher is genuine or not?
How deep is the liquid in a half-full hemisphere?
Worlds with different mathematics and logic
does 'java' command compile the java program?
How many space launch vehicles are under development worldwide?
Can adverbs modify adjectives?
Delete n lines skip 1 line script
grounded outlets and code compliance
How does Monks' Improved Unarmored Movement work out of combat?
Which Catholic priests were given diplomatic missions?
Smallest PRIME containing the first 11 primes as sub-strings
Can I pay some of the cost of an activated ability lots of times to get more out of the effect?
Realistically, how much do you need to start investing?
If someone asks a question using “quién”, how can one shortly respond?
Can a passenger predict that an airline is about to go bankrupt?
What does it mean by "my days-of-the-week underwear only go to Thursday" in this context?
Would a horse be sufficient buffer to prevent injury when falling from a great height?
To what degree did the Supreme Court limit Boris Johnson's ability to prorogue?
How do I introduce dark themes?
Did Tolkien ever write about a Heaven or Hell for Men?
Beyond Futuristic Technology for an Alien Warship?
Implementation of a Thread Pool in C++
How do we know neutrons have no charge?
Lost passport and visa, tried to reapply, got rejected twice. What are my next steps?
Writing a program that will filter the integer solutions
NSolve gives additional solutions that don't satisfy the equations!How to find integer solutions?why doesn't NSolve find all the solutions that Solve finds?On finding all the positive integral solutions of $x^2+y^2=z^2+1$Solve doesn't give me all the solutions I expectShowing that an integer solution does not existHow to convert an expression a + b*Sqrt[c] to a simpler format?FindInstance fails to find integer solutions to glaringly obvious problemsFind multiple solutions of a non-linear system with more variables that equationsHow to solve equation in integer numbers
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
$begingroup$
I've the following equation:
b==(-12 +
Sqrt[3] Sqrt[
3 (-4 + r)^2 + 12 a^2 (-2 + r) - 4 a (-5 + r) (-2 + r) +
4 a^3 (-2 + r)^2] + 3 r)/(6 (-2 + r))
And $r$ is a given number and I'll run $a$ from $2$ to a given number n, which are all integers.
How can I write a code that will give me only an output of $b$ when the equation gives an integer back?
For example, when I use $r=4$ and use the following code:
Table[Sqrt[a (1 + a) (1 + 2 a)]/Sqrt[6], a, 1, 100, 1]
It will find that $a=24$ gives $b=70$, so I want to see only that solution.
Maybe I can use the If[]
function?
equation-solving programming code-request system code
$endgroup$
add a comment
|
$begingroup$
I've the following equation:
b==(-12 +
Sqrt[3] Sqrt[
3 (-4 + r)^2 + 12 a^2 (-2 + r) - 4 a (-5 + r) (-2 + r) +
4 a^3 (-2 + r)^2] + 3 r)/(6 (-2 + r))
And $r$ is a given number and I'll run $a$ from $2$ to a given number n, which are all integers.
How can I write a code that will give me only an output of $b$ when the equation gives an integer back?
For example, when I use $r=4$ and use the following code:
Table[Sqrt[a (1 + a) (1 + 2 a)]/Sqrt[6], a, 1, 100, 1]
It will find that $a=24$ gives $b=70$, so I want to see only that solution.
Maybe I can use the If[]
function?
equation-solving programming code-request system code
$endgroup$
$begingroup$
tryTable[If[IntegerQ[Sqrt[a (1 + a) (1 + 2 a)]/Sqrt[6]],Sqrt[a (1 + a) (1 + 2 a)]/Sqrt[6],Nothing], a, 1, 100, 1]
or shorterTable[If[IntegerQ[#,#,Nothing]&@(Sqrt[a (1 + a) (1 + 2 a)]/Sqrt[6]), a, 1, 100, 1]
?
$endgroup$
– kglr
7 hours ago
add a comment
|
$begingroup$
I've the following equation:
b==(-12 +
Sqrt[3] Sqrt[
3 (-4 + r)^2 + 12 a^2 (-2 + r) - 4 a (-5 + r) (-2 + r) +
4 a^3 (-2 + r)^2] + 3 r)/(6 (-2 + r))
And $r$ is a given number and I'll run $a$ from $2$ to a given number n, which are all integers.
How can I write a code that will give me only an output of $b$ when the equation gives an integer back?
For example, when I use $r=4$ and use the following code:
Table[Sqrt[a (1 + a) (1 + 2 a)]/Sqrt[6], a, 1, 100, 1]
It will find that $a=24$ gives $b=70$, so I want to see only that solution.
Maybe I can use the If[]
function?
equation-solving programming code-request system code
$endgroup$
I've the following equation:
b==(-12 +
Sqrt[3] Sqrt[
3 (-4 + r)^2 + 12 a^2 (-2 + r) - 4 a (-5 + r) (-2 + r) +
4 a^3 (-2 + r)^2] + 3 r)/(6 (-2 + r))
And $r$ is a given number and I'll run $a$ from $2$ to a given number n, which are all integers.
How can I write a code that will give me only an output of $b$ when the equation gives an integer back?
For example, when I use $r=4$ and use the following code:
Table[Sqrt[a (1 + a) (1 + 2 a)]/Sqrt[6], a, 1, 100, 1]
It will find that $a=24$ gives $b=70$, so I want to see only that solution.
Maybe I can use the If[]
function?
equation-solving programming code-request system code
equation-solving programming code-request system code
asked 8 hours ago
JanJan
2502 silver badges11 bronze badges
2502 silver badges11 bronze badges
$begingroup$
tryTable[If[IntegerQ[Sqrt[a (1 + a) (1 + 2 a)]/Sqrt[6]],Sqrt[a (1 + a) (1 + 2 a)]/Sqrt[6],Nothing], a, 1, 100, 1]
or shorterTable[If[IntegerQ[#,#,Nothing]&@(Sqrt[a (1 + a) (1 + 2 a)]/Sqrt[6]), a, 1, 100, 1]
?
$endgroup$
– kglr
7 hours ago
add a comment
|
$begingroup$
tryTable[If[IntegerQ[Sqrt[a (1 + a) (1 + 2 a)]/Sqrt[6]],Sqrt[a (1 + a) (1 + 2 a)]/Sqrt[6],Nothing], a, 1, 100, 1]
or shorterTable[If[IntegerQ[#,#,Nothing]&@(Sqrt[a (1 + a) (1 + 2 a)]/Sqrt[6]), a, 1, 100, 1]
?
$endgroup$
– kglr
7 hours ago
$begingroup$
try
Table[If[IntegerQ[Sqrt[a (1 + a) (1 + 2 a)]/Sqrt[6]],Sqrt[a (1 + a) (1 + 2 a)]/Sqrt[6],Nothing], a, 1, 100, 1]
or shorter Table[If[IntegerQ[#,#,Nothing]&@(Sqrt[a (1 + a) (1 + 2 a)]/Sqrt[6]), a, 1, 100, 1]
?$endgroup$
– kglr
7 hours ago
$begingroup$
try
Table[If[IntegerQ[Sqrt[a (1 + a) (1 + 2 a)]/Sqrt[6]],Sqrt[a (1 + a) (1 + 2 a)]/Sqrt[6],Nothing], a, 1, 100, 1]
or shorter Table[If[IntegerQ[#,#,Nothing]&@(Sqrt[a (1 + a) (1 + 2 a)]/Sqrt[6]), a, 1, 100, 1]
?$endgroup$
– kglr
7 hours ago
add a comment
|
2 Answers
2
active
oldest
votes
$begingroup$
You can use Solve
. Your equation:
eqn[r_] := b == (-12 + Sqrt[3] Sqrt[3 (-4 + r)^2 + 12 a^2 (-2 + r) - 4 a (-5 + r) (-2 + r) + 4 a^3 (-2 + r)^2] + 3 r)/(6 (-2 + r))
Using Solve
(with $r=4$):
Solve[eqn[4] && 1 < a < 100, a, b, Integers]
a -> 24, b -> 70
Using Solve
(with $r=11$):
Solve[eqn[11] && 1 < a < 100, a, b, Integers]
a -> 25, b -> 73
$endgroup$
add a comment
|
$begingroup$
You might try IntegerQ
Table[b = (-12 +Sqrt[3] Sqrt[3 (-4 + r)^2 + 12 a^2 (-2 + r) - 4 a (-5 + r) (-2+ r) +4 a^3 (-2 + r)^2] + 3 r)/(6 (-2 + r)) /. r -> 4;
If[IntegerQ[b], b, a, Nothing], a, 2, 50]
(*70, 24*)
$endgroup$
add a comment
|
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "387"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f206787%2fwriting-a-program-that-will-filter-the-integer-solutions%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
You can use Solve
. Your equation:
eqn[r_] := b == (-12 + Sqrt[3] Sqrt[3 (-4 + r)^2 + 12 a^2 (-2 + r) - 4 a (-5 + r) (-2 + r) + 4 a^3 (-2 + r)^2] + 3 r)/(6 (-2 + r))
Using Solve
(with $r=4$):
Solve[eqn[4] && 1 < a < 100, a, b, Integers]
a -> 24, b -> 70
Using Solve
(with $r=11$):
Solve[eqn[11] && 1 < a < 100, a, b, Integers]
a -> 25, b -> 73
$endgroup$
add a comment
|
$begingroup$
You can use Solve
. Your equation:
eqn[r_] := b == (-12 + Sqrt[3] Sqrt[3 (-4 + r)^2 + 12 a^2 (-2 + r) - 4 a (-5 + r) (-2 + r) + 4 a^3 (-2 + r)^2] + 3 r)/(6 (-2 + r))
Using Solve
(with $r=4$):
Solve[eqn[4] && 1 < a < 100, a, b, Integers]
a -> 24, b -> 70
Using Solve
(with $r=11$):
Solve[eqn[11] && 1 < a < 100, a, b, Integers]
a -> 25, b -> 73
$endgroup$
add a comment
|
$begingroup$
You can use Solve
. Your equation:
eqn[r_] := b == (-12 + Sqrt[3] Sqrt[3 (-4 + r)^2 + 12 a^2 (-2 + r) - 4 a (-5 + r) (-2 + r) + 4 a^3 (-2 + r)^2] + 3 r)/(6 (-2 + r))
Using Solve
(with $r=4$):
Solve[eqn[4] && 1 < a < 100, a, b, Integers]
a -> 24, b -> 70
Using Solve
(with $r=11$):
Solve[eqn[11] && 1 < a < 100, a, b, Integers]
a -> 25, b -> 73
$endgroup$
You can use Solve
. Your equation:
eqn[r_] := b == (-12 + Sqrt[3] Sqrt[3 (-4 + r)^2 + 12 a^2 (-2 + r) - 4 a (-5 + r) (-2 + r) + 4 a^3 (-2 + r)^2] + 3 r)/(6 (-2 + r))
Using Solve
(with $r=4$):
Solve[eqn[4] && 1 < a < 100, a, b, Integers]
a -> 24, b -> 70
Using Solve
(with $r=11$):
Solve[eqn[11] && 1 < a < 100, a, b, Integers]
a -> 25, b -> 73
answered 7 hours ago
Carl WollCarl Woll
90.6k3 gold badges120 silver badges232 bronze badges
90.6k3 gold badges120 silver badges232 bronze badges
add a comment
|
add a comment
|
$begingroup$
You might try IntegerQ
Table[b = (-12 +Sqrt[3] Sqrt[3 (-4 + r)^2 + 12 a^2 (-2 + r) - 4 a (-5 + r) (-2+ r) +4 a^3 (-2 + r)^2] + 3 r)/(6 (-2 + r)) /. r -> 4;
If[IntegerQ[b], b, a, Nothing], a, 2, 50]
(*70, 24*)
$endgroup$
add a comment
|
$begingroup$
You might try IntegerQ
Table[b = (-12 +Sqrt[3] Sqrt[3 (-4 + r)^2 + 12 a^2 (-2 + r) - 4 a (-5 + r) (-2+ r) +4 a^3 (-2 + r)^2] + 3 r)/(6 (-2 + r)) /. r -> 4;
If[IntegerQ[b], b, a, Nothing], a, 2, 50]
(*70, 24*)
$endgroup$
add a comment
|
$begingroup$
You might try IntegerQ
Table[b = (-12 +Sqrt[3] Sqrt[3 (-4 + r)^2 + 12 a^2 (-2 + r) - 4 a (-5 + r) (-2+ r) +4 a^3 (-2 + r)^2] + 3 r)/(6 (-2 + r)) /. r -> 4;
If[IntegerQ[b], b, a, Nothing], a, 2, 50]
(*70, 24*)
$endgroup$
You might try IntegerQ
Table[b = (-12 +Sqrt[3] Sqrt[3 (-4 + r)^2 + 12 a^2 (-2 + r) - 4 a (-5 + r) (-2+ r) +4 a^3 (-2 + r)^2] + 3 r)/(6 (-2 + r)) /. r -> 4;
If[IntegerQ[b], b, a, Nothing], a, 2, 50]
(*70, 24*)
answered 7 hours ago
Ulrich NeumannUlrich Neumann
14.3k7 silver badges23 bronze badges
14.3k7 silver badges23 bronze badges
add a comment
|
add a comment
|
Thanks for contributing an answer to Mathematica Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f206787%2fwriting-a-program-that-will-filter-the-integer-solutions%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
$begingroup$
try
Table[If[IntegerQ[Sqrt[a (1 + a) (1 + 2 a)]/Sqrt[6]],Sqrt[a (1 + a) (1 + 2 a)]/Sqrt[6],Nothing], a, 1, 100, 1]
or shorterTable[If[IntegerQ[#,#,Nothing]&@(Sqrt[a (1 + a) (1 + 2 a)]/Sqrt[6]), a, 1, 100, 1]
?$endgroup$
– kglr
7 hours ago