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

                    Solar Wings Breeze Design and development Specifications (Breeze) References Navigation menu1368-485X"Hang glider: Breeze (Solar Wings)"e

                    Kathakali Contents Etymology and nomenclature History Repertoire Songs and musical instruments Traditional plays Styles: Sampradayam Training centers and awards Relationship to other dance forms See also Notes References External links Navigation menueThe Illustrated Encyclopedia of Hinduism: A-MSouth Asian Folklore: An EncyclopediaRoutledge International Encyclopedia of Women: Global Women's Issues and KnowledgeKathakali Dance-drama: Where Gods and Demons Come to PlayKathakali Dance-drama: Where Gods and Demons Come to PlayKathakali Dance-drama: Where Gods and Demons Come to Play10.1353/atj.2005.0004The Illustrated Encyclopedia of Hinduism: A-MEncyclopedia of HinduismKathakali Dance-drama: Where Gods and Demons Come to PlaySonic Liturgy: Ritual and Music in Hindu Tradition"The Mirror of Gesture"Kathakali Dance-drama: Where Gods and Demons Come to Play"Kathakali"Indian Theatre: Traditions of PerformanceIndian Theatre: Traditions of PerformanceIndian Theatre: Traditions of PerformanceIndian Theatre: Traditions of PerformanceMedieval Indian Literature: An AnthologyThe Oxford Companion to Indian TheatreSouth Asian Folklore: An Encyclopedia : Afghanistan, Bangladesh, India, Nepal, Pakistan, Sri LankaThe Rise of Performance Studies: Rethinking Richard Schechner's Broad SpectrumIndian Theatre: Traditions of PerformanceModern Asian Theatre and Performance 1900-2000Critical Theory and PerformanceBetween Theater and AnthropologyKathakali603847011Indian Theatre: Traditions of PerformanceIndian Theatre: Traditions of PerformanceIndian Theatre: Traditions of PerformanceBetween Theater and AnthropologyBetween Theater and AnthropologyNambeesan Smaraka AwardsArchivedThe Cambridge Guide to TheatreRoutledge International Encyclopedia of Women: Global Women's Issues and KnowledgeThe Garland Encyclopedia of World Music: South Asia : the Indian subcontinentThe Ethos of Noh: Actors and Their Art10.2307/1145740By Means of Performance: Intercultural Studies of Theatre and Ritual10.1017/s204912550000100xReconceiving the Renaissance: A Critical ReaderPerformance TheoryListening to Theatre: The Aural Dimension of Beijing Opera10.2307/1146013Kathakali: The Art of the Non-WorldlyOn KathakaliKathakali, the dance theatreThe Kathakali Complex: Performance & StructureKathakali Dance-Drama: Where Gods and Demons Come to Play10.1093/obo/9780195399318-0071Drama and Ritual of Early Hinduism"In the Shadow of Hollywood Orientalism: Authentic East Indian Dancing"10.1080/08949460490274013Sanskrit Play Production in Ancient IndiaIndian Music: History and StructureBharata, the Nāṭyaśāstra233639306Table of Contents2238067286469807Dance In Indian Painting10.2307/32047833204783Kathakali Dance-Theatre: A Visual Narrative of Sacred Indian MimeIndian Classical Dance: The Renaissance and BeyondKathakali: an indigenous art-form of Keralaeee

                    Method to test if a number is a perfect power? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern)Detecting perfect squares faster than by extracting square rooteffective way to get the integer sequence A181392 from oeisA rarely mentioned fact about perfect powersHow many numbers such $n$ are there that $n<100,lfloorsqrtn rfloor mid n$Check perfect squareness by modulo division against multiple basesFor what pair of integers $(a,b)$ is $3^a + 7^b$ a perfect square.Do there exist any positive integers $n$ such that $lfloore^nrfloor$ is a perfect power? What is the probability that one exists?finding perfect power factors of an integerProve that the sequence contains a perfect square for any natural number $m $ in the domain of $f$ .Counting Perfect Powers