Let's say, I do this:

n = 1.0002923;
ζA = FromDMS[{17, 14, 32}];
ζB = FromDMS[{67, 29, 51}];
δ = 
 1/2 π - 
  1/2 ((ζA + ζB) + n*(Tan[ζA] + Tan[ζB]))
ϕ = 1/2 π + 
  1/2 ((ζA - ζB) + n*(Tan[ζA] - Tan[ζB]))

(* -65.1739

-20.5667 )*

Then I write:

Solve[{ϕ - δ == ζA + 
    n*Tan[ζA], π - ϕ - δ == ζB + 
    Tan[ζB]}, {ϕ, δ}]

And the output is:

During evaluation of In[273]:= Solve::ivar: -20.5667 is not a valid variable. >>

Out[273]= Solve[{True, False}, {-20.5667, -65.1739}]

The only thing I can do is either completely close Mathematica and then run just Solve, or change the variables in Solve into some, I have never used since starting Mathematica. This is a very annoying issue and I admit, I am too ignorant to know why it is happening. I am not claiming this to be bug and I think the more experienced and knowledgeable will tell me this is to be expected, it changes little on the annoyance of this problem. So, can someone please 1. explain me, why this is happening and 2. how to properly use Solve and other constructs that are susceptible to this issue without using a new symbol each time? I cannot and do not want to keep track of all the symbols I have defined since starting Mathematica, and the problem is, opening new notebook solves absolutely nothing. Also, I think it is quite reasonable to use the same symbols to describe the same quantities in a given problem...


2 Answers 2


The variables given to Solve has to be symbols. For example you can't do something like this:


In your case, ϕ and δ are already expressions containing other symbols. You can either clear these variables before solving, using Clear[ϕ, δ], or you can wrap Solve in a module as follows:

Module[{ϕ, δ}], 
 Solve[{ϕ - δ == ζA + n*Tan[ζA], π - ϕ - δ == ζB + Tan[ζB]},{ϕ, δ}]

Mathematica remembers what you tell it, as long as the kernel is still running.

You are asking Mathematica to find the values of ϕ and δ that solve those equations. However, you already told Mathematica what the value of ϕ and δ are. So there is no problem for Mathematica to solve, and Solve can do nothing.

There are several ways to make Mathematica forget about these variables.

  1. Quit the kernel. (On the "Evaluation" menu.) Mathematica forgets everything.

  2. Use ClearAll[ϕ,δ]. Mathematica will forget everything it knows about ϕ and δ.

  3. Use Module[ {ϕ,δ}, ... ] and Mathematica will think these are new variables inside the Module statement.

  • $\begingroup$ Ad 1. Quit[]. $\endgroup$
    – corey979
    Commented Oct 15, 2016 at 9: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.