I am fairly new in Mathematica and I am trying to work with scalars and vectors. I decided to denote vectors using OverVector (as example, OverVector[F]stands for the force). Any scalar is denoted by a symbol.

When an expression has a multiplication between scalar and vector, the expected outcome should be nullVector, but Mathematica evaluated this as zero. (I have been using Notation package and

Notation[OverVector[0]\[DoubleLongLeftRightArrow] nullVector]

nullVector stands for the zero vector)

How I can prevent Mathematica to evaluate Times[OverVector[F],0] as zero?

In other words. I need Mathematica evaluates the multiplication between vector and zero as the zero vector (nullVector) not as zero. How I can get this?

Thank you so much.


2 Answers 2


Using TagSetDelayed allows this definition to be associated with OverVector instead of Times:

OverVector /: Times[OverVector[_], 0] := nullVector
  • $\begingroup$ Many thanks @Marius. This works perfectly. $\endgroup$ Jan 4, 2016 at 2:13

One way is

Times[OverVector[_],0] = nullVector

though generally it's not a good idea to redefine built-in commands.

  • 1
    $\begingroup$ Thanks @Andrew, I think too it's not a good practice to redefine built-in commands. I´m cheking the code with the @Marius´s idea. $\endgroup$ Jan 4, 2016 at 2:18

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.