Integrate a SymPy expression with a complex factor which does not involve x











up vote
1
down vote

favorite












I want to integrate complex functions with sympy.integrate. I realized that it takes too much time (at least I stopped process after 2.5 hours).



I am planning to give an equation to the program as simply as possible.
Lets assume I have a function :



alpha*x**(-rho/(rho - 1))*(-gamma*l*rho + gamma*l - gamma*pi*rho + gamma*pi - l*rho - pi*rho)/(gamma*mu)


I only part I will integrate is



MainPart = x**(-rho/(rho - 1))

IntegMainPart=sympy.integrate(MainPart)


and rest are only parameters and they will be



Rest=alpha*(-gamma*l*rho + gamma*l - gamma*pi*rho + gamma*pi - l*rho - pi*rho)/(gamma*mu)


So is it possible that i can take only important part and integrate it and than multiple with rest like



IntegMainPart*Rest


?










share|improve this question




























    up vote
    1
    down vote

    favorite












    I want to integrate complex functions with sympy.integrate. I realized that it takes too much time (at least I stopped process after 2.5 hours).



    I am planning to give an equation to the program as simply as possible.
    Lets assume I have a function :



    alpha*x**(-rho/(rho - 1))*(-gamma*l*rho + gamma*l - gamma*pi*rho + gamma*pi - l*rho - pi*rho)/(gamma*mu)


    I only part I will integrate is



    MainPart = x**(-rho/(rho - 1))

    IntegMainPart=sympy.integrate(MainPart)


    and rest are only parameters and they will be



    Rest=alpha*(-gamma*l*rho + gamma*l - gamma*pi*rho + gamma*pi - l*rho - pi*rho)/(gamma*mu)


    So is it possible that i can take only important part and integrate it and than multiple with rest like



    IntegMainPart*Rest


    ?










    share|improve this question


























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I want to integrate complex functions with sympy.integrate. I realized that it takes too much time (at least I stopped process after 2.5 hours).



      I am planning to give an equation to the program as simply as possible.
      Lets assume I have a function :



      alpha*x**(-rho/(rho - 1))*(-gamma*l*rho + gamma*l - gamma*pi*rho + gamma*pi - l*rho - pi*rho)/(gamma*mu)


      I only part I will integrate is



      MainPart = x**(-rho/(rho - 1))

      IntegMainPart=sympy.integrate(MainPart)


      and rest are only parameters and they will be



      Rest=alpha*(-gamma*l*rho + gamma*l - gamma*pi*rho + gamma*pi - l*rho - pi*rho)/(gamma*mu)


      So is it possible that i can take only important part and integrate it and than multiple with rest like



      IntegMainPart*Rest


      ?










      share|improve this question















      I want to integrate complex functions with sympy.integrate. I realized that it takes too much time (at least I stopped process after 2.5 hours).



      I am planning to give an equation to the program as simply as possible.
      Lets assume I have a function :



      alpha*x**(-rho/(rho - 1))*(-gamma*l*rho + gamma*l - gamma*pi*rho + gamma*pi - l*rho - pi*rho)/(gamma*mu)


      I only part I will integrate is



      MainPart = x**(-rho/(rho - 1))

      IntegMainPart=sympy.integrate(MainPart)


      and rest are only parameters and they will be



      Rest=alpha*(-gamma*l*rho + gamma*l - gamma*pi*rho + gamma*pi - l*rho - pi*rho)/(gamma*mu)


      So is it possible that i can take only important part and integrate it and than multiple with rest like



      IntegMainPart*Rest


      ?







      python sympy






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 4 at 14:47









      Welcome to Stack Overflow

      25.7k92646




      25.7k92646










      asked Nov 4 at 9:59









      i2_

      4817




      4817
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          SymPy is capable of correctly handling the factors that do not involve the variable of integration. You should not need to remove them manually. Here is how this integral works for me.



          from sympy import symbols, pi, integrate
          x, alpha, gamma, mu, rho, l = symbols('x, alpha, gamma, mu, rho, l')
          expr = alpha*x**(-rho/(rho - 1))*(-gamma*l*rho + gamma*l - gamma*pi*rho + gamma*pi - l*rho - pi*rho)/(gamma*mu)
          print(integrate(expr, x))


          SymPy 1.3 prints the integral at once.



          alpha*x**(-rho/(rho - 1) + 1)*(-gamma*l*rho + gamma*l - pi*gamma*rho + pi*gamma - l*rho - pi*rho)/(gamma*mu*(-rho/(rho - 1) + 1))





          share|improve this answer





















            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            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',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            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%2fstackoverflow.com%2fquestions%2f53139574%2fintegrate-a-sympy-expression-with-a-complex-factor-which-does-not-involve-x%23new-answer', 'question_page');
            }
            );

            Post as a guest
































            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote













            SymPy is capable of correctly handling the factors that do not involve the variable of integration. You should not need to remove them manually. Here is how this integral works for me.



            from sympy import symbols, pi, integrate
            x, alpha, gamma, mu, rho, l = symbols('x, alpha, gamma, mu, rho, l')
            expr = alpha*x**(-rho/(rho - 1))*(-gamma*l*rho + gamma*l - gamma*pi*rho + gamma*pi - l*rho - pi*rho)/(gamma*mu)
            print(integrate(expr, x))


            SymPy 1.3 prints the integral at once.



            alpha*x**(-rho/(rho - 1) + 1)*(-gamma*l*rho + gamma*l - pi*gamma*rho + pi*gamma - l*rho - pi*rho)/(gamma*mu*(-rho/(rho - 1) + 1))





            share|improve this answer

























              up vote
              0
              down vote













              SymPy is capable of correctly handling the factors that do not involve the variable of integration. You should not need to remove them manually. Here is how this integral works for me.



              from sympy import symbols, pi, integrate
              x, alpha, gamma, mu, rho, l = symbols('x, alpha, gamma, mu, rho, l')
              expr = alpha*x**(-rho/(rho - 1))*(-gamma*l*rho + gamma*l - gamma*pi*rho + gamma*pi - l*rho - pi*rho)/(gamma*mu)
              print(integrate(expr, x))


              SymPy 1.3 prints the integral at once.



              alpha*x**(-rho/(rho - 1) + 1)*(-gamma*l*rho + gamma*l - pi*gamma*rho + pi*gamma - l*rho - pi*rho)/(gamma*mu*(-rho/(rho - 1) + 1))





              share|improve this answer























                up vote
                0
                down vote










                up vote
                0
                down vote









                SymPy is capable of correctly handling the factors that do not involve the variable of integration. You should not need to remove them manually. Here is how this integral works for me.



                from sympy import symbols, pi, integrate
                x, alpha, gamma, mu, rho, l = symbols('x, alpha, gamma, mu, rho, l')
                expr = alpha*x**(-rho/(rho - 1))*(-gamma*l*rho + gamma*l - gamma*pi*rho + gamma*pi - l*rho - pi*rho)/(gamma*mu)
                print(integrate(expr, x))


                SymPy 1.3 prints the integral at once.



                alpha*x**(-rho/(rho - 1) + 1)*(-gamma*l*rho + gamma*l - pi*gamma*rho + pi*gamma - l*rho - pi*rho)/(gamma*mu*(-rho/(rho - 1) + 1))





                share|improve this answer












                SymPy is capable of correctly handling the factors that do not involve the variable of integration. You should not need to remove them manually. Here is how this integral works for me.



                from sympy import symbols, pi, integrate
                x, alpha, gamma, mu, rho, l = symbols('x, alpha, gamma, mu, rho, l')
                expr = alpha*x**(-rho/(rho - 1))*(-gamma*l*rho + gamma*l - gamma*pi*rho + gamma*pi - l*rho - pi*rho)/(gamma*mu)
                print(integrate(expr, x))


                SymPy 1.3 prints the integral at once.



                alpha*x**(-rho/(rho - 1) + 1)*(-gamma*l*rho + gamma*l - pi*gamma*rho + pi*gamma - l*rho - pi*rho)/(gamma*mu*(-rho/(rho - 1) + 1))






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 4 at 14:46









                Welcome to Stack Overflow

                25.7k92646




                25.7k92646






























                     

                    draft saved


                    draft discarded



















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53139574%2fintegrate-a-sympy-expression-with-a-complex-factor-which-does-not-involve-x%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest




















































































                    這個網誌中的熱門文章

                    Tangent Lines Diagram Along Smooth Curve

                    Yusuf al-Mu'taman ibn Hud

                    Zucchini