Solving system of ODEs with extra parameter The 2019 Stack Overflow Developer Survey Results Are InTransforming ParametricFunction in expression depending on the parameterSolving a system of ODEs with the Runge-Kutta methodTips for efficiently solving large system coupled (nonlinear) ODEsHow do I pull from a data list for parameter values in a system of ODEs and then solve and plot?Solving PDEs with complicated boundary conditionsSolving Differential Algebraic Equations as BVPSolving a system of coupled Nonlinear ODEs using numeric and get `ndnum` errorIssues to modelize a system of differential equation (NDSolve)Solving PDEs over a region in different co-ordinate system?Error when solving 't Hooft-Polyakov radial equations using NDSolveHow to apply NIntegrate three times

How much of the clove should I use when using big garlic heads?

How to check whether the reindex working or not in Magento?

Loose spokes after only a few rides

How would you translate 「腰掛で仕事をする」

Why didn't the Event Horizon Telescope team mention Sagittarius A*?

Why doesn't mkfifo with a mode of 1755 grant read permissions and sticky bit to the user?

What could be the right powersource for 15 seconds lifespan disposable giant chainsaw?

Can a flute soloist sit?

Is bread bad for ducks?

Using xargs with pdftk

The difference between dialogue marks

Why is the Constellation's nose gear so long?

Why is ParallelDo slower than Do?

How can I refresh a custom data tab in the contact summary?

Why not take a picture of a closer black hole?

For what reasons would an animal species NOT cross a *horizontal* land bridge?

If I score a critical hit on an 18 or higher, what are my chances of getting a critical hit if I roll 3d20?

Are there any other methods to apply to solving simultaneous equations?

Why doesn't shell automatically fix "useless use of cat"?

two types of coins, decide which type it is based on 100 flips

Ubuntu Server install with full GUI

Command for nulifying spaces

Why was M87 targeted for the Event Horizon Telescope instead of Sagittarius A*?

How to type this arrow in math mode?



Solving system of ODEs with extra parameter



The 2019 Stack Overflow Developer Survey Results Are InTransforming ParametricFunction in expression depending on the parameterSolving a system of ODEs with the Runge-Kutta methodTips for efficiently solving large system coupled (nonlinear) ODEsHow do I pull from a data list for parameter values in a system of ODEs and then solve and plot?Solving PDEs with complicated boundary conditionsSolving Differential Algebraic Equations as BVPSolving a system of coupled Nonlinear ODEs using numeric and get `ndnum` errorIssues to modelize a system of differential equation (NDSolve)Solving PDEs over a region in different co-ordinate system?Error when solving 't Hooft-Polyakov radial equations using NDSolveHow to apply NIntegrate three times










3












$begingroup$


I would like to solve a $2times 2$ system of the form
$$fracddthetaT=TA,quad T(0)=Id$$
where $theta$ is real and $A$ is of the form
$$A=beginpmatrix 0 & frace^-i thetalambda\ frac136e^-ithetaleft(9lambda + 2(lambda-1)^2 (6costheta + cos2theta + 6)right) & 0endpmatrix,$$
with $lambda$ a free parameter in the unit circle.



In particular I'm interested in obtaining numeric solutions at $theta=2pi$ depending on the extra parameter $lambda$. I'm fairly new using Mathematica, and this is what I have tried so far:



T[θ_] = T11[θ], T12[θ], T21[θ], T22[θ];
A[θ_] =
0, E^(-I θ)/λ,
1/36 E^(-I θ) (9 λ + 2 (-1 + λ)^2 (6 + 6 Cos[θ] + Cos[2 θ])), 0
;
sys = T'[θ] == T[θ].A[θ];


The previous code sets the system that I want to solve and now I try to solve numerically. First I've tried



NSol = NDSolve[
sys, T11[0] == 1, T12[0] == 0, T21[0] == 0, T22[0] == 1,
T11[θ], T12[θ], T21[θ], T22[θ],
θ,
θ, 0, 2 Pi
];


which gives me the output



NDSolve::dupv: "Duplicate variable θ found in NDSolve[<<1>>]."


I have also tried



Nsol2 = ParametricNDSolve[
sys, T11[0] == 1, T12[0] == 0, T21[0] == 0, T22[0] == 1,
T11, T12, T21, T22,
θ, 0, 2 Pi,
λ
];


which gives me as output $T_11,dots,T_22$ as ParametricFunctions depending on each other and on $lambda$.



I don't know if this is the right approach and, if so, how to extract a numeric expression depending on $lambda$ from the last output - all that I've seen in the documentation are examples that are plotted for specific values of the parameter. Any help is much appreciated.



EDIT




Following the comments in one of the answers I'd like to explain further: the output that I would like to obtain is some sort of function depending of the parameter $lambda$ that I can manipulate afterwards. Say for instance, computing the series expansion of powers of $lambda$ of my solution. I don't know how to treat the ParametricFunction that I obtain to do such computations.











share|improve this question











$endgroup$
















    3












    $begingroup$


    I would like to solve a $2times 2$ system of the form
    $$fracddthetaT=TA,quad T(0)=Id$$
    where $theta$ is real and $A$ is of the form
    $$A=beginpmatrix 0 & frace^-i thetalambda\ frac136e^-ithetaleft(9lambda + 2(lambda-1)^2 (6costheta + cos2theta + 6)right) & 0endpmatrix,$$
    with $lambda$ a free parameter in the unit circle.



    In particular I'm interested in obtaining numeric solutions at $theta=2pi$ depending on the extra parameter $lambda$. I'm fairly new using Mathematica, and this is what I have tried so far:



    T[θ_] = T11[θ], T12[θ], T21[θ], T22[θ];
    A[θ_] =
    0, E^(-I θ)/λ,
    1/36 E^(-I θ) (9 λ + 2 (-1 + λ)^2 (6 + 6 Cos[θ] + Cos[2 θ])), 0
    ;
    sys = T'[θ] == T[θ].A[θ];


    The previous code sets the system that I want to solve and now I try to solve numerically. First I've tried



    NSol = NDSolve[
    sys, T11[0] == 1, T12[0] == 0, T21[0] == 0, T22[0] == 1,
    T11[θ], T12[θ], T21[θ], T22[θ],
    θ,
    θ, 0, 2 Pi
    ];


    which gives me the output



    NDSolve::dupv: "Duplicate variable θ found in NDSolve[<<1>>]."


    I have also tried



    Nsol2 = ParametricNDSolve[
    sys, T11[0] == 1, T12[0] == 0, T21[0] == 0, T22[0] == 1,
    T11, T12, T21, T22,
    θ, 0, 2 Pi,
    λ
    ];


    which gives me as output $T_11,dots,T_22$ as ParametricFunctions depending on each other and on $lambda$.



    I don't know if this is the right approach and, if so, how to extract a numeric expression depending on $lambda$ from the last output - all that I've seen in the documentation are examples that are plotted for specific values of the parameter. Any help is much appreciated.



    EDIT




    Following the comments in one of the answers I'd like to explain further: the output that I would like to obtain is some sort of function depending of the parameter $lambda$ that I can manipulate afterwards. Say for instance, computing the series expansion of powers of $lambda$ of my solution. I don't know how to treat the ParametricFunction that I obtain to do such computations.











    share|improve this question











    $endgroup$














      3












      3








      3





      $begingroup$


      I would like to solve a $2times 2$ system of the form
      $$fracddthetaT=TA,quad T(0)=Id$$
      where $theta$ is real and $A$ is of the form
      $$A=beginpmatrix 0 & frace^-i thetalambda\ frac136e^-ithetaleft(9lambda + 2(lambda-1)^2 (6costheta + cos2theta + 6)right) & 0endpmatrix,$$
      with $lambda$ a free parameter in the unit circle.



      In particular I'm interested in obtaining numeric solutions at $theta=2pi$ depending on the extra parameter $lambda$. I'm fairly new using Mathematica, and this is what I have tried so far:



      T[θ_] = T11[θ], T12[θ], T21[θ], T22[θ];
      A[θ_] =
      0, E^(-I θ)/λ,
      1/36 E^(-I θ) (9 λ + 2 (-1 + λ)^2 (6 + 6 Cos[θ] + Cos[2 θ])), 0
      ;
      sys = T'[θ] == T[θ].A[θ];


      The previous code sets the system that I want to solve and now I try to solve numerically. First I've tried



      NSol = NDSolve[
      sys, T11[0] == 1, T12[0] == 0, T21[0] == 0, T22[0] == 1,
      T11[θ], T12[θ], T21[θ], T22[θ],
      θ,
      θ, 0, 2 Pi
      ];


      which gives me the output



      NDSolve::dupv: "Duplicate variable θ found in NDSolve[<<1>>]."


      I have also tried



      Nsol2 = ParametricNDSolve[
      sys, T11[0] == 1, T12[0] == 0, T21[0] == 0, T22[0] == 1,
      T11, T12, T21, T22,
      θ, 0, 2 Pi,
      λ
      ];


      which gives me as output $T_11,dots,T_22$ as ParametricFunctions depending on each other and on $lambda$.



      I don't know if this is the right approach and, if so, how to extract a numeric expression depending on $lambda$ from the last output - all that I've seen in the documentation are examples that are plotted for specific values of the parameter. Any help is much appreciated.



      EDIT




      Following the comments in one of the answers I'd like to explain further: the output that I would like to obtain is some sort of function depending of the parameter $lambda$ that I can manipulate afterwards. Say for instance, computing the series expansion of powers of $lambda$ of my solution. I don't know how to treat the ParametricFunction that I obtain to do such computations.











      share|improve this question











      $endgroup$




      I would like to solve a $2times 2$ system of the form
      $$fracddthetaT=TA,quad T(0)=Id$$
      where $theta$ is real and $A$ is of the form
      $$A=beginpmatrix 0 & frace^-i thetalambda\ frac136e^-ithetaleft(9lambda + 2(lambda-1)^2 (6costheta + cos2theta + 6)right) & 0endpmatrix,$$
      with $lambda$ a free parameter in the unit circle.



      In particular I'm interested in obtaining numeric solutions at $theta=2pi$ depending on the extra parameter $lambda$. I'm fairly new using Mathematica, and this is what I have tried so far:



      T[θ_] = T11[θ], T12[θ], T21[θ], T22[θ];
      A[θ_] =
      0, E^(-I θ)/λ,
      1/36 E^(-I θ) (9 λ + 2 (-1 + λ)^2 (6 + 6 Cos[θ] + Cos[2 θ])), 0
      ;
      sys = T'[θ] == T[θ].A[θ];


      The previous code sets the system that I want to solve and now I try to solve numerically. First I've tried



      NSol = NDSolve[
      sys, T11[0] == 1, T12[0] == 0, T21[0] == 0, T22[0] == 1,
      T11[θ], T12[θ], T21[θ], T22[θ],
      θ,
      θ, 0, 2 Pi
      ];


      which gives me the output



      NDSolve::dupv: "Duplicate variable θ found in NDSolve[<<1>>]."


      I have also tried



      Nsol2 = ParametricNDSolve[
      sys, T11[0] == 1, T12[0] == 0, T21[0] == 0, T22[0] == 1,
      T11, T12, T21, T22,
      θ, 0, 2 Pi,
      λ
      ];


      which gives me as output $T_11,dots,T_22$ as ParametricFunctions depending on each other and on $lambda$.



      I don't know if this is the right approach and, if so, how to extract a numeric expression depending on $lambda$ from the last output - all that I've seen in the documentation are examples that are plotted for specific values of the parameter. Any help is much appreciated.



      EDIT




      Following the comments in one of the answers I'd like to explain further: the output that I would like to obtain is some sort of function depending of the parameter $lambda$ that I can manipulate afterwards. Say for instance, computing the series expansion of powers of $lambda$ of my solution. I don't know how to treat the ParametricFunction that I obtain to do such computations.








      differential-equations numerical-integration






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 30 at 19:56









      Carl Woll

      73.4k398192




      73.4k398192










      asked Mar 30 at 13:31









      EduEdu

      1476




      1476




















          3 Answers
          3






          active

          oldest

          votes


















          2












          $begingroup$

          Here is how to obtain the series expansion of the matrix components. First, using a tweaked version (solving for t[2π] instead of t) of JM's formulation:



          A[θ_] = 
          0, E^(-I θ)/λ,
          1/36 E^(-I θ) (9 λ + 2 (-1 + λ)^2 (6 + 6 Cos[θ] + Cos[2 θ])), 0
          ;

          pf = ParametricNDSolveValue[

          t'[θ] == t[θ].A[θ], t[0] == IdentityMatrix[2]
          ,
          t[2π],
          θ, 0, 2π,
          λ
          ];


          Then, pf will return the matrix value at $theta = 2 pi$. For example:



          pf[1]
          pf[Exp[I Pi/3]]



          1. + 3.62818*10^-9 I,
          6.82646*10^-8 - 5.73536*10^-9 I, 1.70661*10^-8 - 1.43384*10^-9 I,
          1. + 3.62818*10^-9 I



          0.985595 + 1.17074 I, -0.425572 + 0.737112 I, -0.788363 - 1.36549 I,
          0.985595 - 1.17074 I




          Finding the series expansion is simple:



          DecimalForm[Series[pf[λ], λ, 1, 5], 4,4] //TeXForm



          $left(
          beginarraycc
          1.0000 & 6.2830 \
          1.5710 & 1.0000 \
          endarray
          right)+left(
          beginarraycc
          0.0000+0.0000 i & -6.2830+0.0000 i \
          1.5710+0.0000 i & 0.0000+0.0000 i \
          endarray
          right) (lambda -1)+left(
          beginarraycc
          0.0000-0.7869 i & 0.6691-0.0000 i \
          0.8799+0.0000 i & -0.0000+0.7869 i \
          endarray
          right) (lambda -1)^2+left(
          beginarraycc
          0.0000+0.7869 i & -1.3380+0.0000 i \
          0.0000+0.0000 i & 0.0000-0.7869 i \
          endarray
          right) (lambda -1)^3+left(
          beginarraycc
          -0.0152-0.4524 i & 1.8410-0.0000 i \
          -0.5708-0.0000 i & -0.0152+0.4524 i \
          endarray
          right) (lambda -1)^4+left(
          beginarraycc
          0.0305+0.1179 i & -2.1780+0.0000 i \
          0.5708-0.0000 i & 0.0305-0.1179 i \
          endarray
          right) (lambda -1)^5+Oleft((lambda -1)^6right)$







          share|improve this answer









          $endgroup$




















            4












            $begingroup$

            As far as I can tell, you did everything right in your second approach. Classically, Mathematica returns lists of rules as results of solving functions, but in this case, I find this tradition rather confusing and prefer to use ParametricNDSolveValue; it returns a ParametricFunction object that, when applied to a numerical parameter, returns a list of 4 InterpolatingFunction for your 4 functions.



            T[θ_] = T11[θ], T12[θ], T21[θ], T22[θ];
            A[θ_] = 0, E^(-I θ)/λ, 1/36 E^(-I θ) (9 λ + 2 (-1 + λ)^2 (6 + 6 Cos[θ] + Cos[2 θ])), 0;
            sys = T'[θ] == T[θ].A[θ];

            Tsol = ParametricNDSolveValue[sys, T11[0] == 1, T12[0] == 0,
            T21[0] == 0, T22[0] == 1,
            T11, T12, T21, T22,
            θ, 0, 2 Pi,
            λ
            ];


            In order to obtain the numerical values for all the solutions at θ = 2 Pi for a given parameter, say λ = 0.1, you may use Through:



            Through[Tsol[0.1][2. Pi]]



            -0.545795 + 1.00532 I, -1.43497 - 7.95125*10^-7 I, -0.215035 -
            2.80298*10^-8 I, -0.545795 - 1.00532 I




            In order to make that into a function, you may use



            f = λ [Function] Through[Tsol[λ][2. Pi]]





            share|improve this answer











            $endgroup$












            • $begingroup$
              Thanks for your answer. Only the last step differs from what I'd like to obtain. What I would like to see is a function depending on $lambda$, not the evaluation at a single point.
              $endgroup$
              – Edu
              Mar 30 at 14:17


















            3












            $begingroup$

            For this case, you don't even need to write out the components of your matrix function:



            pf = ParametricNDSolveValue[t'[θ] == t[θ].0, Exp[-I θ]/λ,
            Exp[-I θ] (9 λ + 2 (λ - 1)^2
            (6 Cos[θ] + Cos[2 θ] + 6))/36, 0,
            t[0] == IdentityMatrix[2], t, θ, 0, 2 π, λ,
            Method -> "StiffnessSwitching"];

            sol = pf[(3 + 4 I)/5];

            ParametricPlot[ReIm[Tr[sol[θ]]], θ, 0, 2 π]


            some curve



            ParametricPlot[ReIm[Det[sol[θ]]], θ, 0, 2 π]


            some other curve



            You can even make a plot where the parameter is varying:



            Plot[Re[Tr[pf[Exp[I ϕ]][2 π]]], ϕ, 0, 2 π]


            yet another curve






            share|improve this answer











            $endgroup$












            • $begingroup$
              Thanks for your answer. Could I see the solution as a function of $lambda$ instead? I suppose is something possible to do...
              $endgroup$
              – Edu
              Mar 30 at 14:23










            • $begingroup$
              That is what the third plot is; I let $lambda=exp(ivarphi)$ (quote "with $lambda$ a free parameter in the unit circle") and plotted the real part of the trace of the matrix.
              $endgroup$
              – J. M. is away
              Mar 30 at 14:24











            • $begingroup$
              Sure, but I'd like to manipulate it further. Not just see its plot. See my point?
              $endgroup$
              – Edu
              Mar 30 at 14:26










            • $begingroup$
              You make no mention of what kind of manipulations you like to do in your question, so no, I do not see.
              $endgroup$
              – J. M. is away
              Mar 30 at 14:26











            • $begingroup$
              For example, can I get the solution as a function of $lambda$? Or as a series expansion of powers of $lambda$?
              $endgroup$
              – Edu
              Mar 30 at 14:41











            Your Answer





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

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "387"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f194251%2fsolving-system-of-odes-with-extra-parameter%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            3 Answers
            3






            active

            oldest

            votes








            3 Answers
            3






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2












            $begingroup$

            Here is how to obtain the series expansion of the matrix components. First, using a tweaked version (solving for t[2π] instead of t) of JM's formulation:



            A[θ_] = 
            0, E^(-I θ)/λ,
            1/36 E^(-I θ) (9 λ + 2 (-1 + λ)^2 (6 + 6 Cos[θ] + Cos[2 θ])), 0
            ;

            pf = ParametricNDSolveValue[

            t'[θ] == t[θ].A[θ], t[0] == IdentityMatrix[2]
            ,
            t[2π],
            θ, 0, 2π,
            λ
            ];


            Then, pf will return the matrix value at $theta = 2 pi$. For example:



            pf[1]
            pf[Exp[I Pi/3]]



            1. + 3.62818*10^-9 I,
            6.82646*10^-8 - 5.73536*10^-9 I, 1.70661*10^-8 - 1.43384*10^-9 I,
            1. + 3.62818*10^-9 I



            0.985595 + 1.17074 I, -0.425572 + 0.737112 I, -0.788363 - 1.36549 I,
            0.985595 - 1.17074 I




            Finding the series expansion is simple:



            DecimalForm[Series[pf[λ], λ, 1, 5], 4,4] //TeXForm



            $left(
            beginarraycc
            1.0000 & 6.2830 \
            1.5710 & 1.0000 \
            endarray
            right)+left(
            beginarraycc
            0.0000+0.0000 i & -6.2830+0.0000 i \
            1.5710+0.0000 i & 0.0000+0.0000 i \
            endarray
            right) (lambda -1)+left(
            beginarraycc
            0.0000-0.7869 i & 0.6691-0.0000 i \
            0.8799+0.0000 i & -0.0000+0.7869 i \
            endarray
            right) (lambda -1)^2+left(
            beginarraycc
            0.0000+0.7869 i & -1.3380+0.0000 i \
            0.0000+0.0000 i & 0.0000-0.7869 i \
            endarray
            right) (lambda -1)^3+left(
            beginarraycc
            -0.0152-0.4524 i & 1.8410-0.0000 i \
            -0.5708-0.0000 i & -0.0152+0.4524 i \
            endarray
            right) (lambda -1)^4+left(
            beginarraycc
            0.0305+0.1179 i & -2.1780+0.0000 i \
            0.5708-0.0000 i & 0.0305-0.1179 i \
            endarray
            right) (lambda -1)^5+Oleft((lambda -1)^6right)$







            share|improve this answer









            $endgroup$

















              2












              $begingroup$

              Here is how to obtain the series expansion of the matrix components. First, using a tweaked version (solving for t[2π] instead of t) of JM's formulation:



              A[θ_] = 
              0, E^(-I θ)/λ,
              1/36 E^(-I θ) (9 λ + 2 (-1 + λ)^2 (6 + 6 Cos[θ] + Cos[2 θ])), 0
              ;

              pf = ParametricNDSolveValue[

              t'[θ] == t[θ].A[θ], t[0] == IdentityMatrix[2]
              ,
              t[2π],
              θ, 0, 2π,
              λ
              ];


              Then, pf will return the matrix value at $theta = 2 pi$. For example:



              pf[1]
              pf[Exp[I Pi/3]]



              1. + 3.62818*10^-9 I,
              6.82646*10^-8 - 5.73536*10^-9 I, 1.70661*10^-8 - 1.43384*10^-9 I,
              1. + 3.62818*10^-9 I



              0.985595 + 1.17074 I, -0.425572 + 0.737112 I, -0.788363 - 1.36549 I,
              0.985595 - 1.17074 I




              Finding the series expansion is simple:



              DecimalForm[Series[pf[λ], λ, 1, 5], 4,4] //TeXForm



              $left(
              beginarraycc
              1.0000 & 6.2830 \
              1.5710 & 1.0000 \
              endarray
              right)+left(
              beginarraycc
              0.0000+0.0000 i & -6.2830+0.0000 i \
              1.5710+0.0000 i & 0.0000+0.0000 i \
              endarray
              right) (lambda -1)+left(
              beginarraycc
              0.0000-0.7869 i & 0.6691-0.0000 i \
              0.8799+0.0000 i & -0.0000+0.7869 i \
              endarray
              right) (lambda -1)^2+left(
              beginarraycc
              0.0000+0.7869 i & -1.3380+0.0000 i \
              0.0000+0.0000 i & 0.0000-0.7869 i \
              endarray
              right) (lambda -1)^3+left(
              beginarraycc
              -0.0152-0.4524 i & 1.8410-0.0000 i \
              -0.5708-0.0000 i & -0.0152+0.4524 i \
              endarray
              right) (lambda -1)^4+left(
              beginarraycc
              0.0305+0.1179 i & -2.1780+0.0000 i \
              0.5708-0.0000 i & 0.0305-0.1179 i \
              endarray
              right) (lambda -1)^5+Oleft((lambda -1)^6right)$







              share|improve this answer









              $endgroup$















                2












                2








                2





                $begingroup$

                Here is how to obtain the series expansion of the matrix components. First, using a tweaked version (solving for t[2π] instead of t) of JM's formulation:



                A[θ_] = 
                0, E^(-I θ)/λ,
                1/36 E^(-I θ) (9 λ + 2 (-1 + λ)^2 (6 + 6 Cos[θ] + Cos[2 θ])), 0
                ;

                pf = ParametricNDSolveValue[

                t'[θ] == t[θ].A[θ], t[0] == IdentityMatrix[2]
                ,
                t[2π],
                θ, 0, 2π,
                λ
                ];


                Then, pf will return the matrix value at $theta = 2 pi$. For example:



                pf[1]
                pf[Exp[I Pi/3]]



                1. + 3.62818*10^-9 I,
                6.82646*10^-8 - 5.73536*10^-9 I, 1.70661*10^-8 - 1.43384*10^-9 I,
                1. + 3.62818*10^-9 I



                0.985595 + 1.17074 I, -0.425572 + 0.737112 I, -0.788363 - 1.36549 I,
                0.985595 - 1.17074 I




                Finding the series expansion is simple:



                DecimalForm[Series[pf[λ], λ, 1, 5], 4,4] //TeXForm



                $left(
                beginarraycc
                1.0000 & 6.2830 \
                1.5710 & 1.0000 \
                endarray
                right)+left(
                beginarraycc
                0.0000+0.0000 i & -6.2830+0.0000 i \
                1.5710+0.0000 i & 0.0000+0.0000 i \
                endarray
                right) (lambda -1)+left(
                beginarraycc
                0.0000-0.7869 i & 0.6691-0.0000 i \
                0.8799+0.0000 i & -0.0000+0.7869 i \
                endarray
                right) (lambda -1)^2+left(
                beginarraycc
                0.0000+0.7869 i & -1.3380+0.0000 i \
                0.0000+0.0000 i & 0.0000-0.7869 i \
                endarray
                right) (lambda -1)^3+left(
                beginarraycc
                -0.0152-0.4524 i & 1.8410-0.0000 i \
                -0.5708-0.0000 i & -0.0152+0.4524 i \
                endarray
                right) (lambda -1)^4+left(
                beginarraycc
                0.0305+0.1179 i & -2.1780+0.0000 i \
                0.5708-0.0000 i & 0.0305-0.1179 i \
                endarray
                right) (lambda -1)^5+Oleft((lambda -1)^6right)$







                share|improve this answer









                $endgroup$



                Here is how to obtain the series expansion of the matrix components. First, using a tweaked version (solving for t[2π] instead of t) of JM's formulation:



                A[θ_] = 
                0, E^(-I θ)/λ,
                1/36 E^(-I θ) (9 λ + 2 (-1 + λ)^2 (6 + 6 Cos[θ] + Cos[2 θ])), 0
                ;

                pf = ParametricNDSolveValue[

                t'[θ] == t[θ].A[θ], t[0] == IdentityMatrix[2]
                ,
                t[2π],
                θ, 0, 2π,
                λ
                ];


                Then, pf will return the matrix value at $theta = 2 pi$. For example:



                pf[1]
                pf[Exp[I Pi/3]]



                1. + 3.62818*10^-9 I,
                6.82646*10^-8 - 5.73536*10^-9 I, 1.70661*10^-8 - 1.43384*10^-9 I,
                1. + 3.62818*10^-9 I



                0.985595 + 1.17074 I, -0.425572 + 0.737112 I, -0.788363 - 1.36549 I,
                0.985595 - 1.17074 I




                Finding the series expansion is simple:



                DecimalForm[Series[pf[λ], λ, 1, 5], 4,4] //TeXForm



                $left(
                beginarraycc
                1.0000 & 6.2830 \
                1.5710 & 1.0000 \
                endarray
                right)+left(
                beginarraycc
                0.0000+0.0000 i & -6.2830+0.0000 i \
                1.5710+0.0000 i & 0.0000+0.0000 i \
                endarray
                right) (lambda -1)+left(
                beginarraycc
                0.0000-0.7869 i & 0.6691-0.0000 i \
                0.8799+0.0000 i & -0.0000+0.7869 i \
                endarray
                right) (lambda -1)^2+left(
                beginarraycc
                0.0000+0.7869 i & -1.3380+0.0000 i \
                0.0000+0.0000 i & 0.0000-0.7869 i \
                endarray
                right) (lambda -1)^3+left(
                beginarraycc
                -0.0152-0.4524 i & 1.8410-0.0000 i \
                -0.5708-0.0000 i & -0.0152+0.4524 i \
                endarray
                right) (lambda -1)^4+left(
                beginarraycc
                0.0305+0.1179 i & -2.1780+0.0000 i \
                0.5708-0.0000 i & 0.0305-0.1179 i \
                endarray
                right) (lambda -1)^5+Oleft((lambda -1)^6right)$








                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 30 at 18:58









                Carl WollCarl Woll

                73.4k398192




                73.4k398192





















                    4












                    $begingroup$

                    As far as I can tell, you did everything right in your second approach. Classically, Mathematica returns lists of rules as results of solving functions, but in this case, I find this tradition rather confusing and prefer to use ParametricNDSolveValue; it returns a ParametricFunction object that, when applied to a numerical parameter, returns a list of 4 InterpolatingFunction for your 4 functions.



                    T[θ_] = T11[θ], T12[θ], T21[θ], T22[θ];
                    A[θ_] = 0, E^(-I θ)/λ, 1/36 E^(-I θ) (9 λ + 2 (-1 + λ)^2 (6 + 6 Cos[θ] + Cos[2 θ])), 0;
                    sys = T'[θ] == T[θ].A[θ];

                    Tsol = ParametricNDSolveValue[sys, T11[0] == 1, T12[0] == 0,
                    T21[0] == 0, T22[0] == 1,
                    T11, T12, T21, T22,
                    θ, 0, 2 Pi,
                    λ
                    ];


                    In order to obtain the numerical values for all the solutions at θ = 2 Pi for a given parameter, say λ = 0.1, you may use Through:



                    Through[Tsol[0.1][2. Pi]]



                    -0.545795 + 1.00532 I, -1.43497 - 7.95125*10^-7 I, -0.215035 -
                    2.80298*10^-8 I, -0.545795 - 1.00532 I




                    In order to make that into a function, you may use



                    f = λ [Function] Through[Tsol[λ][2. Pi]]





                    share|improve this answer











                    $endgroup$












                    • $begingroup$
                      Thanks for your answer. Only the last step differs from what I'd like to obtain. What I would like to see is a function depending on $lambda$, not the evaluation at a single point.
                      $endgroup$
                      – Edu
                      Mar 30 at 14:17















                    4












                    $begingroup$

                    As far as I can tell, you did everything right in your second approach. Classically, Mathematica returns lists of rules as results of solving functions, but in this case, I find this tradition rather confusing and prefer to use ParametricNDSolveValue; it returns a ParametricFunction object that, when applied to a numerical parameter, returns a list of 4 InterpolatingFunction for your 4 functions.



                    T[θ_] = T11[θ], T12[θ], T21[θ], T22[θ];
                    A[θ_] = 0, E^(-I θ)/λ, 1/36 E^(-I θ) (9 λ + 2 (-1 + λ)^2 (6 + 6 Cos[θ] + Cos[2 θ])), 0;
                    sys = T'[θ] == T[θ].A[θ];

                    Tsol = ParametricNDSolveValue[sys, T11[0] == 1, T12[0] == 0,
                    T21[0] == 0, T22[0] == 1,
                    T11, T12, T21, T22,
                    θ, 0, 2 Pi,
                    λ
                    ];


                    In order to obtain the numerical values for all the solutions at θ = 2 Pi for a given parameter, say λ = 0.1, you may use Through:



                    Through[Tsol[0.1][2. Pi]]



                    -0.545795 + 1.00532 I, -1.43497 - 7.95125*10^-7 I, -0.215035 -
                    2.80298*10^-8 I, -0.545795 - 1.00532 I




                    In order to make that into a function, you may use



                    f = λ [Function] Through[Tsol[λ][2. Pi]]





                    share|improve this answer











                    $endgroup$












                    • $begingroup$
                      Thanks for your answer. Only the last step differs from what I'd like to obtain. What I would like to see is a function depending on $lambda$, not the evaluation at a single point.
                      $endgroup$
                      – Edu
                      Mar 30 at 14:17













                    4












                    4








                    4





                    $begingroup$

                    As far as I can tell, you did everything right in your second approach. Classically, Mathematica returns lists of rules as results of solving functions, but in this case, I find this tradition rather confusing and prefer to use ParametricNDSolveValue; it returns a ParametricFunction object that, when applied to a numerical parameter, returns a list of 4 InterpolatingFunction for your 4 functions.



                    T[θ_] = T11[θ], T12[θ], T21[θ], T22[θ];
                    A[θ_] = 0, E^(-I θ)/λ, 1/36 E^(-I θ) (9 λ + 2 (-1 + λ)^2 (6 + 6 Cos[θ] + Cos[2 θ])), 0;
                    sys = T'[θ] == T[θ].A[θ];

                    Tsol = ParametricNDSolveValue[sys, T11[0] == 1, T12[0] == 0,
                    T21[0] == 0, T22[0] == 1,
                    T11, T12, T21, T22,
                    θ, 0, 2 Pi,
                    λ
                    ];


                    In order to obtain the numerical values for all the solutions at θ = 2 Pi for a given parameter, say λ = 0.1, you may use Through:



                    Through[Tsol[0.1][2. Pi]]



                    -0.545795 + 1.00532 I, -1.43497 - 7.95125*10^-7 I, -0.215035 -
                    2.80298*10^-8 I, -0.545795 - 1.00532 I




                    In order to make that into a function, you may use



                    f = λ [Function] Through[Tsol[λ][2. Pi]]





                    share|improve this answer











                    $endgroup$



                    As far as I can tell, you did everything right in your second approach. Classically, Mathematica returns lists of rules as results of solving functions, but in this case, I find this tradition rather confusing and prefer to use ParametricNDSolveValue; it returns a ParametricFunction object that, when applied to a numerical parameter, returns a list of 4 InterpolatingFunction for your 4 functions.



                    T[θ_] = T11[θ], T12[θ], T21[θ], T22[θ];
                    A[θ_] = 0, E^(-I θ)/λ, 1/36 E^(-I θ) (9 λ + 2 (-1 + λ)^2 (6 + 6 Cos[θ] + Cos[2 θ])), 0;
                    sys = T'[θ] == T[θ].A[θ];

                    Tsol = ParametricNDSolveValue[sys, T11[0] == 1, T12[0] == 0,
                    T21[0] == 0, T22[0] == 1,
                    T11, T12, T21, T22,
                    θ, 0, 2 Pi,
                    λ
                    ];


                    In order to obtain the numerical values for all the solutions at θ = 2 Pi for a given parameter, say λ = 0.1, you may use Through:



                    Through[Tsol[0.1][2. Pi]]



                    -0.545795 + 1.00532 I, -1.43497 - 7.95125*10^-7 I, -0.215035 -
                    2.80298*10^-8 I, -0.545795 - 1.00532 I




                    In order to make that into a function, you may use



                    f = λ [Function] Through[Tsol[λ][2. Pi]]






                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Mar 30 at 14:25

























                    answered Mar 30 at 13:47









                    Henrik SchumacherHenrik Schumacher

                    59.8k582166




                    59.8k582166











                    • $begingroup$
                      Thanks for your answer. Only the last step differs from what I'd like to obtain. What I would like to see is a function depending on $lambda$, not the evaluation at a single point.
                      $endgroup$
                      – Edu
                      Mar 30 at 14:17
















                    • $begingroup$
                      Thanks for your answer. Only the last step differs from what I'd like to obtain. What I would like to see is a function depending on $lambda$, not the evaluation at a single point.
                      $endgroup$
                      – Edu
                      Mar 30 at 14:17















                    $begingroup$
                    Thanks for your answer. Only the last step differs from what I'd like to obtain. What I would like to see is a function depending on $lambda$, not the evaluation at a single point.
                    $endgroup$
                    – Edu
                    Mar 30 at 14:17




                    $begingroup$
                    Thanks for your answer. Only the last step differs from what I'd like to obtain. What I would like to see is a function depending on $lambda$, not the evaluation at a single point.
                    $endgroup$
                    – Edu
                    Mar 30 at 14:17











                    3












                    $begingroup$

                    For this case, you don't even need to write out the components of your matrix function:



                    pf = ParametricNDSolveValue[t'[θ] == t[θ].0, Exp[-I θ]/λ,
                    Exp[-I θ] (9 λ + 2 (λ - 1)^2
                    (6 Cos[θ] + Cos[2 θ] + 6))/36, 0,
                    t[0] == IdentityMatrix[2], t, θ, 0, 2 π, λ,
                    Method -> "StiffnessSwitching"];

                    sol = pf[(3 + 4 I)/5];

                    ParametricPlot[ReIm[Tr[sol[θ]]], θ, 0, 2 π]


                    some curve



                    ParametricPlot[ReIm[Det[sol[θ]]], θ, 0, 2 π]


                    some other curve



                    You can even make a plot where the parameter is varying:



                    Plot[Re[Tr[pf[Exp[I ϕ]][2 π]]], ϕ, 0, 2 π]


                    yet another curve






                    share|improve this answer











                    $endgroup$












                    • $begingroup$
                      Thanks for your answer. Could I see the solution as a function of $lambda$ instead? I suppose is something possible to do...
                      $endgroup$
                      – Edu
                      Mar 30 at 14:23










                    • $begingroup$
                      That is what the third plot is; I let $lambda=exp(ivarphi)$ (quote "with $lambda$ a free parameter in the unit circle") and plotted the real part of the trace of the matrix.
                      $endgroup$
                      – J. M. is away
                      Mar 30 at 14:24











                    • $begingroup$
                      Sure, but I'd like to manipulate it further. Not just see its plot. See my point?
                      $endgroup$
                      – Edu
                      Mar 30 at 14:26










                    • $begingroup$
                      You make no mention of what kind of manipulations you like to do in your question, so no, I do not see.
                      $endgroup$
                      – J. M. is away
                      Mar 30 at 14:26











                    • $begingroup$
                      For example, can I get the solution as a function of $lambda$? Or as a series expansion of powers of $lambda$?
                      $endgroup$
                      – Edu
                      Mar 30 at 14:41















                    3












                    $begingroup$

                    For this case, you don't even need to write out the components of your matrix function:



                    pf = ParametricNDSolveValue[t'[θ] == t[θ].0, Exp[-I θ]/λ,
                    Exp[-I θ] (9 λ + 2 (λ - 1)^2
                    (6 Cos[θ] + Cos[2 θ] + 6))/36, 0,
                    t[0] == IdentityMatrix[2], t, θ, 0, 2 π, λ,
                    Method -> "StiffnessSwitching"];

                    sol = pf[(3 + 4 I)/5];

                    ParametricPlot[ReIm[Tr[sol[θ]]], θ, 0, 2 π]


                    some curve



                    ParametricPlot[ReIm[Det[sol[θ]]], θ, 0, 2 π]


                    some other curve



                    You can even make a plot where the parameter is varying:



                    Plot[Re[Tr[pf[Exp[I ϕ]][2 π]]], ϕ, 0, 2 π]


                    yet another curve






                    share|improve this answer











                    $endgroup$












                    • $begingroup$
                      Thanks for your answer. Could I see the solution as a function of $lambda$ instead? I suppose is something possible to do...
                      $endgroup$
                      – Edu
                      Mar 30 at 14:23










                    • $begingroup$
                      That is what the third plot is; I let $lambda=exp(ivarphi)$ (quote "with $lambda$ a free parameter in the unit circle") and plotted the real part of the trace of the matrix.
                      $endgroup$
                      – J. M. is away
                      Mar 30 at 14:24











                    • $begingroup$
                      Sure, but I'd like to manipulate it further. Not just see its plot. See my point?
                      $endgroup$
                      – Edu
                      Mar 30 at 14:26










                    • $begingroup$
                      You make no mention of what kind of manipulations you like to do in your question, so no, I do not see.
                      $endgroup$
                      – J. M. is away
                      Mar 30 at 14:26











                    • $begingroup$
                      For example, can I get the solution as a function of $lambda$? Or as a series expansion of powers of $lambda$?
                      $endgroup$
                      – Edu
                      Mar 30 at 14:41













                    3












                    3








                    3





                    $begingroup$

                    For this case, you don't even need to write out the components of your matrix function:



                    pf = ParametricNDSolveValue[t'[θ] == t[θ].0, Exp[-I θ]/λ,
                    Exp[-I θ] (9 λ + 2 (λ - 1)^2
                    (6 Cos[θ] + Cos[2 θ] + 6))/36, 0,
                    t[0] == IdentityMatrix[2], t, θ, 0, 2 π, λ,
                    Method -> "StiffnessSwitching"];

                    sol = pf[(3 + 4 I)/5];

                    ParametricPlot[ReIm[Tr[sol[θ]]], θ, 0, 2 π]


                    some curve



                    ParametricPlot[ReIm[Det[sol[θ]]], θ, 0, 2 π]


                    some other curve



                    You can even make a plot where the parameter is varying:



                    Plot[Re[Tr[pf[Exp[I ϕ]][2 π]]], ϕ, 0, 2 π]


                    yet another curve






                    share|improve this answer











                    $endgroup$



                    For this case, you don't even need to write out the components of your matrix function:



                    pf = ParametricNDSolveValue[t'[θ] == t[θ].0, Exp[-I θ]/λ,
                    Exp[-I θ] (9 λ + 2 (λ - 1)^2
                    (6 Cos[θ] + Cos[2 θ] + 6))/36, 0,
                    t[0] == IdentityMatrix[2], t, θ, 0, 2 π, λ,
                    Method -> "StiffnessSwitching"];

                    sol = pf[(3 + 4 I)/5];

                    ParametricPlot[ReIm[Tr[sol[θ]]], θ, 0, 2 π]


                    some curve



                    ParametricPlot[ReIm[Det[sol[θ]]], θ, 0, 2 π]


                    some other curve



                    You can even make a plot where the parameter is varying:



                    Plot[Re[Tr[pf[Exp[I ϕ]][2 π]]], ϕ, 0, 2 π]


                    yet another curve







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    answered Mar 30 at 13:57


























                    community wiki





                    J. M. is away












                    • $begingroup$
                      Thanks for your answer. Could I see the solution as a function of $lambda$ instead? I suppose is something possible to do...
                      $endgroup$
                      – Edu
                      Mar 30 at 14:23










                    • $begingroup$
                      That is what the third plot is; I let $lambda=exp(ivarphi)$ (quote "with $lambda$ a free parameter in the unit circle") and plotted the real part of the trace of the matrix.
                      $endgroup$
                      – J. M. is away
                      Mar 30 at 14:24











                    • $begingroup$
                      Sure, but I'd like to manipulate it further. Not just see its plot. See my point?
                      $endgroup$
                      – Edu
                      Mar 30 at 14:26










                    • $begingroup$
                      You make no mention of what kind of manipulations you like to do in your question, so no, I do not see.
                      $endgroup$
                      – J. M. is away
                      Mar 30 at 14:26











                    • $begingroup$
                      For example, can I get the solution as a function of $lambda$? Or as a series expansion of powers of $lambda$?
                      $endgroup$
                      – Edu
                      Mar 30 at 14:41
















                    • $begingroup$
                      Thanks for your answer. Could I see the solution as a function of $lambda$ instead? I suppose is something possible to do...
                      $endgroup$
                      – Edu
                      Mar 30 at 14:23










                    • $begingroup$
                      That is what the third plot is; I let $lambda=exp(ivarphi)$ (quote "with $lambda$ a free parameter in the unit circle") and plotted the real part of the trace of the matrix.
                      $endgroup$
                      – J. M. is away
                      Mar 30 at 14:24











                    • $begingroup$
                      Sure, but I'd like to manipulate it further. Not just see its plot. See my point?
                      $endgroup$
                      – Edu
                      Mar 30 at 14:26










                    • $begingroup$
                      You make no mention of what kind of manipulations you like to do in your question, so no, I do not see.
                      $endgroup$
                      – J. M. is away
                      Mar 30 at 14:26











                    • $begingroup$
                      For example, can I get the solution as a function of $lambda$? Or as a series expansion of powers of $lambda$?
                      $endgroup$
                      – Edu
                      Mar 30 at 14:41















                    $begingroup$
                    Thanks for your answer. Could I see the solution as a function of $lambda$ instead? I suppose is something possible to do...
                    $endgroup$
                    – Edu
                    Mar 30 at 14:23




                    $begingroup$
                    Thanks for your answer. Could I see the solution as a function of $lambda$ instead? I suppose is something possible to do...
                    $endgroup$
                    – Edu
                    Mar 30 at 14:23












                    $begingroup$
                    That is what the third plot is; I let $lambda=exp(ivarphi)$ (quote "with $lambda$ a free parameter in the unit circle") and plotted the real part of the trace of the matrix.
                    $endgroup$
                    – J. M. is away
                    Mar 30 at 14:24





                    $begingroup$
                    That is what the third plot is; I let $lambda=exp(ivarphi)$ (quote "with $lambda$ a free parameter in the unit circle") and plotted the real part of the trace of the matrix.
                    $endgroup$
                    – J. M. is away
                    Mar 30 at 14:24













                    $begingroup$
                    Sure, but I'd like to manipulate it further. Not just see its plot. See my point?
                    $endgroup$
                    – Edu
                    Mar 30 at 14:26




                    $begingroup$
                    Sure, but I'd like to manipulate it further. Not just see its plot. See my point?
                    $endgroup$
                    – Edu
                    Mar 30 at 14:26












                    $begingroup$
                    You make no mention of what kind of manipulations you like to do in your question, so no, I do not see.
                    $endgroup$
                    – J. M. is away
                    Mar 30 at 14:26





                    $begingroup$
                    You make no mention of what kind of manipulations you like to do in your question, so no, I do not see.
                    $endgroup$
                    – J. M. is away
                    Mar 30 at 14:26













                    $begingroup$
                    For example, can I get the solution as a function of $lambda$? Or as a series expansion of powers of $lambda$?
                    $endgroup$
                    – Edu
                    Mar 30 at 14:41




                    $begingroup$
                    For example, can I get the solution as a function of $lambda$? Or as a series expansion of powers of $lambda$?
                    $endgroup$
                    – Edu
                    Mar 30 at 14:41

















                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Mathematica Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    Use MathJax to format equations. MathJax reference.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f194251%2fsolving-system-of-odes-with-extra-parameter%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

                    Adding axes to figuresAdding axes labels to LaTeX figuresLaTeX equivalent of ConTeXt buffersRotate a node but not its content: the case of the ellipse decorationHow to define the default vertical distance between nodes?TikZ scaling graphic and adjust node position and keep font sizeNumerical conditional within tikz keys?adding axes to shapesAlign axes across subfiguresAdding figures with a certain orderLine up nested tikz enviroments or how to get rid of themAdding axes labels to LaTeX figures

                    Tähtien Talli Jäsenet | Lähteet | NavigointivalikkoSuomen Hippos – Tähtien Talli

                    Do these cracks on my tires look bad? The Next CEO of Stack OverflowDry rot tire should I replace?Having to replace tiresFishtailed so easily? Bad tires? ABS?Filling the tires with something other than air, to avoid puncture hassles?Used Michelin tires safe to install?Do these tyre cracks necessitate replacement?Rumbling noise: tires or mechanicalIs it possible to fix noisy feathered tires?Are bad winter tires still better than summer tires in winter?Torque converter failure - Related to replacing only 2 tires?Why use snow tires on all 4 wheels on 2-wheel-drive cars?