Simple Differential Equation in Matlab and Wolfram get two different answer?A simple second order differential equationTwo Matlab ODE solvers, two different resultssolving system of ordinary differential equation with ODE solver of matlabSolution to Basic ODE using Matlab?Two couple equation first order Runge Kutta Matlab troubles?Differential Equation and MatlabIs this differential equation solvable in MATLAB?Formulating a linear difference equation model and some MatLab tipsAnalyzing a population governed by a nonlinear difference equation and matlab (Hassel's model)Calculating value of $textsinc(x)$, WolframAlpha and MATLAB give two different answers.

Why does the negative sign arise in this thermodynamic relation?

Does the nature of the Apocalypse in The Umbrella Academy change from the first to the last episode?

Can Mathematica be used to create an Artistic 3D extrusion from a 2D image and wrap a line pattern around it?

When traveling to Europe from North America, do I need to purchase a different power strip?

What's the "normal" opposite of flautando?

How is the wildcard * interpreted as a command?

Single word request: Harming the benefactor

Recommendation letter by significant other if you worked with them professionally?

Plausibility of Mushroom Buildings

Find longest word in a string: are any of these algorithms good?

Can you reject a postdoc offer after the PI has paid a large sum for flights/accommodation for your visit?

Signed and unsigned numbers

Conservation of Mass and Energy

Could you please stop shuffling the deck and play already?

Do f-stop and exposure time perfectly cancel?

Is it necessary to separate DC power cables and data cables?

Makefile strange variable substitution

Why the color red for the Republican Party

Can one live in the U.S. and not use a credit card?

Difference on montgomery curve equation between EFD and RFC7748

Why does Captain Marvel assume the people on this planet know this?

How to detect if C code (which needs 'extern C') is compiled in C++

What are actual Tesla M60 models used by AWS?

Motivation for Zeta Function of an Algebraic Variety



Simple Differential Equation in Matlab and Wolfram get two different answer?


A simple second order differential equationTwo Matlab ODE solvers, two different resultssolving system of ordinary differential equation with ODE solver of matlabSolution to Basic ODE using Matlab?Two couple equation first order Runge Kutta Matlab troubles?Differential Equation and MatlabIs this differential equation solvable in MATLAB?Formulating a linear difference equation model and some MatLab tipsAnalyzing a population governed by a nonlinear difference equation and matlab (Hassel's model)Calculating value of $textsinc(x)$, WolframAlpha and MATLAB give two different answers.













0












$begingroup$


I'm a beginner in using Matlab. if I have a DE like



$$x'(t)=frac1sin (2x)$$



How I can Implement in Matlab to calculate just answer?



I try dsolve like as:



ySol(t) = dsolve(ode,cond)
but couldn't define ode, and cond.



Update: this is my matlab:
enter image description here



and different answer from Wolfram:



enter image description here










share|cite|improve this question











$endgroup$
















    0












    $begingroup$


    I'm a beginner in using Matlab. if I have a DE like



    $$x'(t)=frac1sin (2x)$$



    How I can Implement in Matlab to calculate just answer?



    I try dsolve like as:



    ySol(t) = dsolve(ode,cond)
    but couldn't define ode, and cond.



    Update: this is my matlab:
    enter image description here



    and different answer from Wolfram:



    enter image description here










    share|cite|improve this question











    $endgroup$














      0












      0








      0





      $begingroup$


      I'm a beginner in using Matlab. if I have a DE like



      $$x'(t)=frac1sin (2x)$$



      How I can Implement in Matlab to calculate just answer?



      I try dsolve like as:



      ySol(t) = dsolve(ode,cond)
      but couldn't define ode, and cond.



      Update: this is my matlab:
      enter image description here



      and different answer from Wolfram:



      enter image description here










      share|cite|improve this question











      $endgroup$




      I'm a beginner in using Matlab. if I have a DE like



      $$x'(t)=frac1sin (2x)$$



      How I can Implement in Matlab to calculate just answer?



      I try dsolve like as:



      ySol(t) = dsolve(ode,cond)
      but couldn't define ode, and cond.



      Update: this is my matlab:
      enter image description here



      and different answer from Wolfram:



      enter image description here







      ordinary-differential-equations matlab wolfram-alpha






      share|cite|improve this question















      share|cite|improve this question













      share|cite|improve this question




      share|cite|improve this question








      edited Mar 7 at 8:36









      Dylan

      13.7k31027




      13.7k31027










      asked Mar 6 at 23:05









      user355834user355834

      416




      416




















          2 Answers
          2






          active

          oldest

          votes


















          2












          $begingroup$

          These are the same answer. Separate to get



          $$ sin(2x) dx = dt $$



          There are two ways to do this. The first is to integrate directly:



          $$ -frac12cos(2x) = t + c_1 $$
          $$ cos(2x) = -2(t+c_1) $$
          $$ x = frac12 arccos(-2(t+c_1)) $$



          This is the answer given by Wolfram.



          The second way is to use the double-angle formula



          $$ 2sin(x)cos(x) dx = dt $$



          $$ sin^2(x) = t + c_2 $$



          $$ sin (x) = sqrtt+c_2 $$



          $$ x = arcsin(sqrtt+c_2) $$



          This is the answer given by MATLAB.



          If you're wondering why there two different anti-derivatives of $sin(2x)$, it's because they differ by a constant



          $$ sin^2 x = -frac12cos (2x) + frac12 $$






          share|cite|improve this answer











          $endgroup$












          • $begingroup$
            [+1] Very didactic answer. Two points are still puzzling for me 1) On the asker side : an initial condition $x(0)=1$ has been introduced. Why ? 2) On the answerer side : why don't you consider as well $sin(x)=-sqrtt+c_2$ ?
            $endgroup$
            – Jean Marie
            Mar 7 at 8:54










          • $begingroup$
            @JeanMarie 1) MATLAB requires an initial condition to solve the problem, so I assumed $x(0)=1$ was put in there as a placeholder. 2) I didn't feel like going into details, since the point was just to illustrate that the 2 answers are more or less equivalent. If you want to be pedantic, the sign of the square root depends on the initial condition given.
            $endgroup$
            – Dylan
            Mar 7 at 8:59











          • $begingroup$
            Why do you use the adjective "pedantic" ? Conventionally, working with real numbers, symbol $sqrt...$ designates a positive quantity, and $-sqrt...$ is for a negative quantity which is different.
            $endgroup$
            – Jean Marie
            Mar 7 at 9:09










          • $begingroup$
            @JeanMarie You take the positive $sqrtcdots$ if the initial condition is positive and the negative $-sqrtcdots$ if the initial condition is negative.
            $endgroup$
            – Dylan
            Mar 7 at 9:18



















          1












          $begingroup$

          A (Matlab oriented) complement to the very didactic answer by @Dylan.



          Here is an extension of your program displaying either two or one solution(s). I use some Matlab instructions that may be new to you, in particular with a symbolic initial value $a$ (you had fixed this initial value to $a=1$) that can be constrained to be positive. The first part is with symbolic variables, almost the same as yours ; the second part uses numerical variables in order to see what happens for different values of $a$:



          clear all;close all;
          syms x(t) a
          ode=diff(x)==1/sin(2*x); % no need to take diff(x,t)...
          cond=x(0)==a; % a instead of 1
          %assume(a>0)
          s=dsolve(ode,cond) : % one or two solutions
          %%%
          T=0:0.01:0.7;
          for a=0:0.1:pi/2
          g=inline(s(1));plot(T,real(g(a,T)),'r');hold on;
          g=inline(s(2));plot(T,real(g(a,T)),'b');hold on;% to be suppressed if a>0
          end;


          The answer(s) given by Matlab are :



          s =



          asin((sin(a)^2 + t)^(1/2))



          -asin((sin(a)^2 + t)^(1/2))



          Which one is the good one ?... Both...



          If we introduce "assume(a>0)", Matlab gives a single answer which is the first one.



          Other analytical facts could be commented (for example the domains of existence of solutions), but I think the asker will be satisfied with the details already given.



          enter image description here






          share|cite|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: "69"
            ;
            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: 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
            ,
            noCode: true, onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3138221%2fsimple-differential-equation-in-matlab-and-wolfram-get-two-different-answer%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









            2












            $begingroup$

            These are the same answer. Separate to get



            $$ sin(2x) dx = dt $$



            There are two ways to do this. The first is to integrate directly:



            $$ -frac12cos(2x) = t + c_1 $$
            $$ cos(2x) = -2(t+c_1) $$
            $$ x = frac12 arccos(-2(t+c_1)) $$



            This is the answer given by Wolfram.



            The second way is to use the double-angle formula



            $$ 2sin(x)cos(x) dx = dt $$



            $$ sin^2(x) = t + c_2 $$



            $$ sin (x) = sqrtt+c_2 $$



            $$ x = arcsin(sqrtt+c_2) $$



            This is the answer given by MATLAB.



            If you're wondering why there two different anti-derivatives of $sin(2x)$, it's because they differ by a constant



            $$ sin^2 x = -frac12cos (2x) + frac12 $$






            share|cite|improve this answer











            $endgroup$












            • $begingroup$
              [+1] Very didactic answer. Two points are still puzzling for me 1) On the asker side : an initial condition $x(0)=1$ has been introduced. Why ? 2) On the answerer side : why don't you consider as well $sin(x)=-sqrtt+c_2$ ?
              $endgroup$
              – Jean Marie
              Mar 7 at 8:54










            • $begingroup$
              @JeanMarie 1) MATLAB requires an initial condition to solve the problem, so I assumed $x(0)=1$ was put in there as a placeholder. 2) I didn't feel like going into details, since the point was just to illustrate that the 2 answers are more or less equivalent. If you want to be pedantic, the sign of the square root depends on the initial condition given.
              $endgroup$
              – Dylan
              Mar 7 at 8:59











            • $begingroup$
              Why do you use the adjective "pedantic" ? Conventionally, working with real numbers, symbol $sqrt...$ designates a positive quantity, and $-sqrt...$ is for a negative quantity which is different.
              $endgroup$
              – Jean Marie
              Mar 7 at 9:09










            • $begingroup$
              @JeanMarie You take the positive $sqrtcdots$ if the initial condition is positive and the negative $-sqrtcdots$ if the initial condition is negative.
              $endgroup$
              – Dylan
              Mar 7 at 9:18
















            2












            $begingroup$

            These are the same answer. Separate to get



            $$ sin(2x) dx = dt $$



            There are two ways to do this. The first is to integrate directly:



            $$ -frac12cos(2x) = t + c_1 $$
            $$ cos(2x) = -2(t+c_1) $$
            $$ x = frac12 arccos(-2(t+c_1)) $$



            This is the answer given by Wolfram.



            The second way is to use the double-angle formula



            $$ 2sin(x)cos(x) dx = dt $$



            $$ sin^2(x) = t + c_2 $$



            $$ sin (x) = sqrtt+c_2 $$



            $$ x = arcsin(sqrtt+c_2) $$



            This is the answer given by MATLAB.



            If you're wondering why there two different anti-derivatives of $sin(2x)$, it's because they differ by a constant



            $$ sin^2 x = -frac12cos (2x) + frac12 $$






            share|cite|improve this answer











            $endgroup$












            • $begingroup$
              [+1] Very didactic answer. Two points are still puzzling for me 1) On the asker side : an initial condition $x(0)=1$ has been introduced. Why ? 2) On the answerer side : why don't you consider as well $sin(x)=-sqrtt+c_2$ ?
              $endgroup$
              – Jean Marie
              Mar 7 at 8:54










            • $begingroup$
              @JeanMarie 1) MATLAB requires an initial condition to solve the problem, so I assumed $x(0)=1$ was put in there as a placeholder. 2) I didn't feel like going into details, since the point was just to illustrate that the 2 answers are more or less equivalent. If you want to be pedantic, the sign of the square root depends on the initial condition given.
              $endgroup$
              – Dylan
              Mar 7 at 8:59











            • $begingroup$
              Why do you use the adjective "pedantic" ? Conventionally, working with real numbers, symbol $sqrt...$ designates a positive quantity, and $-sqrt...$ is for a negative quantity which is different.
              $endgroup$
              – Jean Marie
              Mar 7 at 9:09










            • $begingroup$
              @JeanMarie You take the positive $sqrtcdots$ if the initial condition is positive and the negative $-sqrtcdots$ if the initial condition is negative.
              $endgroup$
              – Dylan
              Mar 7 at 9:18














            2












            2








            2





            $begingroup$

            These are the same answer. Separate to get



            $$ sin(2x) dx = dt $$



            There are two ways to do this. The first is to integrate directly:



            $$ -frac12cos(2x) = t + c_1 $$
            $$ cos(2x) = -2(t+c_1) $$
            $$ x = frac12 arccos(-2(t+c_1)) $$



            This is the answer given by Wolfram.



            The second way is to use the double-angle formula



            $$ 2sin(x)cos(x) dx = dt $$



            $$ sin^2(x) = t + c_2 $$



            $$ sin (x) = sqrtt+c_2 $$



            $$ x = arcsin(sqrtt+c_2) $$



            This is the answer given by MATLAB.



            If you're wondering why there two different anti-derivatives of $sin(2x)$, it's because they differ by a constant



            $$ sin^2 x = -frac12cos (2x) + frac12 $$






            share|cite|improve this answer











            $endgroup$



            These are the same answer. Separate to get



            $$ sin(2x) dx = dt $$



            There are two ways to do this. The first is to integrate directly:



            $$ -frac12cos(2x) = t + c_1 $$
            $$ cos(2x) = -2(t+c_1) $$
            $$ x = frac12 arccos(-2(t+c_1)) $$



            This is the answer given by Wolfram.



            The second way is to use the double-angle formula



            $$ 2sin(x)cos(x) dx = dt $$



            $$ sin^2(x) = t + c_2 $$



            $$ sin (x) = sqrtt+c_2 $$



            $$ x = arcsin(sqrtt+c_2) $$



            This is the answer given by MATLAB.



            If you're wondering why there two different anti-derivatives of $sin(2x)$, it's because they differ by a constant



            $$ sin^2 x = -frac12cos (2x) + frac12 $$







            share|cite|improve this answer














            share|cite|improve this answer



            share|cite|improve this answer








            edited Mar 7 at 9:00

























            answered Mar 7 at 8:41









            DylanDylan

            13.7k31027




            13.7k31027











            • $begingroup$
              [+1] Very didactic answer. Two points are still puzzling for me 1) On the asker side : an initial condition $x(0)=1$ has been introduced. Why ? 2) On the answerer side : why don't you consider as well $sin(x)=-sqrtt+c_2$ ?
              $endgroup$
              – Jean Marie
              Mar 7 at 8:54










            • $begingroup$
              @JeanMarie 1) MATLAB requires an initial condition to solve the problem, so I assumed $x(0)=1$ was put in there as a placeholder. 2) I didn't feel like going into details, since the point was just to illustrate that the 2 answers are more or less equivalent. If you want to be pedantic, the sign of the square root depends on the initial condition given.
              $endgroup$
              – Dylan
              Mar 7 at 8:59











            • $begingroup$
              Why do you use the adjective "pedantic" ? Conventionally, working with real numbers, symbol $sqrt...$ designates a positive quantity, and $-sqrt...$ is for a negative quantity which is different.
              $endgroup$
              – Jean Marie
              Mar 7 at 9:09










            • $begingroup$
              @JeanMarie You take the positive $sqrtcdots$ if the initial condition is positive and the negative $-sqrtcdots$ if the initial condition is negative.
              $endgroup$
              – Dylan
              Mar 7 at 9:18

















            • $begingroup$
              [+1] Very didactic answer. Two points are still puzzling for me 1) On the asker side : an initial condition $x(0)=1$ has been introduced. Why ? 2) On the answerer side : why don't you consider as well $sin(x)=-sqrtt+c_2$ ?
              $endgroup$
              – Jean Marie
              Mar 7 at 8:54










            • $begingroup$
              @JeanMarie 1) MATLAB requires an initial condition to solve the problem, so I assumed $x(0)=1$ was put in there as a placeholder. 2) I didn't feel like going into details, since the point was just to illustrate that the 2 answers are more or less equivalent. If you want to be pedantic, the sign of the square root depends on the initial condition given.
              $endgroup$
              – Dylan
              Mar 7 at 8:59











            • $begingroup$
              Why do you use the adjective "pedantic" ? Conventionally, working with real numbers, symbol $sqrt...$ designates a positive quantity, and $-sqrt...$ is for a negative quantity which is different.
              $endgroup$
              – Jean Marie
              Mar 7 at 9:09










            • $begingroup$
              @JeanMarie You take the positive $sqrtcdots$ if the initial condition is positive and the negative $-sqrtcdots$ if the initial condition is negative.
              $endgroup$
              – Dylan
              Mar 7 at 9:18
















            $begingroup$
            [+1] Very didactic answer. Two points are still puzzling for me 1) On the asker side : an initial condition $x(0)=1$ has been introduced. Why ? 2) On the answerer side : why don't you consider as well $sin(x)=-sqrtt+c_2$ ?
            $endgroup$
            – Jean Marie
            Mar 7 at 8:54




            $begingroup$
            [+1] Very didactic answer. Two points are still puzzling for me 1) On the asker side : an initial condition $x(0)=1$ has been introduced. Why ? 2) On the answerer side : why don't you consider as well $sin(x)=-sqrtt+c_2$ ?
            $endgroup$
            – Jean Marie
            Mar 7 at 8:54












            $begingroup$
            @JeanMarie 1) MATLAB requires an initial condition to solve the problem, so I assumed $x(0)=1$ was put in there as a placeholder. 2) I didn't feel like going into details, since the point was just to illustrate that the 2 answers are more or less equivalent. If you want to be pedantic, the sign of the square root depends on the initial condition given.
            $endgroup$
            – Dylan
            Mar 7 at 8:59





            $begingroup$
            @JeanMarie 1) MATLAB requires an initial condition to solve the problem, so I assumed $x(0)=1$ was put in there as a placeholder. 2) I didn't feel like going into details, since the point was just to illustrate that the 2 answers are more or less equivalent. If you want to be pedantic, the sign of the square root depends on the initial condition given.
            $endgroup$
            – Dylan
            Mar 7 at 8:59













            $begingroup$
            Why do you use the adjective "pedantic" ? Conventionally, working with real numbers, symbol $sqrt...$ designates a positive quantity, and $-sqrt...$ is for a negative quantity which is different.
            $endgroup$
            – Jean Marie
            Mar 7 at 9:09




            $begingroup$
            Why do you use the adjective "pedantic" ? Conventionally, working with real numbers, symbol $sqrt...$ designates a positive quantity, and $-sqrt...$ is for a negative quantity which is different.
            $endgroup$
            – Jean Marie
            Mar 7 at 9:09












            $begingroup$
            @JeanMarie You take the positive $sqrtcdots$ if the initial condition is positive and the negative $-sqrtcdots$ if the initial condition is negative.
            $endgroup$
            – Dylan
            Mar 7 at 9:18





            $begingroup$
            @JeanMarie You take the positive $sqrtcdots$ if the initial condition is positive and the negative $-sqrtcdots$ if the initial condition is negative.
            $endgroup$
            – Dylan
            Mar 7 at 9:18












            1












            $begingroup$

            A (Matlab oriented) complement to the very didactic answer by @Dylan.



            Here is an extension of your program displaying either two or one solution(s). I use some Matlab instructions that may be new to you, in particular with a symbolic initial value $a$ (you had fixed this initial value to $a=1$) that can be constrained to be positive. The first part is with symbolic variables, almost the same as yours ; the second part uses numerical variables in order to see what happens for different values of $a$:



            clear all;close all;
            syms x(t) a
            ode=diff(x)==1/sin(2*x); % no need to take diff(x,t)...
            cond=x(0)==a; % a instead of 1
            %assume(a>0)
            s=dsolve(ode,cond) : % one or two solutions
            %%%
            T=0:0.01:0.7;
            for a=0:0.1:pi/2
            g=inline(s(1));plot(T,real(g(a,T)),'r');hold on;
            g=inline(s(2));plot(T,real(g(a,T)),'b');hold on;% to be suppressed if a>0
            end;


            The answer(s) given by Matlab are :



            s =



            asin((sin(a)^2 + t)^(1/2))



            -asin((sin(a)^2 + t)^(1/2))



            Which one is the good one ?... Both...



            If we introduce "assume(a>0)", Matlab gives a single answer which is the first one.



            Other analytical facts could be commented (for example the domains of existence of solutions), but I think the asker will be satisfied with the details already given.



            enter image description here






            share|cite|improve this answer











            $endgroup$

















              1












              $begingroup$

              A (Matlab oriented) complement to the very didactic answer by @Dylan.



              Here is an extension of your program displaying either two or one solution(s). I use some Matlab instructions that may be new to you, in particular with a symbolic initial value $a$ (you had fixed this initial value to $a=1$) that can be constrained to be positive. The first part is with symbolic variables, almost the same as yours ; the second part uses numerical variables in order to see what happens for different values of $a$:



              clear all;close all;
              syms x(t) a
              ode=diff(x)==1/sin(2*x); % no need to take diff(x,t)...
              cond=x(0)==a; % a instead of 1
              %assume(a>0)
              s=dsolve(ode,cond) : % one or two solutions
              %%%
              T=0:0.01:0.7;
              for a=0:0.1:pi/2
              g=inline(s(1));plot(T,real(g(a,T)),'r');hold on;
              g=inline(s(2));plot(T,real(g(a,T)),'b');hold on;% to be suppressed if a>0
              end;


              The answer(s) given by Matlab are :



              s =



              asin((sin(a)^2 + t)^(1/2))



              -asin((sin(a)^2 + t)^(1/2))



              Which one is the good one ?... Both...



              If we introduce "assume(a>0)", Matlab gives a single answer which is the first one.



              Other analytical facts could be commented (for example the domains of existence of solutions), but I think the asker will be satisfied with the details already given.



              enter image description here






              share|cite|improve this answer











              $endgroup$















                1












                1








                1





                $begingroup$

                A (Matlab oriented) complement to the very didactic answer by @Dylan.



                Here is an extension of your program displaying either two or one solution(s). I use some Matlab instructions that may be new to you, in particular with a symbolic initial value $a$ (you had fixed this initial value to $a=1$) that can be constrained to be positive. The first part is with symbolic variables, almost the same as yours ; the second part uses numerical variables in order to see what happens for different values of $a$:



                clear all;close all;
                syms x(t) a
                ode=diff(x)==1/sin(2*x); % no need to take diff(x,t)...
                cond=x(0)==a; % a instead of 1
                %assume(a>0)
                s=dsolve(ode,cond) : % one or two solutions
                %%%
                T=0:0.01:0.7;
                for a=0:0.1:pi/2
                g=inline(s(1));plot(T,real(g(a,T)),'r');hold on;
                g=inline(s(2));plot(T,real(g(a,T)),'b');hold on;% to be suppressed if a>0
                end;


                The answer(s) given by Matlab are :



                s =



                asin((sin(a)^2 + t)^(1/2))



                -asin((sin(a)^2 + t)^(1/2))



                Which one is the good one ?... Both...



                If we introduce "assume(a>0)", Matlab gives a single answer which is the first one.



                Other analytical facts could be commented (for example the domains of existence of solutions), but I think the asker will be satisfied with the details already given.



                enter image description here






                share|cite|improve this answer











                $endgroup$



                A (Matlab oriented) complement to the very didactic answer by @Dylan.



                Here is an extension of your program displaying either two or one solution(s). I use some Matlab instructions that may be new to you, in particular with a symbolic initial value $a$ (you had fixed this initial value to $a=1$) that can be constrained to be positive. The first part is with symbolic variables, almost the same as yours ; the second part uses numerical variables in order to see what happens for different values of $a$:



                clear all;close all;
                syms x(t) a
                ode=diff(x)==1/sin(2*x); % no need to take diff(x,t)...
                cond=x(0)==a; % a instead of 1
                %assume(a>0)
                s=dsolve(ode,cond) : % one or two solutions
                %%%
                T=0:0.01:0.7;
                for a=0:0.1:pi/2
                g=inline(s(1));plot(T,real(g(a,T)),'r');hold on;
                g=inline(s(2));plot(T,real(g(a,T)),'b');hold on;% to be suppressed if a>0
                end;


                The answer(s) given by Matlab are :



                s =



                asin((sin(a)^2 + t)^(1/2))



                -asin((sin(a)^2 + t)^(1/2))



                Which one is the good one ?... Both...



                If we introduce "assume(a>0)", Matlab gives a single answer which is the first one.



                Other analytical facts could be commented (for example the domains of existence of solutions), but I think the asker will be satisfied with the details already given.



                enter image description here







                share|cite|improve this answer














                share|cite|improve this answer



                share|cite|improve this answer








                edited 2 days ago

























                answered Mar 7 at 10:19









                Jean MarieJean Marie

                30.6k42154




                30.6k42154



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Mathematics 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%2fmath.stackexchange.com%2fquestions%2f3138221%2fsimple-differential-equation-in-matlab-and-wolfram-get-two-different-answer%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

                    How should I support this large drywall patch? Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?How do I cover large gaps in drywall?How do I keep drywall around a patch from crumbling?Can I glue a second layer of drywall?How to patch long strip on drywall?Large drywall patch: how to avoid bulging seams?Drywall Mesh Patch vs. Bulge? To remove or not to remove?How to fix this drywall job?Prep drywall before backsplashWhat's the best way to fix this horrible drywall patch job?Drywall patching using 3M Patch Plus Primer

                    random experiment with two different functions on unit interval Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern)Random variable and probability space notionsRandom Walk with EdgesFinding functions where the increase over a random interval is Poisson distributedNumber of days until dayCan an observed event in fact be of zero probability?Unit random processmodels of coins and uniform distributionHow to get the number of successes given $n$ trials , probability $P$ and a random variable $X$Absorbing Markov chain in a computer. Is “almost every” turned into always convergence in computer executions?Stopped random walk is not uniformly integrable

                    Lowndes Grove History Architecture References Navigation menu32°48′6″N 79°57′58″W / 32.80167°N 79.96611°W / 32.80167; -79.9661132°48′6″N 79°57′58″W / 32.80167°N 79.96611°W / 32.80167; -79.9661178002500"National Register Information System"Historic houses of South Carolina"Lowndes Grove""+32° 48' 6.00", −79° 57' 58.00""Lowndes Grove, Charleston County (260 St. Margaret St., Charleston)""Lowndes Grove"The Charleston ExpositionIt Happened in South Carolina"Lowndes Grove (House), Saint Margaret Street & Sixth Avenue, Charleston, Charleston County, SC(Photographs)"Plantations of the Carolina Low Countrye