Why does Mathematica return $Failed with this function definition?
This function is from an answer in my previous post and it was working well.
I'm using Mathematica 13 on Windows 64 bit.

 capacitor[{a1_, a2_}] := Block[{d, l, nd, res, s, t}, d = a2 - a1;
      l = Norm[d];
      s = a1 (1 - 4.5/9) + a2 4.5/9;
      t = a1 (1 - 5/9) + a2 5/9;
      nd = l/15 RotationTransform[Pi/2][Normalize[d]];
      res = Line[{{s + nd, s - nd}, {t + nd, t - nd}}];
      {Thick, Darker[Green], Line[{{a1, s}, {t, a2}}], Brown, res}]

1 Answer 1


It does work for me as expected - I'm using Wolfram Desktop 13.1 on macOS:

enter image description here

  • $\begingroup$ I was thinking it's my problem but afraid to restart Mathematica as I'll have to restart many programs. $\endgroup$
    – hana
    Nov 10, 2022 at 23:07
  • $\begingroup$ What specific code produces $Failed? Just the definition above, or an attempt to use it? Can you post the code you are trying to run if it's the latter? $\endgroup$
    – Victor K.
    Nov 10, 2022 at 23:09
  • $\begingroup$ The definition alone returns failed. $\endgroup$
    – hana
    Nov 10, 2022 at 23:11
  • 2
    $\begingroup$ I tried Remove[capacitor] and then excute the function definition again and it works! $\endgroup$
    – hana
    Nov 10, 2022 at 23:37
  • 1
    $\begingroup$ @hana this is a good illustration of why it is good practice to ClearAll your function names before you define them. In this case, you would write something like ClearAll[capacitor]; in the line before your definition of capacitor. $\endgroup$ Nov 11, 2022 at 5:15

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.