Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Mathematica has produced the following error message:

Part::partd: Part specification ... is longer than depth of object?

What is partd?

I think I may have flattened or (unflattened) arrays and am not sure how to locate the exact object?

share|improve this question
Probably means that you are trying to access an array with more dimensions than it has (e.g. myArray[[i,j]] when myArray is a single dimension). – Guillochon Jan 16 '13 at 0:42
up vote 16 down vote accepted

Two of the most common error messages that users encounter when working with parts of lists are Part::partd and Part::partw (look up Message for the error message syntax). Both of these are because the user is trying to access an invalid part of the expression (the "object" referred to in the error message), but there's a subtle difference between the two:


This error occurs when you're trying to obtain a part of an expression at a position longer than the Length of the expression (or subexpression). For example:

exprw = {{a, b}, {c, d, e}};
exprw[[2, 3]]
(* e *)

exprw[[1, 3]]

Part::partw: "Part 3 of {a,b} does not exist"

You can see that we tried to access the third element of a two element list and this results in an error. In general, if you get a partw error, look at the size of your index and check if it makes sense to your application. If not, you've found the source of your error. If it does, then your application/model is most likely faulty and you might want to check that instead.


This error occurs when you're trying to index the expression at a depth deeper than the maximum depth of the expression. In general, you can index the elements of an expression at Level $n$ by using exactly $n$ indices and you can index any element in an expression of Depth $d$ with most $d-1$ indices. However, when you try to index an expression at a depth greater than its maximum depth or you try to access an element at level $n$ with more than $n$ indices (which again translates to deeper depth), you get a partd error. For example, consider:

exprd = {{a, b}, {c, d, {e}}};

The maximum depth or Depth[exprd] is 4. Now try indexing with 4 indices:

exprd[[1, 1, 1, 1]]

Part::partd: "Part specification {{a,b},{c,d,{e}}}[[1,1,1,1]] is longer than depth of object"

So if you get a partd error, check to see if you're using the right number of indices for the given expression.

share|improve this answer
Thanks this explains it quite well. – sebastian c. Jan 16 '13 at 10:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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