0
$\begingroup$

I am trying to graph a piecewise function composed of a series of parametric cubic functions. I initially created a ParametricPlot for the first four pieces of the equation and it was working fine, as shown below

ParametricPlot[
  Piecewise[
    {{{1.27 t^3 - 1.57 t + 0.62, -3.5 t^3 - 0.54 t + 0.76}, 
      0 < t <= 0.06}, 
     {{-0.62t^3 + 0.35t^2 - 1.59t + 0.62, 2.04t^3 - 1.03t^2 - 0.47t + 0.76}, 
      0.06 < t <= 0.15}, 
     {{1.49t^3 - 0.57t^2 - 1.45t + 0.61 ,-3.47t^3 + 1.39t^2 - 0.83t + 0.78  },   
      0.15 < t <= 0.31}, 
     {{14.35t^3 - 12.51t^2 + 2.24t + 0.23 , -3.89t^3 + 1.77t^2 - 0.95t + 0.79}, 
       0.31 < t <= .41}}], 
  {t, 0, .41}]

outputting this graph

enter image description here

However, once I added the next term and adjusted the ParametricPlot accordingly, it no longer worked.

The code:

ParametricPlot[
  Piecewise[
    {{{1.27 t^3 - 1.57 t + 0.62, -3.5 t^3 - 0.54 t + 0.76}, 
      0 < t <= 0.06}, 
     {{-0.62t^3 + 0.35t^2 - 1.59t + 0.62, 2.04t^3 - 1.03t^2 - 0.47t + 0.76}, 
      0.06 < t <= 0.15}, 
     {{1.49t^3 - 0.57t^2 - 1.45t + 0.61 ,-3.47t^3 + 1.39t^2 - 0.83t + 0.78  },   
      0.15 < t <= 0.31}, 
     {{14.35t^3 - 12.51t^2 + 2.24t + 0.23 , -3.89t^3 + 1.77t^2 - 0.95t + 0.79}, 
       0.31 < t <= .41},
     {{-5.93t^3 + 12.45t^2 - 8t + 1.63 ,13.95t^3 - 20.19t^2 + 8.07t - 0.44} 
      0.41 < t <= 0.49}, 
     {{6.62t^3 - 5.91t^2 + 0.94t + 0.18 , 2.96t^3 - 4.12t^2 + 0.23t + 0.83} 
      0.49 < t <= 0.53}}}], 
  {t,0,.53}]

with the following error message. The first one is repeated twice.

enter image description here enter image description here

and the last message reading:

General: Further output of Piecewise::pairs will be suppressed during this calculation.

While it seems that the issue is that the data is not in pairs, I do not understand why it worked for the first part and how to get it to continue working as I add more data. Did I just screw up putting it in?

$\endgroup$
  • $\begingroup$ You have made a simple typing mistake: you are omitting two commas from the last two segments that you added in 2nd example. You need commas before 0.41 < t <= 0.49 and 0.49 < t <= 0.53. $\endgroup$ – m_goldberg Jan 11 at 18:13
2
$\begingroup$

This is just to fill out what I already said in a comment to the question.

You have made a simple typing mistake. You are omitting two commas from the last two segments that you added in 2nd example. You need commas before 0.41 < t <= 0.49 and 0.49 < t <= 0.53 Here is how plot looks when those commas are inserted:

ParametricPlot[
  Piecewise[
    {{{1.27 t^3 - 1.57 t + 0.62, -3.5 t^3 - 0.54 t + 0.76},
      0 < t <= 0.06}, 
     {{-0.62 t^3 + 0.35 t^2 - 1.59 t + 0.62, 2.04 t^3 - 1.03 t^2 - 0.47 t + 0.76},
      0.06 < t <= 0.15}, 
     {{1.49 t^3 - 0.57 t^2 - 1.45 t + 0.61, -3.47 t^3 + 1.39 t^2 - 0.83 t + 0.78}, 
      0.15 < t <= 0.31}, 
     {{14.35 t^3 - 12.51 t^2 + 2.24 t + 0.23, -3.89 t^3 + 1.77 t^2 - 0.95 t + 0.79},
      0.31 < t <= .41}, 
     {{-5.93 t^3 + 12.45 t^2 - 8 t + 1.63, 13.95 t^3 - 20.19 t^2 + 8.07 t - 0.44}, 
      0.41 < t <= 0.49}, 
     {{6.62 t^3 - 5.91 t^2 + 0.94 t + 0.18, 2.96 t^3 - 4.12 t^2 + 0.23 t + 0.83},
      0.49 < t <= 0.53}}],
  {t, 0, .53}]

plot

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.