Find maximum of the output from reduceHow Can I use Solve/Reduce OutputFailure message from ReduceExtract desired solutions from ReduceFinding the least positive integer satisfying a quantified statementhow do I control the output of Reduce function?Using the output of ReduceIncomplete and weird output from ReduceUsing Solve returns unnecessary Root, overcomplicated formula, and erroneous negative valueHow to analyse huge output from Reduce systematically?Make Reduce produce nicer output

Typing CO_2 easily

Showing mass murder in a kid's book

What does "Scientists rise up against statistical significance" mean? (Comment in Nature)

Why is the Sun approximated as a black body at ~ 5800 K?

Anime with legendary swords made from talismans and a man who could change them with a shattered body

What should be the ideal length of sentences in a blog post for ease of reading?

Make a Bowl of Alphabet Soup

Given this phrasing in the lease, when should I pay my rent?

When is "ei" a diphthong?

How were servants to the Kaiser of Imperial Germany treated and where may I find more information on them

The Digit Triangles

What does "tick" mean in this sentence?

Sigmoid with a slope but no asymptotes?

Do I have to know the General Relativity theory to understand the concept of inertial frame?

PTIJ: Which Dr. Seuss books should one obtain?

How do you justify more code being written by following clean code practices?

Are Captain Marvel's powers affected by Thanos breaking the Tesseract and claiming the stone?

How to make a list of partial sums using forEach

Should I warn new/prospective PhD Student that supervisor is terrible?

Animation: customize bounce interpolation

What (the heck) is a Super Worm Equinox Moon?

Does the Crossbow Expert feat's extra crossbow attack work with the reaction attack from a Hunter ranger's Giant Killer feature?

Echo with obfuscation

Why can't the Brexit deadlock in the UK parliament be solved with a plurality vote?



Find maximum of the output from reduce


How Can I use Solve/Reduce OutputFailure message from ReduceExtract desired solutions from ReduceFinding the least positive integer satisfying a quantified statementhow do I control the output of Reduce function?Using the output of ReduceIncomplete and weird output from ReduceUsing Solve returns unnecessary Root, overcomplicated formula, and erroneous negative valueHow to analyse huge output from Reduce systematically?Make Reduce produce nicer output













4












$begingroup$


I am trying to reduce a function in two variables($n_1$ and $n_2$) whose domain is the set of Integers. I get a long list of pairs of values for these two variables(instead of a range). This could be because the range of $n_2$ changes for each $n_1$. I just want the maximum value of $n_1$ and $n_2$. Can you please guide me?



 driftParamSet = 1.9 - 0.2 Subscript[n, 2] + Subscript[n, 1] (-0.2 + (2.91434*10^-16 Subscript[n, 1])/(1. Subscript[n, 1] + 1.5 Subscript[n, 2]));
drift[Gamma] = 17;
Reduce[driftParamSet> -drift[Gamma] && Subscript[n, 1]>= 0 && Subscript[n, 2]>= 0,Subscript[n, 1],Subscript[n, 2], Integers];


Current output:
$n_1=0land n_2=1left|n_1=0land n_2=2right|n_1=0land n_2=3|n_1=0land n_2=4
\......\left|n_1=0land n_2=90right|n_1=0land n_2=91|\.....\
left(n_1=92land n_2=2right)lor left(n_1=93land n_2=0right)lor left(n_1=93land n_2=1right)lor left(n_1=94land n_2=0right)$



Expected output:



$n_1$=94 and $n_2=$91










share|improve this question











$endgroup$







  • 1




    $begingroup$
    Several symbols in your code are undefined. Please provide the definitions to aid the reader in answering your question.
    $endgroup$
    – bbgodfrey
    Mar 7 at 1:52










  • $begingroup$
    @bbgodfrey, sorry about that. I have updated the question now.
    $endgroup$
    – gaganso
    Mar 7 at 1:58















4












$begingroup$


I am trying to reduce a function in two variables($n_1$ and $n_2$) whose domain is the set of Integers. I get a long list of pairs of values for these two variables(instead of a range). This could be because the range of $n_2$ changes for each $n_1$. I just want the maximum value of $n_1$ and $n_2$. Can you please guide me?



 driftParamSet = 1.9 - 0.2 Subscript[n, 2] + Subscript[n, 1] (-0.2 + (2.91434*10^-16 Subscript[n, 1])/(1. Subscript[n, 1] + 1.5 Subscript[n, 2]));
drift[Gamma] = 17;
Reduce[driftParamSet> -drift[Gamma] && Subscript[n, 1]>= 0 && Subscript[n, 2]>= 0,Subscript[n, 1],Subscript[n, 2], Integers];


Current output:
$n_1=0land n_2=1left|n_1=0land n_2=2right|n_1=0land n_2=3|n_1=0land n_2=4
\......\left|n_1=0land n_2=90right|n_1=0land n_2=91|\.....\
left(n_1=92land n_2=2right)lor left(n_1=93land n_2=0right)lor left(n_1=93land n_2=1right)lor left(n_1=94land n_2=0right)$



Expected output:



$n_1$=94 and $n_2=$91










share|improve this question











$endgroup$







  • 1




    $begingroup$
    Several symbols in your code are undefined. Please provide the definitions to aid the reader in answering your question.
    $endgroup$
    – bbgodfrey
    Mar 7 at 1:52










  • $begingroup$
    @bbgodfrey, sorry about that. I have updated the question now.
    $endgroup$
    – gaganso
    Mar 7 at 1:58













4












4








4





$begingroup$


I am trying to reduce a function in two variables($n_1$ and $n_2$) whose domain is the set of Integers. I get a long list of pairs of values for these two variables(instead of a range). This could be because the range of $n_2$ changes for each $n_1$. I just want the maximum value of $n_1$ and $n_2$. Can you please guide me?



 driftParamSet = 1.9 - 0.2 Subscript[n, 2] + Subscript[n, 1] (-0.2 + (2.91434*10^-16 Subscript[n, 1])/(1. Subscript[n, 1] + 1.5 Subscript[n, 2]));
drift[Gamma] = 17;
Reduce[driftParamSet> -drift[Gamma] && Subscript[n, 1]>= 0 && Subscript[n, 2]>= 0,Subscript[n, 1],Subscript[n, 2], Integers];


Current output:
$n_1=0land n_2=1left|n_1=0land n_2=2right|n_1=0land n_2=3|n_1=0land n_2=4
\......\left|n_1=0land n_2=90right|n_1=0land n_2=91|\.....\
left(n_1=92land n_2=2right)lor left(n_1=93land n_2=0right)lor left(n_1=93land n_2=1right)lor left(n_1=94land n_2=0right)$



Expected output:



$n_1$=94 and $n_2=$91










share|improve this question











$endgroup$




I am trying to reduce a function in two variables($n_1$ and $n_2$) whose domain is the set of Integers. I get a long list of pairs of values for these two variables(instead of a range). This could be because the range of $n_2$ changes for each $n_1$. I just want the maximum value of $n_1$ and $n_2$. Can you please guide me?



 driftParamSet = 1.9 - 0.2 Subscript[n, 2] + Subscript[n, 1] (-0.2 + (2.91434*10^-16 Subscript[n, 1])/(1. Subscript[n, 1] + 1.5 Subscript[n, 2]));
drift[Gamma] = 17;
Reduce[driftParamSet> -drift[Gamma] && Subscript[n, 1]>= 0 && Subscript[n, 2]>= 0,Subscript[n, 1],Subscript[n, 2], Integers];


Current output:
$n_1=0land n_2=1left|n_1=0land n_2=2right|n_1=0land n_2=3|n_1=0land n_2=4
\......\left|n_1=0land n_2=90right|n_1=0land n_2=91|\.....\
left(n_1=92land n_2=2right)lor left(n_1=93land n_2=0right)lor left(n_1=93land n_2=1right)lor left(n_1=94land n_2=0right)$



Expected output:



$n_1$=94 and $n_2=$91







equation-solving functions






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 7 at 1:57







gaganso

















asked Mar 7 at 1:28









gagansogaganso

1307




1307







  • 1




    $begingroup$
    Several symbols in your code are undefined. Please provide the definitions to aid the reader in answering your question.
    $endgroup$
    – bbgodfrey
    Mar 7 at 1:52










  • $begingroup$
    @bbgodfrey, sorry about that. I have updated the question now.
    $endgroup$
    – gaganso
    Mar 7 at 1:58












  • 1




    $begingroup$
    Several symbols in your code are undefined. Please provide the definitions to aid the reader in answering your question.
    $endgroup$
    – bbgodfrey
    Mar 7 at 1:52










  • $begingroup$
    @bbgodfrey, sorry about that. I have updated the question now.
    $endgroup$
    – gaganso
    Mar 7 at 1:58







1




1




$begingroup$
Several symbols in your code are undefined. Please provide the definitions to aid the reader in answering your question.
$endgroup$
– bbgodfrey
Mar 7 at 1:52




$begingroup$
Several symbols in your code are undefined. Please provide the definitions to aid the reader in answering your question.
$endgroup$
– bbgodfrey
Mar 7 at 1:52












$begingroup$
@bbgodfrey, sorry about that. I have updated the question now.
$endgroup$
– gaganso
Mar 7 at 1:58




$begingroup$
@bbgodfrey, sorry about that. I have updated the question now.
$endgroup$
– gaganso
Mar 7 at 1:58










2 Answers
2






active

oldest

votes


















4












$begingroup$

Let the large result of Reduce be rs. Then the maximum of each quantity is determined by



Max@Cases[rs, Equal[Subscript[n, 1], z_] -> z, Infinity]
(* 94 *)
Max@Cases[rs, Equal[Subscript[n, 2], z_] -> z, Infinity]
(* 94 *)


not 91 as speculated in the question. The corresponding terms in rs can be obtained by



Position[rs, 94, Infinity]
(* 94, 2, 2, 4559, 1, 2 *)

rs[[94]]
(* Subscript[n, 1] == 0 && Subscript[n, 2] == 94 *)

rs[[4559]]
(* Subscript[n, 1] == 94 && Subscript[n, 2] == 0 *)





share|improve this answer











$endgroup$












  • $begingroup$
    thank you! To understand this better, the Cases[] function with the specified parameter creates a list of values of n1/n2 and the Max[] function operates on this list to give the maximum?
    $endgroup$
    – gaganso
    Mar 7 at 2:21






  • 1




    $begingroup$
    @gaganso Precisely so.
    $endgroup$
    – bbgodfrey
    Mar 7 at 2:22


















4












$begingroup$

An alternative is to use Solve after Rationalizeing input expressions:



driftParamSet = Rationalize[1.9 - 0.2 n2 + 
n1 (-0.2 + (2.91434*10^-16 n1)/(1. n1 + 1.5 n2)), 10^-16]
driftγ = 17;
solutions = Solve[driftParamSet > -driftγ && n1 >= 0 && n2 >= 0, n1, n2, Integers];

Max /@ Transpose[n1, n2 /. solutions]



94, 94




Yet another approach is using ArgMax:



Extract[ArgMax[#, driftParamSet > -driftγ && n1 >= 0 && n2 >= 0, n1, n2, Integers]& /@ 
n1, n2, 1, 1, -1, -1]



94, 94







share|improve this answer











$endgroup$












    Your Answer





    StackExchange.ifUsing("editor", function ()
    return StackExchange.using("mathjaxEditing", function ()
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
    );
    );
    , "mathjax-editing");

    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/3.0/"u003ecc by-sa 3.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
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f192764%2ffind-maximum-of-the-output-from-reduce%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









    4












    $begingroup$

    Let the large result of Reduce be rs. Then the maximum of each quantity is determined by



    Max@Cases[rs, Equal[Subscript[n, 1], z_] -> z, Infinity]
    (* 94 *)
    Max@Cases[rs, Equal[Subscript[n, 2], z_] -> z, Infinity]
    (* 94 *)


    not 91 as speculated in the question. The corresponding terms in rs can be obtained by



    Position[rs, 94, Infinity]
    (* 94, 2, 2, 4559, 1, 2 *)

    rs[[94]]
    (* Subscript[n, 1] == 0 && Subscript[n, 2] == 94 *)

    rs[[4559]]
    (* Subscript[n, 1] == 94 && Subscript[n, 2] == 0 *)





    share|improve this answer











    $endgroup$












    • $begingroup$
      thank you! To understand this better, the Cases[] function with the specified parameter creates a list of values of n1/n2 and the Max[] function operates on this list to give the maximum?
      $endgroup$
      – gaganso
      Mar 7 at 2:21






    • 1




      $begingroup$
      @gaganso Precisely so.
      $endgroup$
      – bbgodfrey
      Mar 7 at 2:22















    4












    $begingroup$

    Let the large result of Reduce be rs. Then the maximum of each quantity is determined by



    Max@Cases[rs, Equal[Subscript[n, 1], z_] -> z, Infinity]
    (* 94 *)
    Max@Cases[rs, Equal[Subscript[n, 2], z_] -> z, Infinity]
    (* 94 *)


    not 91 as speculated in the question. The corresponding terms in rs can be obtained by



    Position[rs, 94, Infinity]
    (* 94, 2, 2, 4559, 1, 2 *)

    rs[[94]]
    (* Subscript[n, 1] == 0 && Subscript[n, 2] == 94 *)

    rs[[4559]]
    (* Subscript[n, 1] == 94 && Subscript[n, 2] == 0 *)





    share|improve this answer











    $endgroup$












    • $begingroup$
      thank you! To understand this better, the Cases[] function with the specified parameter creates a list of values of n1/n2 and the Max[] function operates on this list to give the maximum?
      $endgroup$
      – gaganso
      Mar 7 at 2:21






    • 1




      $begingroup$
      @gaganso Precisely so.
      $endgroup$
      – bbgodfrey
      Mar 7 at 2:22













    4












    4








    4





    $begingroup$

    Let the large result of Reduce be rs. Then the maximum of each quantity is determined by



    Max@Cases[rs, Equal[Subscript[n, 1], z_] -> z, Infinity]
    (* 94 *)
    Max@Cases[rs, Equal[Subscript[n, 2], z_] -> z, Infinity]
    (* 94 *)


    not 91 as speculated in the question. The corresponding terms in rs can be obtained by



    Position[rs, 94, Infinity]
    (* 94, 2, 2, 4559, 1, 2 *)

    rs[[94]]
    (* Subscript[n, 1] == 0 && Subscript[n, 2] == 94 *)

    rs[[4559]]
    (* Subscript[n, 1] == 94 && Subscript[n, 2] == 0 *)





    share|improve this answer











    $endgroup$



    Let the large result of Reduce be rs. Then the maximum of each quantity is determined by



    Max@Cases[rs, Equal[Subscript[n, 1], z_] -> z, Infinity]
    (* 94 *)
    Max@Cases[rs, Equal[Subscript[n, 2], z_] -> z, Infinity]
    (* 94 *)


    not 91 as speculated in the question. The corresponding terms in rs can be obtained by



    Position[rs, 94, Infinity]
    (* 94, 2, 2, 4559, 1, 2 *)

    rs[[94]]
    (* Subscript[n, 1] == 0 && Subscript[n, 2] == 94 *)

    rs[[4559]]
    (* Subscript[n, 1] == 94 && Subscript[n, 2] == 0 *)






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Mar 7 at 2:18

























    answered Mar 7 at 2:13









    bbgodfreybbgodfrey

    44.9k1059110




    44.9k1059110











    • $begingroup$
      thank you! To understand this better, the Cases[] function with the specified parameter creates a list of values of n1/n2 and the Max[] function operates on this list to give the maximum?
      $endgroup$
      – gaganso
      Mar 7 at 2:21






    • 1




      $begingroup$
      @gaganso Precisely so.
      $endgroup$
      – bbgodfrey
      Mar 7 at 2:22
















    • $begingroup$
      thank you! To understand this better, the Cases[] function with the specified parameter creates a list of values of n1/n2 and the Max[] function operates on this list to give the maximum?
      $endgroup$
      – gaganso
      Mar 7 at 2:21






    • 1




      $begingroup$
      @gaganso Precisely so.
      $endgroup$
      – bbgodfrey
      Mar 7 at 2:22















    $begingroup$
    thank you! To understand this better, the Cases[] function with the specified parameter creates a list of values of n1/n2 and the Max[] function operates on this list to give the maximum?
    $endgroup$
    – gaganso
    Mar 7 at 2:21




    $begingroup$
    thank you! To understand this better, the Cases[] function with the specified parameter creates a list of values of n1/n2 and the Max[] function operates on this list to give the maximum?
    $endgroup$
    – gaganso
    Mar 7 at 2:21




    1




    1




    $begingroup$
    @gaganso Precisely so.
    $endgroup$
    – bbgodfrey
    Mar 7 at 2:22




    $begingroup$
    @gaganso Precisely so.
    $endgroup$
    – bbgodfrey
    Mar 7 at 2:22











    4












    $begingroup$

    An alternative is to use Solve after Rationalizeing input expressions:



    driftParamSet = Rationalize[1.9 - 0.2 n2 + 
    n1 (-0.2 + (2.91434*10^-16 n1)/(1. n1 + 1.5 n2)), 10^-16]
    driftγ = 17;
    solutions = Solve[driftParamSet > -driftγ && n1 >= 0 && n2 >= 0, n1, n2, Integers];

    Max /@ Transpose[n1, n2 /. solutions]



    94, 94




    Yet another approach is using ArgMax:



    Extract[ArgMax[#, driftParamSet > -driftγ && n1 >= 0 && n2 >= 0, n1, n2, Integers]& /@ 
    n1, n2, 1, 1, -1, -1]



    94, 94







    share|improve this answer











    $endgroup$

















      4












      $begingroup$

      An alternative is to use Solve after Rationalizeing input expressions:



      driftParamSet = Rationalize[1.9 - 0.2 n2 + 
      n1 (-0.2 + (2.91434*10^-16 n1)/(1. n1 + 1.5 n2)), 10^-16]
      driftγ = 17;
      solutions = Solve[driftParamSet > -driftγ && n1 >= 0 && n2 >= 0, n1, n2, Integers];

      Max /@ Transpose[n1, n2 /. solutions]



      94, 94




      Yet another approach is using ArgMax:



      Extract[ArgMax[#, driftParamSet > -driftγ && n1 >= 0 && n2 >= 0, n1, n2, Integers]& /@ 
      n1, n2, 1, 1, -1, -1]



      94, 94







      share|improve this answer











      $endgroup$















        4












        4








        4





        $begingroup$

        An alternative is to use Solve after Rationalizeing input expressions:



        driftParamSet = Rationalize[1.9 - 0.2 n2 + 
        n1 (-0.2 + (2.91434*10^-16 n1)/(1. n1 + 1.5 n2)), 10^-16]
        driftγ = 17;
        solutions = Solve[driftParamSet > -driftγ && n1 >= 0 && n2 >= 0, n1, n2, Integers];

        Max /@ Transpose[n1, n2 /. solutions]



        94, 94




        Yet another approach is using ArgMax:



        Extract[ArgMax[#, driftParamSet > -driftγ && n1 >= 0 && n2 >= 0, n1, n2, Integers]& /@ 
        n1, n2, 1, 1, -1, -1]



        94, 94







        share|improve this answer











        $endgroup$



        An alternative is to use Solve after Rationalizeing input expressions:



        driftParamSet = Rationalize[1.9 - 0.2 n2 + 
        n1 (-0.2 + (2.91434*10^-16 n1)/(1. n1 + 1.5 n2)), 10^-16]
        driftγ = 17;
        solutions = Solve[driftParamSet > -driftγ && n1 >= 0 && n2 >= 0, n1, n2, Integers];

        Max /@ Transpose[n1, n2 /. solutions]



        94, 94




        Yet another approach is using ArgMax:



        Extract[ArgMax[#, driftParamSet > -driftγ && n1 >= 0 && n2 >= 0, n1, n2, Integers]& /@ 
        n1, n2, 1, 1, -1, -1]



        94, 94








        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 7 at 3:00

























        answered Mar 7 at 2:29









        kglrkglr

        189k10206424




        189k10206424



























            draft saved

            draft discarded
















































            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.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f192764%2ffind-maximum-of-the-output-from-reduce%23new-answer', 'question_page');

            );

            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







            Popular posts from this blog

            1928 у кіно

            Захаров Федір Захарович

            Ель Греко