Solve piecewise function

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite
1












I have two piecewise function



equ1 = Piecewise[0.524324 + 0.0376478x, 0.639464 <= x <= 0.839322]
equ2 = Piecewise[-0.506432 + 1.48068x, 0.658914 <= x <= 0.77085]


Now, I am trying to solve equ1 = equ2.



Firstly I tried FindRoot:



FindRoot[equ1 == equ2, x]


But the output is x = 0. I can only get the correct answer by set search starting point 0.7. How can I direct get the answer without set starting point?



Secondly, I tried code Reduce:



Reduce[equ1 == equ2, x]


However, the error appear. The good news is Reduce do provide the correct answer for my equation. The error is:



Reduce::ratnz: Reduce was unable to solve the system with inexact coefficients. The answer was obtained by solving a corresponding exact system and numericizing the result.


Do I have other way to solve those two piecewise function?










share|improve this question



















  • 2




    What's wrong with Solve[0.524324 + 0.0376478 x == -0.506432 + 1.48068 x, x]? or even FindRoot[equ1 == equ2, x, .7]?
    – AccidentalFourierTransform
    5 hours ago







  • 1




    Try to plot then you see where is root.Plot[equ1 - equ2, x, 1/2, 1], FindRoot[equ1 == equ2, x, 7/10].
    – Mariusz Iwaniuk
    5 hours ago






  • 1




    Because at later stages, I need to compara 100 equations to find out solution. It is not possible to set the starting value for each one of them.
    – Yubao Deng
    4 hours ago






  • 1




    Your Reduce command works for me. The message is just a warning, not an error.
    – Michael E2
    3 hours ago














up vote
1
down vote

favorite
1












I have two piecewise function



equ1 = Piecewise[0.524324 + 0.0376478x, 0.639464 <= x <= 0.839322]
equ2 = Piecewise[-0.506432 + 1.48068x, 0.658914 <= x <= 0.77085]


Now, I am trying to solve equ1 = equ2.



Firstly I tried FindRoot:



FindRoot[equ1 == equ2, x]


But the output is x = 0. I can only get the correct answer by set search starting point 0.7. How can I direct get the answer without set starting point?



Secondly, I tried code Reduce:



Reduce[equ1 == equ2, x]


However, the error appear. The good news is Reduce do provide the correct answer for my equation. The error is:



Reduce::ratnz: Reduce was unable to solve the system with inexact coefficients. The answer was obtained by solving a corresponding exact system and numericizing the result.


Do I have other way to solve those two piecewise function?










share|improve this question



















  • 2




    What's wrong with Solve[0.524324 + 0.0376478 x == -0.506432 + 1.48068 x, x]? or even FindRoot[equ1 == equ2, x, .7]?
    – AccidentalFourierTransform
    5 hours ago







  • 1




    Try to plot then you see where is root.Plot[equ1 - equ2, x, 1/2, 1], FindRoot[equ1 == equ2, x, 7/10].
    – Mariusz Iwaniuk
    5 hours ago






  • 1




    Because at later stages, I need to compara 100 equations to find out solution. It is not possible to set the starting value for each one of them.
    – Yubao Deng
    4 hours ago






  • 1




    Your Reduce command works for me. The message is just a warning, not an error.
    – Michael E2
    3 hours ago












up vote
1
down vote

favorite
1









up vote
1
down vote

favorite
1






1





I have two piecewise function



equ1 = Piecewise[0.524324 + 0.0376478x, 0.639464 <= x <= 0.839322]
equ2 = Piecewise[-0.506432 + 1.48068x, 0.658914 <= x <= 0.77085]


Now, I am trying to solve equ1 = equ2.



Firstly I tried FindRoot:



FindRoot[equ1 == equ2, x]


But the output is x = 0. I can only get the correct answer by set search starting point 0.7. How can I direct get the answer without set starting point?



Secondly, I tried code Reduce:



Reduce[equ1 == equ2, x]


However, the error appear. The good news is Reduce do provide the correct answer for my equation. The error is:



Reduce::ratnz: Reduce was unable to solve the system with inexact coefficients. The answer was obtained by solving a corresponding exact system and numericizing the result.


Do I have other way to solve those two piecewise function?










share|improve this question















I have two piecewise function



equ1 = Piecewise[0.524324 + 0.0376478x, 0.639464 <= x <= 0.839322]
equ2 = Piecewise[-0.506432 + 1.48068x, 0.658914 <= x <= 0.77085]


Now, I am trying to solve equ1 = equ2.



Firstly I tried FindRoot:



FindRoot[equ1 == equ2, x]


But the output is x = 0. I can only get the correct answer by set search starting point 0.7. How can I direct get the answer without set starting point?



Secondly, I tried code Reduce:



Reduce[equ1 == equ2, x]


However, the error appear. The good news is Reduce do provide the correct answer for my equation. The error is:



Reduce::ratnz: Reduce was unable to solve the system with inexact coefficients. The answer was obtained by solving a corresponding exact system and numericizing the result.


Do I have other way to solve those two piecewise function?







equation-solving error piecewise






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 3 hours ago









Michael E2

142k11192458




142k11192458










asked 5 hours ago









Yubao Deng

613




613







  • 2




    What's wrong with Solve[0.524324 + 0.0376478 x == -0.506432 + 1.48068 x, x]? or even FindRoot[equ1 == equ2, x, .7]?
    – AccidentalFourierTransform
    5 hours ago







  • 1




    Try to plot then you see where is root.Plot[equ1 - equ2, x, 1/2, 1], FindRoot[equ1 == equ2, x, 7/10].
    – Mariusz Iwaniuk
    5 hours ago






  • 1




    Because at later stages, I need to compara 100 equations to find out solution. It is not possible to set the starting value for each one of them.
    – Yubao Deng
    4 hours ago






  • 1




    Your Reduce command works for me. The message is just a warning, not an error.
    – Michael E2
    3 hours ago












  • 2




    What's wrong with Solve[0.524324 + 0.0376478 x == -0.506432 + 1.48068 x, x]? or even FindRoot[equ1 == equ2, x, .7]?
    – AccidentalFourierTransform
    5 hours ago







  • 1




    Try to plot then you see where is root.Plot[equ1 - equ2, x, 1/2, 1], FindRoot[equ1 == equ2, x, 7/10].
    – Mariusz Iwaniuk
    5 hours ago






  • 1




    Because at later stages, I need to compara 100 equations to find out solution. It is not possible to set the starting value for each one of them.
    – Yubao Deng
    4 hours ago






  • 1




    Your Reduce command works for me. The message is just a warning, not an error.
    – Michael E2
    3 hours ago







2




2




What's wrong with Solve[0.524324 + 0.0376478 x == -0.506432 + 1.48068 x, x]? or even FindRoot[equ1 == equ2, x, .7]?
– AccidentalFourierTransform
5 hours ago





What's wrong with Solve[0.524324 + 0.0376478 x == -0.506432 + 1.48068 x, x]? or even FindRoot[equ1 == equ2, x, .7]?
– AccidentalFourierTransform
5 hours ago





1




1




Try to plot then you see where is root.Plot[equ1 - equ2, x, 1/2, 1], FindRoot[equ1 == equ2, x, 7/10].
– Mariusz Iwaniuk
5 hours ago




Try to plot then you see where is root.Plot[equ1 - equ2, x, 1/2, 1], FindRoot[equ1 == equ2, x, 7/10].
– Mariusz Iwaniuk
5 hours ago




1




1




Because at later stages, I need to compara 100 equations to find out solution. It is not possible to set the starting value for each one of them.
– Yubao Deng
4 hours ago




Because at later stages, I need to compara 100 equations to find out solution. It is not possible to set the starting value for each one of them.
– Yubao Deng
4 hours ago




1




1




Your Reduce command works for me. The message is just a warning, not an error.
– Michael E2
3 hours ago




Your Reduce command works for me. The message is just a warning, not an error.
– Michael E2
3 hours ago










3 Answers
3






active

oldest

votes

















up vote
1
down vote













equ1 = Rationalize[
Piecewise[0.524324 + 0.0376478 x, 0.639464 <= x <= 0.839322]]
equ2 = Rationalize[
Piecewise[-0.506432 + 1.48068 x, 0.658914 <= x <= 0.77085]]
Reduce[equ1 == equ2, x]
x == 0.714299 || x < 79933/125000 || x > 419661/500000





share|improve this answer



























    up vote
    1
    down vote













    Either:



    FindRoot[equ1 == equ2, x, 0.7, 0.639464, 0.839322]
    (* x -> 0.714299 *)


    Or:



    NSolve[equ1 == equ2 && 0.639464 <= x <= 0.839322, x]



    NSolve::ratnz:.... [Unimportant warning.]




    (* x -> 0.714299 *)





    share|improve this answer



























      up vote
      1
      down vote













      If you have 100 equations and you want to find the unique solution to the whole set and each of your Piecewise are written in exactly the same form as the two you showed and the solution must lie in the intersection of all those inequalities then perhaps



      equ1 = Piecewise[0.524324 + 0.0376478 x, 0.639464 <= x <= 0.839322];
      equ2 = Piecewise[-0.506432 + 1.48068 x, 0.658914 <= x <= 0.77085];
      funs = equ1, equ2;
      Join[Equal @@ Map[#[[1, 1, 1]] &, funs],
      Max[Map[#[[1, 1, 2, 1]] &, funs]] < x < Min[Map[#[[1, 1, 2, 3]] &, funs]]]


      will give you



      0.524324 + 0.0376478 x == -0.506432 + 1.48068 x, 0.658914 < x < 0.77085


      and



      x /. Solve[
      Join[Equal @@ Map[#[[1, 1, 1]] &, funs],
      Max[Map[#[[1, 1, 2, 1]] &, funs]] < x < Min[Map[#[[1, 1, 2, 3]] &, funs]]]
      , x][[1]]


      will give you



      0.714299


      You can make the list of funs longer and longer and still get the solution.



      The Max part of that is extracting all your lower bounds and finding the largest one. The Min part of that is extracting all your upper bounds and finding the smallest one. The Equal part of that is extracting all your equations and setting them equal to each other. We assemble those pieces and give them to Solve.



      You should check carefully to make certain that there will always be one unique solution to your set of equations.



      You might click on Piecewise and then Details in the help pages and read very carefully all the information there. Because you have not given any other information about the value of your functions if x happens to be outside the bounds you have given then the value of that Piecewise function will be zero for x outside those bounds. That might surprise you.






      share|improve this answer






















        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',
        convertImagesToLinks: false,
        noModals: false,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: null,
        bindNavPrevention: true,
        postfix: "",
        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%2f184824%2fsolve-piecewise-function%23new-answer', 'question_page');

        );

        Post as a guest






























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes








        up vote
        1
        down vote













        equ1 = Rationalize[
        Piecewise[0.524324 + 0.0376478 x, 0.639464 <= x <= 0.839322]]
        equ2 = Rationalize[
        Piecewise[-0.506432 + 1.48068 x, 0.658914 <= x <= 0.77085]]
        Reduce[equ1 == equ2, x]
        x == 0.714299 || x < 79933/125000 || x > 419661/500000





        share|improve this answer
























          up vote
          1
          down vote













          equ1 = Rationalize[
          Piecewise[0.524324 + 0.0376478 x, 0.639464 <= x <= 0.839322]]
          equ2 = Rationalize[
          Piecewise[-0.506432 + 1.48068 x, 0.658914 <= x <= 0.77085]]
          Reduce[equ1 == equ2, x]
          x == 0.714299 || x < 79933/125000 || x > 419661/500000





          share|improve this answer






















            up vote
            1
            down vote










            up vote
            1
            down vote









            equ1 = Rationalize[
            Piecewise[0.524324 + 0.0376478 x, 0.639464 <= x <= 0.839322]]
            equ2 = Rationalize[
            Piecewise[-0.506432 + 1.48068 x, 0.658914 <= x <= 0.77085]]
            Reduce[equ1 == equ2, x]
            x == 0.714299 || x < 79933/125000 || x > 419661/500000





            share|improve this answer












            equ1 = Rationalize[
            Piecewise[0.524324 + 0.0376478 x, 0.639464 <= x <= 0.839322]]
            equ2 = Rationalize[
            Piecewise[-0.506432 + 1.48068 x, 0.658914 <= x <= 0.77085]]
            Reduce[equ1 == equ2, x]
            x == 0.714299 || x < 79933/125000 || x > 419661/500000






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 4 hours ago









            Alex Trounev

            3,3001313




            3,3001313




















                up vote
                1
                down vote













                Either:



                FindRoot[equ1 == equ2, x, 0.7, 0.639464, 0.839322]
                (* x -> 0.714299 *)


                Or:



                NSolve[equ1 == equ2 && 0.639464 <= x <= 0.839322, x]



                NSolve::ratnz:.... [Unimportant warning.]




                (* x -> 0.714299 *)





                share|improve this answer
























                  up vote
                  1
                  down vote













                  Either:



                  FindRoot[equ1 == equ2, x, 0.7, 0.639464, 0.839322]
                  (* x -> 0.714299 *)


                  Or:



                  NSolve[equ1 == equ2 && 0.639464 <= x <= 0.839322, x]



                  NSolve::ratnz:.... [Unimportant warning.]




                  (* x -> 0.714299 *)





                  share|improve this answer






















                    up vote
                    1
                    down vote










                    up vote
                    1
                    down vote









                    Either:



                    FindRoot[equ1 == equ2, x, 0.7, 0.639464, 0.839322]
                    (* x -> 0.714299 *)


                    Or:



                    NSolve[equ1 == equ2 && 0.639464 <= x <= 0.839322, x]



                    NSolve::ratnz:.... [Unimportant warning.]




                    (* x -> 0.714299 *)





                    share|improve this answer












                    Either:



                    FindRoot[equ1 == equ2, x, 0.7, 0.639464, 0.839322]
                    (* x -> 0.714299 *)


                    Or:



                    NSolve[equ1 == equ2 && 0.639464 <= x <= 0.839322, x]



                    NSolve::ratnz:.... [Unimportant warning.]




                    (* x -> 0.714299 *)






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered 4 hours ago









                    Michael E2

                    142k11192458




                    142k11192458




















                        up vote
                        1
                        down vote













                        If you have 100 equations and you want to find the unique solution to the whole set and each of your Piecewise are written in exactly the same form as the two you showed and the solution must lie in the intersection of all those inequalities then perhaps



                        equ1 = Piecewise[0.524324 + 0.0376478 x, 0.639464 <= x <= 0.839322];
                        equ2 = Piecewise[-0.506432 + 1.48068 x, 0.658914 <= x <= 0.77085];
                        funs = equ1, equ2;
                        Join[Equal @@ Map[#[[1, 1, 1]] &, funs],
                        Max[Map[#[[1, 1, 2, 1]] &, funs]] < x < Min[Map[#[[1, 1, 2, 3]] &, funs]]]


                        will give you



                        0.524324 + 0.0376478 x == -0.506432 + 1.48068 x, 0.658914 < x < 0.77085


                        and



                        x /. Solve[
                        Join[Equal @@ Map[#[[1, 1, 1]] &, funs],
                        Max[Map[#[[1, 1, 2, 1]] &, funs]] < x < Min[Map[#[[1, 1, 2, 3]] &, funs]]]
                        , x][[1]]


                        will give you



                        0.714299


                        You can make the list of funs longer and longer and still get the solution.



                        The Max part of that is extracting all your lower bounds and finding the largest one. The Min part of that is extracting all your upper bounds and finding the smallest one. The Equal part of that is extracting all your equations and setting them equal to each other. We assemble those pieces and give them to Solve.



                        You should check carefully to make certain that there will always be one unique solution to your set of equations.



                        You might click on Piecewise and then Details in the help pages and read very carefully all the information there. Because you have not given any other information about the value of your functions if x happens to be outside the bounds you have given then the value of that Piecewise function will be zero for x outside those bounds. That might surprise you.






                        share|improve this answer


























                          up vote
                          1
                          down vote













                          If you have 100 equations and you want to find the unique solution to the whole set and each of your Piecewise are written in exactly the same form as the two you showed and the solution must lie in the intersection of all those inequalities then perhaps



                          equ1 = Piecewise[0.524324 + 0.0376478 x, 0.639464 <= x <= 0.839322];
                          equ2 = Piecewise[-0.506432 + 1.48068 x, 0.658914 <= x <= 0.77085];
                          funs = equ1, equ2;
                          Join[Equal @@ Map[#[[1, 1, 1]] &, funs],
                          Max[Map[#[[1, 1, 2, 1]] &, funs]] < x < Min[Map[#[[1, 1, 2, 3]] &, funs]]]


                          will give you



                          0.524324 + 0.0376478 x == -0.506432 + 1.48068 x, 0.658914 < x < 0.77085


                          and



                          x /. Solve[
                          Join[Equal @@ Map[#[[1, 1, 1]] &, funs],
                          Max[Map[#[[1, 1, 2, 1]] &, funs]] < x < Min[Map[#[[1, 1, 2, 3]] &, funs]]]
                          , x][[1]]


                          will give you



                          0.714299


                          You can make the list of funs longer and longer and still get the solution.



                          The Max part of that is extracting all your lower bounds and finding the largest one. The Min part of that is extracting all your upper bounds and finding the smallest one. The Equal part of that is extracting all your equations and setting them equal to each other. We assemble those pieces and give them to Solve.



                          You should check carefully to make certain that there will always be one unique solution to your set of equations.



                          You might click on Piecewise and then Details in the help pages and read very carefully all the information there. Because you have not given any other information about the value of your functions if x happens to be outside the bounds you have given then the value of that Piecewise function will be zero for x outside those bounds. That might surprise you.






                          share|improve this answer
























                            up vote
                            1
                            down vote










                            up vote
                            1
                            down vote









                            If you have 100 equations and you want to find the unique solution to the whole set and each of your Piecewise are written in exactly the same form as the two you showed and the solution must lie in the intersection of all those inequalities then perhaps



                            equ1 = Piecewise[0.524324 + 0.0376478 x, 0.639464 <= x <= 0.839322];
                            equ2 = Piecewise[-0.506432 + 1.48068 x, 0.658914 <= x <= 0.77085];
                            funs = equ1, equ2;
                            Join[Equal @@ Map[#[[1, 1, 1]] &, funs],
                            Max[Map[#[[1, 1, 2, 1]] &, funs]] < x < Min[Map[#[[1, 1, 2, 3]] &, funs]]]


                            will give you



                            0.524324 + 0.0376478 x == -0.506432 + 1.48068 x, 0.658914 < x < 0.77085


                            and



                            x /. Solve[
                            Join[Equal @@ Map[#[[1, 1, 1]] &, funs],
                            Max[Map[#[[1, 1, 2, 1]] &, funs]] < x < Min[Map[#[[1, 1, 2, 3]] &, funs]]]
                            , x][[1]]


                            will give you



                            0.714299


                            You can make the list of funs longer and longer and still get the solution.



                            The Max part of that is extracting all your lower bounds and finding the largest one. The Min part of that is extracting all your upper bounds and finding the smallest one. The Equal part of that is extracting all your equations and setting them equal to each other. We assemble those pieces and give them to Solve.



                            You should check carefully to make certain that there will always be one unique solution to your set of equations.



                            You might click on Piecewise and then Details in the help pages and read very carefully all the information there. Because you have not given any other information about the value of your functions if x happens to be outside the bounds you have given then the value of that Piecewise function will be zero for x outside those bounds. That might surprise you.






                            share|improve this answer














                            If you have 100 equations and you want to find the unique solution to the whole set and each of your Piecewise are written in exactly the same form as the two you showed and the solution must lie in the intersection of all those inequalities then perhaps



                            equ1 = Piecewise[0.524324 + 0.0376478 x, 0.639464 <= x <= 0.839322];
                            equ2 = Piecewise[-0.506432 + 1.48068 x, 0.658914 <= x <= 0.77085];
                            funs = equ1, equ2;
                            Join[Equal @@ Map[#[[1, 1, 1]] &, funs],
                            Max[Map[#[[1, 1, 2, 1]] &, funs]] < x < Min[Map[#[[1, 1, 2, 3]] &, funs]]]


                            will give you



                            0.524324 + 0.0376478 x == -0.506432 + 1.48068 x, 0.658914 < x < 0.77085


                            and



                            x /. Solve[
                            Join[Equal @@ Map[#[[1, 1, 1]] &, funs],
                            Max[Map[#[[1, 1, 2, 1]] &, funs]] < x < Min[Map[#[[1, 1, 2, 3]] &, funs]]]
                            , x][[1]]


                            will give you



                            0.714299


                            You can make the list of funs longer and longer and still get the solution.



                            The Max part of that is extracting all your lower bounds and finding the largest one. The Min part of that is extracting all your upper bounds and finding the smallest one. The Equal part of that is extracting all your equations and setting them equal to each other. We assemble those pieces and give them to Solve.



                            You should check carefully to make certain that there will always be one unique solution to your set of equations.



                            You might click on Piecewise and then Details in the help pages and read very carefully all the information there. Because you have not given any other information about the value of your functions if x happens to be outside the bounds you have given then the value of that Piecewise function will be zero for x outside those bounds. That might surprise you.







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited 3 hours ago

























                            answered 3 hours ago









                            Bill

                            5,15058




                            5,15058



























                                 

                                draft saved


                                draft discarded















































                                 


                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function ()
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f184824%2fsolve-piecewise-function%23new-answer', 'question_page');

                                );

                                Post as a guest













































































                                Comments

                                Popular posts from this blog

                                Long meetings (6-7 hours a day): Being “babysat” by supervisor

                                Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

                                Confectionery