Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Mathematica NDSolve

  1. Jan 26, 2015 #1
    hi everybody
    i recently used NDSolve for a system with three second-order equations but it says:
    "NDSolve::ndsdtc:
    ("\"The time constraint of 1.` seconds was exceeded trying to solve for derivatives, so the system will be treated as a system of differential-algebraic equations. You can use Method->{\\\"EquationSimplification\\\"->\\\"Solve\\\"} to have the system solved as ordinary differential equations."

    whats the problem? can anyone help me soon?! i cant give answer even if i change the Method or using DSolve instead NDSolve... :(
     
  2. jcsd
  3. Jan 29, 2015 #2

    Dale

    Staff: Mentor

    It sounds like the equations that you have are not in the form of a derivative on the left and a function on the right. It looks like Mathematica is having trouble trying to put it in that form.

    Can you post the code that is generating this error?
     
  4. Jun 26, 2015 #3
    the code is :
    matherror.jpg
     
  5. Jun 26, 2015 #4

    Dale

    Staff: Mentor

    Ugh, I cannot do anything with a blurry picture of code. Please post the code, not a picture of the code. I need enough code to be able to replicate the error here.
     
  6. Jun 26, 2015 #5
    Ok but because of containing special characters,you must copy the code into your own Mathematica to see it correctly...
    Code (Text):

    lagrange\[CurlyPhi]i1=
    56.8293 (Sin[\[Pi]/
          45] (0.169258 Cos[\[CurlyPhi]i1[t]] +
           0.0118478 Sin[\[CurlyPhi]i1[t]]) +
        Cos[\[Pi]/
          45] (-0.0653683 Cos[\[CurlyPhi]i1[t]] +
           0.169258 Sin[\[CurlyPhi]i1[t]])) -
     1.46445 (2 (-0.169672 Sin[0.0698842 - \[CurlyPhi]i1[t]] Derivative[
             1][\[CurlyPhi]i1][t] +
           0.169672 Sin[0.0698842 - \[CurlyPhi]i1[t]] Derivative[
             1][\[CurlyPhi]i2][t]) (-0.169672 Cos[
             0.0698842 - \[CurlyPhi]i1[t]] Derivative[1][\[CurlyPhi]i1][
             t] + 0.169672 Cos[0.0698842 - \[CurlyPhi]i1[t]] Derivative[
             1][\[CurlyPhi]i2][t] -
           0.2604 Cos[\[CurlyPhi]i2[t]] Derivative[1][\[CurlyPhi]i2][t] +
           0.1092 Derivative[1][\[CurlyPhi]o1][t] -
           0.494053 Sin[1.41389 - \[CurlyPhi]o1[t]] Derivative[
             1][\[CurlyPhi]o1][t]) +
        2 (-0.169672 Cos[0.0698842 - \[CurlyPhi]i1[t]] Derivative[
             1][\[CurlyPhi]i1][t] +
           0.169672 Cos[0.0698842 - \[CurlyPhi]i1[t]] Derivative[
             1][\[CurlyPhi]i2][t]) (0.169672 Sin[
             0.0698842 - \[CurlyPhi]i1[t]] Derivative[1][\[CurlyPhi]i1][
             t] -
           0.169672 Sin[0.0698842 - \[CurlyPhi]i1[t]] Derivative[
             1][\[CurlyPhi]i2][t] -
           0.2604 Sin[\[CurlyPhi]i2[t]] Derivative[1][\[CurlyPhi]i2][t] +
           0.494053 Sin[1.41389 - \[CurlyPhi]o1[t]] Derivative[
             1][\[CurlyPhi]o1][t])) +
     i1 (\[CurlyPhi]i1^\[Prime]\[Prime])[t] +
     1.46445 (-0.339345 Sin[0.0698842 - \[CurlyPhi]i1[t]] Derivative[
          1][\[CurlyPhi]i1][
          t] (-0.169672 Cos[0.0698842 - \[CurlyPhi]i1[t]] Derivative[
             1][\[CurlyPhi]i1][t] +
           0.169672 Cos[0.0698842 - \[CurlyPhi]i1[t]] Derivative[
             1][\[CurlyPhi]i2][t] -
           0.2604 Cos[\[CurlyPhi]i2[t]] Derivative[1][\[CurlyPhi]i2][t] +
           0.1092 Derivative[1][\[CurlyPhi]o1][t] -
           0.494053 Sin[1.41389 - \[CurlyPhi]o1[t]] Derivative[
             1][\[CurlyPhi]o1][t]) -
        0.339345 Cos[0.0698842 - \[CurlyPhi]i1[t]] Derivative[
          1][\[CurlyPhi]i1][
          t] (0.169672 Sin[0.0698842 - \[CurlyPhi]i1[t]] Derivative[
             1][\[CurlyPhi]i1][t] -
           0.169672 Sin[0.0698842 - \[CurlyPhi]i1[t]] Derivative[
             1][\[CurlyPhi]i2][t] -
           0.2604 Sin[\[CurlyPhi]i2[t]] Derivative[1][\[CurlyPhi]i2][t] +
           0.494053 Sin[1.41389 - \[CurlyPhi]o1[t]] Derivative[
             1][\[CurlyPhi]o1][t]) -
        0.339345 Cos[
          0.0698842 - \[CurlyPhi]i1[
            t]] (-0.169672 Sin[0.0698842 - \[CurlyPhi]i1[t]] Derivative[
             1][\[CurlyPhi]i1][t]^2 +
           0.169672 Sin[0.0698842 - \[CurlyPhi]i1[t]] Derivative[
             1][\[CurlyPhi]i1][t] Derivative[1][\[CurlyPhi]i2][t] +
           0.2604 Sin[\[CurlyPhi]i2[t]] Derivative[1][\[CurlyPhi]i2][
             t]^2 + 0.494053 Cos[1.41389 - \[CurlyPhi]o1[t]] Derivative[
             1][\[CurlyPhi]o1][t]^2 -
           0.169672 Cos[
             0.0698842 - \[CurlyPhi]i1[
               t]] (\[CurlyPhi]i1^\[Prime]\[Prime])[t] +
           0.169672 Cos[
             0.0698842 - \[CurlyPhi]i1[
               t]] (\[CurlyPhi]i2^\[Prime]\[Prime])[t] -
           0.2604 Cos[\[CurlyPhi]i2[t]] (\[CurlyPhi]i2^\[Prime]\[Prime])[
             t] + 0.1092 (\[CurlyPhi]o1^\[Prime]\[Prime])[t] -
           0.494053 Sin[
             1.41389 - \[CurlyPhi]o1[t]] (\[CurlyPhi]o1^\[Prime]\[Prime])[
             t]) + 0.339345 Sin[
          0.0698842 - \[CurlyPhi]i1[
            t]] (-0.169672 Cos[0.0698842 - \[CurlyPhi]i1[t]] Derivative[
             1][\[CurlyPhi]i1][t]^2 +
           0.169672 Cos[0.0698842 - \[CurlyPhi]i1[t]] Derivative[
             1][\[CurlyPhi]i1][t] Derivative[1][\[CurlyPhi]i2][t] -
           0.2604 Cos[\[CurlyPhi]i2[t]] Derivative[1][\[CurlyPhi]i2][
             t]^2 - 0.494053 Cos[1.41389 - \[CurlyPhi]o1[t]] Derivative[
             1][\[CurlyPhi]o1][t]^2 +
           0.169672 Sin[
             0.0698842 - \[CurlyPhi]i1[
               t]] (\[CurlyPhi]i1^\[Prime]\[Prime])[t] -
           0.169672 Sin[
             0.0698842 - \[CurlyPhi]i1[
               t]] (\[CurlyPhi]i2^\[Prime]\[Prime])[t] -
           0.2604 Sin[\[CurlyPhi]i2[t]] (\[CurlyPhi]i2^\[Prime]\[Prime])[
             t] + 0.494053 Sin[
             1.41389 - \[CurlyPhi]o1[t]] (\[CurlyPhi]o1^\[Prime]\[Prime])[
             t]))

    lagrange\[CurlyPhi]i2=
    28.7325 (0.00908229 Cos[\[CurlyPhi]i2[t]] +
        0.129883 Sin[\[CurlyPhi]i2[t]]) +
     56.8293 (0.0181646 Cos[\[CurlyPhi]i2[t]] +
        0.259766 Sin[\[CurlyPhi]i2[t]]) -
     1.46445 (0.5208 Sin[\[CurlyPhi]i2[t]] Derivative[1][\[CurlyPhi]i2][
          t] (-0.169672 Cos[0.0698842 - \[CurlyPhi]i1[t]] Derivative[
             1][\[CurlyPhi]i1][t] +
           0.169672 Cos[0.0698842 - \[CurlyPhi]i1[t]] Derivative[
             1][\[CurlyPhi]i2][t] -
           0.2604 Cos[\[CurlyPhi]i2[t]] Derivative[1][\[CurlyPhi]i2][t] +
           0.1092 Derivative[1][\[CurlyPhi]o1][t] -
           0.494053 Sin[1.41389 - \[CurlyPhi]o1[t]] Derivative[
             1][\[CurlyPhi]o1][t]) -
        0.5208 Cos[\[CurlyPhi]i2[t]] Derivative[1][\[CurlyPhi]i2][
          t] (0.169672 Sin[0.0698842 - \[CurlyPhi]i1[t]] Derivative[
             1][\[CurlyPhi]i1][t] -
           0.169672 Sin[0.0698842 - \[CurlyPhi]i1[t]] Derivative[
             1][\[CurlyPhi]i2][t] -
           0.2604 Sin[\[CurlyPhi]i2[t]] Derivative[1][\[CurlyPhi]i2][t] +
           0.494053 Sin[1.41389 - \[CurlyPhi]o1[t]] Derivative[
             1][\[CurlyPhi]o1][t])) -
     2.8965 (0.2604 Sin[\[CurlyPhi]i2[t]] Derivative[1][\[CurlyPhi]i2][
          t] (-0.1302 Cos[\[CurlyPhi]i2[t]] Derivative[1][\[CurlyPhi]i2][
             t] + 0.1092 Derivative[1][\[CurlyPhi]o1][t] -
           0.494053 Sin[1.41389 - \[CurlyPhi]o1[t]] Derivative[
             1][\[CurlyPhi]o1][t]) -
        0.2604 Cos[\[CurlyPhi]i2[t]] Derivative[1][\[CurlyPhi]i2][
          t] (-0.1302 Sin[\[CurlyPhi]i2[t]] Derivative[1][\[CurlyPhi]i2][
             t] + 0.494053 Sin[1.41389 - \[CurlyPhi]o1[t]] Derivative[
             1][\[CurlyPhi]o1][t])) +
     i2 (\[CurlyPhi]i2^\[Prime]\[Prime])[t] +
     1.46445 (2 (0.169672 Sin[0.0698842 - \[CurlyPhi]i1[t]] Derivative[
             1][\[CurlyPhi]i1][t] +
           0.2604 Sin[\[CurlyPhi]i2[t]] Derivative[1][\[CurlyPhi]i2][
             t]) (-0.169672 Cos[0.0698842 - \[CurlyPhi]i1[t]] Derivative[
             1][\[CurlyPhi]i1][t] +
           0.169672 Cos[0.0698842 - \[CurlyPhi]i1[t]] Derivative[
             1][\[CurlyPhi]i2][t] -
           0.2604 Cos[\[CurlyPhi]i2[t]] Derivative[1][\[CurlyPhi]i2][t] +
           0.1092 Derivative[1][\[CurlyPhi]o1][t] -
           0.494053 Sin[1.41389 - \[CurlyPhi]o1[t]] Derivative[
             1][\[CurlyPhi]o1][t]) +
        2 (0.169672 Cos[0.0698842 - \[CurlyPhi]i1[t]] Derivative[
             1][\[CurlyPhi]i1][t] -
           0.2604 Cos[\[CurlyPhi]i2[t]] Derivative[1][\[CurlyPhi]i2][
             t]) (0.169672 Sin[0.0698842 - \[CurlyPhi]i1[t]] Derivative[
             1][\[CurlyPhi]i1][t] -
           0.169672 Sin[0.0698842 - \[CurlyPhi]i1[t]] Derivative[
             1][\[CurlyPhi]i2][t] -
           0.2604 Sin[\[CurlyPhi]i2[t]] Derivative[1][\[CurlyPhi]i2][t] +
           0.494053 Sin[1.41389 - \[CurlyPhi]o1[t]] Derivative[
             1][\[CurlyPhi]o1][t]) +
        2 (0.169672 Cos[0.0698842 - \[CurlyPhi]i1[t]] -
           0.2604 Cos[\[CurlyPhi]i2[t]]) (-0.169672 Sin[
             0.0698842 - \[CurlyPhi]i1[t]] Derivative[1][\[CurlyPhi]i1][
             t]^2 + 0.169672 Sin[0.0698842 - \[CurlyPhi]i1[t]] Derivative[
             1][\[CurlyPhi]i1][t] Derivative[1][\[CurlyPhi]i2][t] +
           0.2604 Sin[\[CurlyPhi]i2[t]] Derivative[1][\[CurlyPhi]i2][
             t]^2 + 0.494053 Cos[1.41389 - \[CurlyPhi]o1[t]] Derivative[
             1][\[CurlyPhi]o1][t]^2 -
           0.169672 Cos[
             0.0698842 - \[CurlyPhi]i1[
               t]] (\[CurlyPhi]i1^\[Prime]\[Prime])[t] +
           0.169672 Cos[
             0.0698842 - \[CurlyPhi]i1[
               t]] (\[CurlyPhi]i2^\[Prime]\[Prime])[t] -
           0.2604 Cos[\[CurlyPhi]i2[t]] (\[CurlyPhi]i2^\[Prime]\[Prime])[
             t] + 0.1092 (\[CurlyPhi]o1^\[Prime]\[Prime])[t] -
           0.494053 Sin[
             1.41389 - \[CurlyPhi]o1[t]] (\[CurlyPhi]o1^\[Prime]\[Prime])[
             t]) + 2 (-0.169672 Sin[0.0698842 - \[CurlyPhi]i1[t]] -
           0.2604 Sin[\[CurlyPhi]i2[t]]) (-0.169672 Cos[
             0.0698842 - \[CurlyPhi]i1[t]] Derivative[1][\[CurlyPhi]i1][
             t]^2 + 0.169672 Cos[0.0698842 - \[CurlyPhi]i1[t]] Derivative[
             1][\[CurlyPhi]i1][t] Derivative[1][\[CurlyPhi]i2][t] -
           0.2604 Cos[\[CurlyPhi]i2[t]] Derivative[1][\[CurlyPhi]i2][
             t]^2 - 0.494053 Cos[1.41389 - \[CurlyPhi]o1[t]] Derivative[
             1][\[CurlyPhi]o1][t]^2 +
           0.169672 Sin[
             0.0698842 - \[CurlyPhi]i1[
               t]] (\[CurlyPhi]i1^\[Prime]\[Prime])[t] -
           0.169672 Sin[
             0.0698842 - \[CurlyPhi]i1[
               t]] (\[CurlyPhi]i2^\[Prime]\[Prime])[t] -
           0.2604 Sin[\[CurlyPhi]i2[t]] (\[CurlyPhi]i2^\[Prime]\[Prime])[
             t] +
           0.494053 Sin[
             1.41389 - \[CurlyPhi]o1[t]] (\[CurlyPhi]o1^\[Prime]\[Prime])[
             t])) + 2.8965 (0.2604 Sin[\[CurlyPhi]i2[t]] Derivative[
          1][\[CurlyPhi]i2][
          t] (-0.1302 Cos[\[CurlyPhi]i2[t]] Derivative[1][\[CurlyPhi]i2][
             t] + 0.1092 Derivative[1][\[CurlyPhi]o1][t] -
           0.494053 Sin[1.41389 - \[CurlyPhi]o1[t]] Derivative[
             1][\[CurlyPhi]o1][t]) -
        0.2604 Cos[\[CurlyPhi]i2[t]] Derivative[1][\[CurlyPhi]i2][
          t] (-0.1302 Sin[\[CurlyPhi]i2[t]] Derivative[1][\[CurlyPhi]i2][
             t] + 0.494053 Sin[1.41389 - \[CurlyPhi]o1[t]] Derivative[
             1][\[CurlyPhi]o1][t]) -
        0.2604 Cos[\[CurlyPhi]i2[
           t]] (0.1302 Sin[\[CurlyPhi]i2[t]] Derivative[1][\[CurlyPhi]i2][
             t]^2 + 0.494053 Cos[1.41389 - \[CurlyPhi]o1[t]] Derivative[
             1][\[CurlyPhi]o1][t]^2 -
           0.1302 Cos[\[CurlyPhi]i2[t]] (\[CurlyPhi]i2^\[Prime]\[Prime])[
             t] + 0.1092 (\[CurlyPhi]o1^\[Prime]\[Prime])[t] -
           0.494053 Sin[
             1.41389 - \[CurlyPhi]o1[t]] (\[CurlyPhi]o1^\[Prime]\[Prime])[
             t]) -
        0.2604 Sin[\[CurlyPhi]i2[
           t]] (-0.1302 Cos[\[CurlyPhi]i2[t]] Derivative[
             1][\[CurlyPhi]i2][t]^2 -
           0.494053 Cos[1.41389 - \[CurlyPhi]o1[t]] Derivative[
             1][\[CurlyPhi]o1][t]^2 -
           0.1302 Sin[\[CurlyPhi]i2[t]] (\[CurlyPhi]i2^\[Prime]\[Prime])[
             t] + 0.494053 Sin[
             1.41389 - \[CurlyPhi]o1[t]] (\[CurlyPhi]o1^\[Prime]\[Prime])[
             t]))

    lagrange\[CurlyPhi]o1=
    28.7325 (-0.00761741 +
        Cos[\[Pi]/
          45] (0.0653683 Cos[\[CurlyPhi]o1[t]] -
           0.318726 Sin[\[CurlyPhi]o1[t]])) +
     28.7325 (-0.00761741 +
        Cos[\[Pi]/
          45] (0.0772161 Cos[\[CurlyPhi]o1[t]] -
           0.487984 Sin[\[CurlyPhi]o1[t]]) +
        Sin[\[Pi]/
          45] (-0.429658 Cos[\[CurlyPhi]o1[t]] -
           0.0118478 Sin[\[CurlyPhi]o1[t]])) +
     56.8293 (-0.00761741 +
        Cos[\[Pi]/
          45] (0.0772161 Cos[\[CurlyPhi]o1[t]] -
           0.487984 Sin[\[CurlyPhi]o1[t]]) +
        Sin[\[Pi]/
          45] (0.429658 Cos[\[CurlyPhi]o1[t]] -
           0.0118478 Sin[\[CurlyPhi]o1[t]])) +
     56.8293 (-0.00761741 +
        Cos[\[CurlyPhi]o1[t]] (0.0772161 Cos[\[CurlyPhi]o1[t]] -
           0.357784 Sin[\[CurlyPhi]o1[t]]) +
        Sin[\[Pi]/
          45] (-0.299458 Cos[\[CurlyPhi]o1[t]] -
           0.0118478 Sin[\[CurlyPhi]o1[t]]) - (0.1092 (1 -
              Cos[\[CurlyPhi]o1[t]]) + 0.466984 Cos[\[CurlyPhi]o1[t]] +
           0.0772161 Sin[\[CurlyPhi]o1[t]]) Sin[\[CurlyPhi]o1[t]]) -
     1.46445 (-0.0153456 Cos[0.728647 - \[CurlyPhi]o1[t]] Sin[
          0.728647 - \[CurlyPhi]o1[t]] Derivative[1][\[CurlyPhi]o1][
          t]^2 +
        0.175189 Cos[0.728647 - \[CurlyPhi]o1[t]] Derivative[
          1][\[CurlyPhi]o1][
          t] (0.1092 Derivative[1][\[CurlyPhi]o1][t] -
           0.0875946 Sin[0.728647 - \[CurlyPhi]o1[t]] Derivative[
             1][\[CurlyPhi]o1][t])) -
     2.8965 (-0.267938 Cos[1.35828 - \[CurlyPhi]o1[t]] Sin[
          1.35828 - \[CurlyPhi]o1[t]] Derivative[1][\[CurlyPhi]o1][t]^2 +
        0.732036 Cos[1.35828 - \[CurlyPhi]o1[t]] Derivative[
          1][\[CurlyPhi]o1][
          t] (0.1092 Derivative[1][\[CurlyPhi]o1][t] -
           0.366018 Sin[1.35828 - \[CurlyPhi]o1[t]] Derivative[
             1][\[CurlyPhi]o1][t])) -
     1.46445 (0.988106 Cos[1.41389 - \[CurlyPhi]o1[t]] Derivative[
          1][\[CurlyPhi]o1][
          t] (-0.169672 Cos[0.0698842 - \[CurlyPhi]i1[t]] Derivative[
             1][\[CurlyPhi]i1][t] +
           0.169672 Cos[0.0698842 - \[CurlyPhi]i1[t]] Derivative[
             1][\[CurlyPhi]i2][t] -
           0.2604 Cos[\[CurlyPhi]i2[t]] Derivative[1][\[CurlyPhi]i2][t] +
           0.1092 Derivative[1][\[CurlyPhi]o1][t] -
           0.494053 Sin[1.41389 - \[CurlyPhi]o1[t]] Derivative[
             1][\[CurlyPhi]o1][t]) -
        0.988106 Cos[1.41389 - \[CurlyPhi]o1[t]] Derivative[
          1][\[CurlyPhi]o1][
          t] (0.169672 Sin[0.0698842 - \[CurlyPhi]i1[t]] Derivative[
             1][\[CurlyPhi]i1][t] -
           0.169672 Sin[0.0698842 - \[CurlyPhi]i1[t]] Derivative[
             1][\[CurlyPhi]i2][t] -
           0.2604 Sin[\[CurlyPhi]i2[t]] Derivative[1][\[CurlyPhi]i2][t] +
           0.494053 Sin[1.41389 - \[CurlyPhi]o1[t]] Derivative[
             1][\[CurlyPhi]o1][t])) -
     2.8965 (0.988106 Cos[1.41389 - \[CurlyPhi]o1[t]] Derivative[
          1][\[CurlyPhi]o1][
          t] (-0.1302 Cos[\[CurlyPhi]i2[t]] Derivative[1][\[CurlyPhi]i2][
             t] + 0.1092 Derivative[1][\[CurlyPhi]o1][t] -
           0.494053 Sin[1.41389 - \[CurlyPhi]o1[t]] Derivative[
             1][\[CurlyPhi]o1][t]) -
        0.988106 Cos[1.41389 - \[CurlyPhi]o1[t]] Derivative[
          1][\[CurlyPhi]o1][
          t] (-0.1302 Sin[\[CurlyPhi]i2[t]] Derivative[1][\[CurlyPhi]i2][
             t] + 0.494053 Sin[1.41389 - \[CurlyPhi]o1[t]] Derivative[
             1][\[CurlyPhi]o1][t])) +
     i1 (\[CurlyPhi]o1^\[Prime]\[Prime])[t] +
     i2 (\[CurlyPhi]o1^\[Prime]\[Prime])[t] +
     1.46445 (-0.0306913 Cos[0.728647 - \[CurlyPhi]o1[t]] Sin[
          0.728647 - \[CurlyPhi]o1[t]] Derivative[1][\[CurlyPhi]o1][
          t]^2 + 0.175189 Cos[0.728647 - \[CurlyPhi]o1[t]] Derivative[
          1][\[CurlyPhi]o1][
          t] (0.1092 Derivative[1][\[CurlyPhi]o1][t] -
           0.0875946 Sin[0.728647 - \[CurlyPhi]o1[t]] Derivative[
             1][\[CurlyPhi]o1][t]) +
        0.0153456 Sin[
          0.728647 - \[CurlyPhi]o1[t]]^2 (\[CurlyPhi]o1^\[Prime]\[Prime])[
          t] + 2 (0.1092 -
           0.0875946 Sin[0.728647 - \[CurlyPhi]o1[t]]) (0.0875946 Cos[
             0.728647 - \[CurlyPhi]o1[t]] Derivative[1][\[CurlyPhi]o1][
             t]^2 + 0.1092 (\[CurlyPhi]o1^\[Prime]\[Prime])[t] -
           0.0875946 Sin[
             0.728647 - \[CurlyPhi]o1[
               t]] (\[CurlyPhi]o1^\[Prime]\[Prime])[t])) +
     2.8965 (-0.535877 Cos[1.35828 - \[CurlyPhi]o1[t]] Sin[
          1.35828 - \[CurlyPhi]o1[t]] Derivative[1][\[CurlyPhi]o1][t]^2 +
        0.732036 Cos[1.35828 - \[CurlyPhi]o1[t]] Derivative[
          1][\[CurlyPhi]o1][
          t] (0.1092 Derivative[1][\[CurlyPhi]o1][t] -
           0.366018 Sin[1.35828 - \[CurlyPhi]o1[t]] Derivative[
             1][\[CurlyPhi]o1][t]) +
        0.267938 Sin[
          1.35828 - \[CurlyPhi]o1[t]]^2 (\[CurlyPhi]o1^\[Prime]\[Prime])[
          t] + 2 (0.1092 -
           0.366018 Sin[1.35828 - \[CurlyPhi]o1[t]]) (0.366018 Cos[
             1.35828 - \[CurlyPhi]o1[t]] Derivative[1][\[CurlyPhi]o1][
             t]^2 + 0.1092 (\[CurlyPhi]o1^\[Prime]\[Prime])[t] -
           0.366018 Sin[
             1.35828 - \[CurlyPhi]o1[t]] (\[CurlyPhi]o1^\[Prime]\[Prime])[
             t])) + 1.46445 (0.988106 Cos[
          1.41389 - \[CurlyPhi]o1[t]] Derivative[1][\[CurlyPhi]o1][
          t] (-0.169672 Cos[0.0698842 - \[CurlyPhi]i1[t]] Derivative[
             1][\[CurlyPhi]i1][t] +
           0.169672 Cos[0.0698842 - \[CurlyPhi]i1[t]] Derivative[
             1][\[CurlyPhi]i2][t] -
           0.2604 Cos[\[CurlyPhi]i2[t]] Derivative[1][\[CurlyPhi]i2][t] +
           0.1092 Derivative[1][\[CurlyPhi]o1][t] -
           0.494053 Sin[1.41389 - \[CurlyPhi]o1[t]] Derivative[
             1][\[CurlyPhi]o1][t]) -
        0.988106 Cos[1.41389 - \[CurlyPhi]o1[t]] Derivative[
          1][\[CurlyPhi]o1][
          t] (0.169672 Sin[0.0698842 - \[CurlyPhi]i1[t]] Derivative[
             1][\[CurlyPhi]i1][t] -
           0.169672 Sin[0.0698842 - \[CurlyPhi]i1[t]] Derivative[
             1][\[CurlyPhi]i2][t] -
           0.2604 Sin[\[CurlyPhi]i2[t]] Derivative[1][\[CurlyPhi]i2][t] +
           0.494053 Sin[1.41389 - \[CurlyPhi]o1[t]] Derivative[
             1][\[CurlyPhi]o1][t]) +
        2 (0.1092 -
           0.494053 Sin[1.41389 - \[CurlyPhi]o1[t]]) (-0.169672 Sin[
             0.0698842 - \[CurlyPhi]i1[t]] Derivative[1][\[CurlyPhi]i1][
             t]^2 + 0.169672 Sin[0.0698842 - \[CurlyPhi]i1[t]] Derivative[
             1][\[CurlyPhi]i1][t] Derivative[1][\[CurlyPhi]i2][t] +
           0.2604 Sin[\[CurlyPhi]i2[t]] Derivative[1][\[CurlyPhi]i2][
             t]^2 + 0.494053 Cos[1.41389 - \[CurlyPhi]o1[t]] Derivative[
             1][\[CurlyPhi]o1][t]^2 -
           0.169672 Cos[
             0.0698842 - \[CurlyPhi]i1[
               t]] (\[CurlyPhi]i1^\[Prime]\[Prime])[t] +
           0.169672 Cos[
             0.0698842 - \[CurlyPhi]i1[
               t]] (\[CurlyPhi]i2^\[Prime]\[Prime])[t] -
           0.2604 Cos[\[CurlyPhi]i2[t]] (\[CurlyPhi]i2^\[Prime]\[Prime])[
             t] + 0.1092 (\[CurlyPhi]o1^\[Prime]\[Prime])[t] -
           0.494053 Sin[
             1.41389 - \[CurlyPhi]o1[t]] (\[CurlyPhi]o1^\[Prime]\[Prime])[
             t]) + 0.988106 Sin[
          1.41389 - \[CurlyPhi]o1[
            t]] (-0.169672 Cos[0.0698842 - \[CurlyPhi]i1[t]] Derivative[
             1][\[CurlyPhi]i1][t]^2 +
           0.169672 Cos[0.0698842 - \[CurlyPhi]i1[t]] Derivative[
             1][\[CurlyPhi]i1][t] Derivative[1][\[CurlyPhi]i2][t] -
           0.2604 Cos[\[CurlyPhi]i2[t]] Derivative[1][\[CurlyPhi]i2][
             t]^2 - 0.494053 Cos[1.41389 - \[CurlyPhi]o1[t]] Derivative[
             1][\[CurlyPhi]o1][t]^2 +
           0.169672 Sin[
             0.0698842 - \[CurlyPhi]i1[
               t]] (\[CurlyPhi]i1^\[Prime]\[Prime])[t] -
           0.169672 Sin[
             0.0698842 - \[CurlyPhi]i1[
               t]] (\[CurlyPhi]i2^\[Prime]\[Prime])[t] -
           0.2604 Sin[\[CurlyPhi]i2[t]] (\[CurlyPhi]i2^\[Prime]\[Prime])[
             t] + 0.494053 Sin[
             1.41389 - \[CurlyPhi]o1[t]] (\[CurlyPhi]o1^\[Prime]\[Prime])[
             t])) + 2.8965 (0.988106 Cos[
          1.41389 - \[CurlyPhi]o1[t]] Derivative[1][\[CurlyPhi]o1][
          t] (-0.1302 Cos[\[CurlyPhi]i2[t]] Derivative[1][\[CurlyPhi]i2][
             t] + 0.1092 Derivative[1][\[CurlyPhi]o1][t] -
           0.494053 Sin[1.41389 - \[CurlyPhi]o1[t]] Derivative[
             1][\[CurlyPhi]o1][t]) -
        0.988106 Cos[1.41389 - \[CurlyPhi]o1[t]] Derivative[
          1][\[CurlyPhi]o1][
          t] (-0.1302 Sin[\[CurlyPhi]i2[t]] Derivative[1][\[CurlyPhi]i2][
             t] + 0.494053 Sin[1.41389 - \[CurlyPhi]o1[t]] Derivative[
             1][\[CurlyPhi]o1][t]) +
        2 (0.1092 -
           0.494053 Sin[
             1.41389 - \[CurlyPhi]o1[t]]) (0.1302 Sin[\[CurlyPhi]i2[
              t]] Derivative[1][\[CurlyPhi]i2][t]^2 +
           0.494053 Cos[1.41389 - \[CurlyPhi]o1[t]] Derivative[
             1][\[CurlyPhi]o1][t]^2 -
           0.1302 Cos[\[CurlyPhi]i2[t]] (\[CurlyPhi]i2^\[Prime]\[Prime])[
             t] + 0.1092 (\[CurlyPhi]o1^\[Prime]\[Prime])[t] -
           0.494053 Sin[
             1.41389 - \[CurlyPhi]o1[t]] (\[CurlyPhi]o1^\[Prime]\[Prime])[
             t]) + 0.988106 Sin[
          1.41389 - \[CurlyPhi]o1[
            t]] (-0.1302 Cos[\[CurlyPhi]i2[t]] Derivative[
             1][\[CurlyPhi]i2][t]^2 -
           0.494053 Cos[1.41389 - \[CurlyPhi]o1[t]] Derivative[
             1][\[CurlyPhi]o1][t]^2 -
           0.1302 Sin[\[CurlyPhi]i2[t]] (\[CurlyPhi]i2^\[Prime]\[Prime])[
             t] + 0.494053 Sin[
             1.41389 - \[CurlyPhi]o1[t]] (\[CurlyPhi]o1^\[Prime]\[Prime])[
             t]))

    lagrangesolve =
     NDSolve[{lagrange\[CurlyPhi]i1 == 0, lagrange\[CurlyPhi]i2 == 0,
       lagrange\[CurlyPhi]o1 == 0, \[CurlyPhi]o1[0] == -\[Pi]/
        36, \[CurlyPhi]i1[0] == \[Pi]/18, \[CurlyPhi]i2[0] == \[Pi]/
        18, \[CurlyPhi]o1'[0] == 0.5, \[CurlyPhi]i1'[0] ==
        0, \[CurlyPhi]i2'[
         0] == -0.75}, {\[CurlyPhi]o1, \[CurlyPhi]i1, \[CurlyPhi]i2}, {t,
       0, 100}]
     
    thanks for your consideration...
     
    Last edited by a moderator: Jun 26, 2015
  7. Jun 26, 2015 #6

    Dale

    Staff: Mentor

    It looks like you have several occurrences of things like this
    Code (Text):

    \[CurlyPhi]o1^\[Prime]\[Prime]
     
    The problem with this is the exponent symbol ^ You do not want to raise Phi to the power of '', you want to take the second derivative of Phi. So this should either be
    Code (Text):

    Derivative[2][f][t]
     
    or
    Code (Text):

    f''[t]
     
    Btw, when you have strange evaluation errors, one very useful function is "FullForm" which will show the internal representation of your code. It is also helpful for posting here so that there isn't any copy-paste "mangling" by the clip board.
     
  8. Jun 27, 2015 #7

    Thank you very much DaleSpam. now it works correctly but i want to know if there is a problem when it gives me the answer but also say :

    NDSolve::ntdvdae: Cannot solve to find an explicit formula for the derivatives. NDSolve will try solving the system as differential-algebraic equations. >>

    can it make a problem for me?!
     
  9. Jun 27, 2015 #8

    Dale

    Staff: Mentor

    You may have some loss of precision due to using different techniques that are less precise but more flexible. I would simply check the precision at the end to make sure it is enough.
     
  10. Jun 27, 2015 #9
    Thank you DaleSpam... :)
     
  11. Jul 18, 2015 #10
    Hello dear Dale
    recently i had written a code in mathematica and used NDSolve to solve equations as below :

    \[Gamma] = 0.01;
    equ1 = \[Theta]''[t] - Sin[\[Theta][t] - \[Gamma]];
    equ2 = -\[CurlyPhi]''[t] + \[Theta]''[
    t] + (\[Theta]'[t])^2 Sin[\[CurlyPhi][t]] -
    Cos[\[Gamma] - \[Theta][t]] Sin[\[CurlyPhi][t]];
    equ = NDSolve[{equ1 == 0,
    equ2 == 0, \[Theta][0] == 0.207347739624690, \[CurlyPhi][0] ==
    0.414695479249380, \[Theta]'[
    0] == -0.206130845238664, \[CurlyPhi]'[
    0] == -0.017471844666685}, {\[Theta], \[CurlyPhi]}, {t, 0, 5},
    MaxSteps -> 100000]

    and it gives me two interpolating function :

    {{\[Theta] -> \!\(\*
    TagBox[
    RowBox[{"InterpolatingFunction", "[",
    RowBox[{
    RowBox[{"{",
    RowBox[{"{",
    RowBox[{"0.`", ",", "5.`"}], "}"}], "}"}], ",", "\<\"<>\"\>"}], "]"}],
    False,
    Editable->False]\), \[CurlyPhi] -> \!\(\*
    TagBox[
    RowBox[{"InterpolatingFunction", "[",
    RowBox[{
    RowBox[{"{",
    RowBox[{"{",
    RowBox[{"0.`", ",", "5.`"}], "}"}], "}"}], ",", "\<\"<>\"\>"}], "]"}],
    False,
    Editable->False]\)}}

    now i want to check the situation that "Phi" will be equal to "2*Theta" in an "if". but i dont know how i can find the "t" that satisfies this condition when i just have two interpolating function?
    can you help me pls Dale?
     
  12. Jul 18, 2015 #11
    Hello dear Dale
    recently i had written a code in mathematica and used NDSolve to solve equations as below :

    \[Gamma] = 0.01;
    equ1 = \[Theta]''[t] - Sin[\[Theta][t] - \[Gamma]];
    equ2 = -\[CurlyPhi]''[t] + \[Theta]''[
    t] + (\[Theta]'[t])^2 Sin[\[CurlyPhi][t]] -
    Cos[\[Gamma] - \[Theta][t]] Sin[\[CurlyPhi][t]];
    equ = NDSolve[{equ1 == 0,
    equ2 == 0, \[Theta][0] == 0.207347739624690, \[CurlyPhi][0] ==
    0.414695479249380, \[Theta]'[
    0] == -0.206130845238664, \[CurlyPhi]'[
    0] == -0.017471844666685}, {\[Theta], \[CurlyPhi]}, {t, 0, 5},
    MaxSteps -> 100000]

    and it gives me two interpolating function :

    {{\[Theta] -> \!\(\*
    TagBox[
    RowBox[{"InterpolatingFunction", "[",
    RowBox[{
    RowBox[{"{",
    RowBox[{"{",
    RowBox[{"0.`", ",", "5.`"}], "}"}], "}"}], ",", "\<\"<>\"\>"}], "]"}],
    False,
    Editable->False]\), \[CurlyPhi] -> \!\(\*
    TagBox[
    RowBox[{"InterpolatingFunction", "[",
    RowBox[{
    RowBox[{"{",
    RowBox[{"{",
    RowBox[{"0.`", ",", "5.`"}], "}"}], "}"}], ",", "\<\"<>\"\>"}], "]"}],
    False,
    Editable->False]\)}}

    now i want to check the situation that "Phi" will be equal to "2*Theta" in an "if". but i dont know how i can find the "t" that satisfies this condition when i just have two interpolating function?
    can you help me pls Dale?
     
  13. Jul 18, 2015 #12

    Dale

    Staff: Mentor

    Hi arshia,

    My general philosophy when dealing with numerical functions is that graphical visualization of what is going on is the most important thing. So I would start with a plot of the equations over the full range:

    Plot[{2 \[Theta][t], \[CurlyPhi][t]} /. equ, {t, 0, 5}]

    From that plot you can see that there are two or three roots. The best way to find them is to use FindRoot. Looking at the plot there appears to be a root near t=0.1, t=2., and t=4. So I would use:

    FindRoot[(2 \[Theta][t] == \[CurlyPhi][t]) /. equ, {t, .1}]

    FindRoot[(2 \[Theta][t] == \[CurlyPhi][t]) /. equ, {t, 2.}]

    FindRoot[(2 \[Theta][t] == \[CurlyPhi][t]) /. equ, {t, 4.}]
     
  14. Jul 18, 2015 #13

    This is a good idea but in fact in my general code i have a "for" loop that must finds this roots automatically in each loop and we know that the figure changes. then i cant define the starting point for FindRoot. have you any idea for it?
    regards
     
  15. Jul 18, 2015 #14

    Dale

    Staff: Mentor

    All I can think of would be to put FindRoot inside a function which would loop over possible starting points for FindRoot and then return all unique roots.
     
  16. Jul 19, 2015 #15
    ok, thank you very much DaleSpam
     
  17. Jul 19, 2015 #16

    Dale

    Staff: Mentor

    By the way. What are you doing with multiple roots? Are you keeping all of them, or are you selecting one? If you are selecting one, what criteria are you using?
     
  18. Jul 21, 2015 #17
    i wrote a new code that have a limiting condition for finding roots and it works correctly in general. but i recently faced with some points that FindRoot could not find a solution for them even though in fact we know it has a solution ! my code is as below for i,j,k,l as defined :

    -------------------------------------------------------------------------------
    \[Gamma] = 0.01;
    equ1 = \[Theta]''[t] - Sin[\[Theta][t] - \[Gamma]];
    equ2 = -\[CurlyPhi]''[t] + \[Theta]''[
    t] + (\[Theta]'[t])^2 Sin[\[CurlyPhi][t]] -
    Cos[\[Gamma] - \[Theta][t]] Sin[\[CurlyPhi][t]];
    array = {{"i", "j", "k", "l", "time", "\[Theta]t[[1]]",
    "\[CurlyPhi]t[[1]]", "\[Theta]dott[[1]]", "\[CurlyPhi]dott[[1]]"}};
    o = 0;

    i = 1;
    j = 1;
    k = 3;
    l = 6;

    equ = NDSolve[{equ1 == 0,
    equ2 == 0, \[Theta][0] == 0.15 + i/100, \[CurlyPhi][0] ==
    0.375 + j/100, \[Theta]'[0] == -0.15 - k/100, \[CurlyPhi]'[0] ==
    0.00 - l/100}, {\[Theta], \[CurlyPhi]}, {t, 0, 5},
    MaxSteps -> 100000];
    For[\[Tau] = 1, \[Tau] <
    251, \[Tau]++, \[Theta]t = \[Theta][\[Tau]/50] /.
    equ; \[CurlyPhi]t = \[CurlyPhi][\[Tau]/50] /. equ;
    If[2.00 \[Theta]t[[1]] < \[CurlyPhi]t[[1]] <
    1.90 \[Theta]t[[1]] && \[Theta]t[[1]] < 0,
    time = (FindRoot[(2 \[Theta][t] == \[CurlyPhi][t]) /.
    equ, {t, (\[Tau]/50)}]); time = t /. time;
    If[0 < time <
    5, \[Theta]t = \[Theta][time] /.
    equ; \[CurlyPhi]t = \[CurlyPhi][time] /. equ; Break[],
    time = 0.25; \[Theta]t = \[Theta][time] /.
    equ; \[CurlyPhi]t = \[CurlyPhi][time] /. equ;],
    time = 0.25; \[Theta]t = \[Theta][time] /.
    equ; \[CurlyPhi]t = \[CurlyPhi][time] /. equ;]];

    time

    If[2 \[Theta]t == \[CurlyPhi]t, \[Theta]t = \[Theta][time] /.
    equ; \[CurlyPhi]t = \[CurlyPhi][time] /.
    equ; \[Theta]dott = \[Theta]'[time] /.
    equ; \[CurlyPhi]dott = \[CurlyPhi]'[time] /. equ;
    array = Append[
    array, {i, j, k, l,
    time, \[Theta]t[[1]], \[CurlyPhi]t[[1]], \[Theta]dott[[
    1]], \[CurlyPhi]dott[[1]]}]; o = o + 1;]

    \[Theta]t

    \[CurlyPhi]t

    \[Theta]dott

    \[CurlyPhi]dott

    o
    --------------------------------------------------------

    as you see , FindRoot can not find any answer even though it has...!

    the error is :

    InterpolatingFunction::dmval: Input value {7.33381} lies outside the range of data in the interpolating function. Extrapolation will be used. >>
    InterpolatingFunction::dmval: Input value {7.33381} lies outside the range of data in the interpolating function. Extrapolation will be used. >>
    InterpolatingFunction::dmval: Input value {-3.67762} lies outside the range of data in the interpolating function. Extrapolation will be used. >>
    The line search decreased the step size to within tolerance specified \
    by AccuracyGoal and PrecisionGoal but was unable to find a sufficient \
    decrease in the merit function. You may need more than MachinePrecision digits of working precision to meet these \
    tolerances. >>

    note that it gives me an answer " {t -> 2.32069} " but this answer does not satisfy my conditions(equality) and for this, o does not change as we expect.
    i completely confused !
     
  19. Jul 21, 2015 #18
    i dont know what this error means(i know its definition but also know no number lies out of the range in my code) and why occurs. have you any idea for this problem?
     
    Last edited: Jul 21, 2015
  20. Jul 21, 2015 #19

    Dale

    Staff: Mentor

    It looks to me like Mathematica is correct. It does not have a root. After the call to NDSolve run this:

    Plot[(2 \[Theta][t] - \[CurlyPhi][t]) /. equ, {t, 0, 5}]

    and then

    FindMaximum[(2 \[Theta][t] - \[CurlyPhi][t]) /. equ, {t, 2.5}]

    You see that it gets close to 0, but does not actually reach 0. The equation does not have a root in the range 0 to 5.
     
  21. Jul 22, 2015 #20
    yes but my problem is not about having solution or not, the problem is the error:

    InterpolatingFunction::dmval: Input value {7.33381} lies outside the range of data in the interpolating function. Extrapolation will be used. >>

    nowhere in my code "t" lies out of the range. my t range is 0 to 5. why FindRoot goes and checks 7.33381 that is out of range...?
    thank for your concentration
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Mathematica NDSolve
  1. Mathematica NDSolve (Replies: 1)

  2. NDSolve in Mathematica (Replies: 3)

  3. Mathematica NDSolve (Replies: 3)

Loading...