1
$\begingroup$

I'm new to Mathematica and I'm trying to plot a interactive graph of a curve with a slider that shows the tangent to the curve in whichever point of the interval, my implementation is

curveC = {(-1 + t^3)/(1 + t^2), t/2 - 2 t^2};
intervalC = {-1, 1}
tangentC = D[curveC, t]
Manipulate[
Show[ParametricPlot[{curveC[t], {t, interval[[1]], interval[[2]]}},
  PlotStyle -> {Blue, Thick}],
Graphics[{  {Thick, Darker @ Red, Arrow[{curveC[s], curveC[s] + tangentC[s]}]}
  }]], {s, -1, 1}]

and I recieve the following error

Coordinate {(1 + $CellContext`t^2)^(-1) (-1 + $CellContext`t^3), Rational[1, 2] $CellContext`t - 2 $CellContext`t^2}[-1] should be a pair of numbers, or a Scaled or Offset form.

I don't know what that error means.

$\endgroup$
2
  • 1
    $\begingroup$ (1) remove the outer curly braces from {curveC[t], {t, interval[[1]], interval[[2]]}}; (2) replace interval with intervalC ; (3) Use curveC[t_] = ... and tangentC[t_] = ... when defining these functions; and -- just in case -- (4) use ClearAll[curveC, tangentC] at the start of your code block. $\endgroup$
    – kglr
    Commented Oct 19, 2023 at 20:13
  • $\begingroup$ thank you for the reply, I fixed it accordingly and I still got the same error $\endgroup$
    – Weyr124
    Commented Oct 19, 2023 at 20:32

1 Answer 1

1
$\begingroup$
curveC = {(-1 + t^3)/(1 + t^2), t/2 - 2 t^2};
intervalC = {-1, 1}
tangentC = D[curveC, t]

Manipulate[
 Show[ParametricPlot[curveC, {t, intervalC[[1]], intervalC[[2]]}, 
    PlotStyle -> {Blue, Thick}], 
  Graphics[{{Thick, Darker @ Red, 
     Arrow[{curveC, curveC + tangentC} /. t -> s]}}]], {s, -1, 1}]

enter image description here

$\endgroup$
2
  • 1
    $\begingroup$ I figured it out on my own and arrived at the same solution, yours is more elegant however. Thank you for your help! $\endgroup$
    – Weyr124
    Commented Oct 21, 2023 at 9:43
  • $\begingroup$ @Benjamin, my pleasure. Thank you for the accept. $\endgroup$
    – kglr
    Commented Oct 21, 2023 at 9:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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