I'm using TikZ to plot several things (geometric surfaces, line plots, etc.) in just one environment. These plots depend on several constants that I define in the same tikzpicture environment. This is a (dummy) example:
\begin{tikzpicture}
\def\a{1}
\def\g{0.5}
\def\kamax{5}
\def\M{15}
\def\T{3}
\pgfmathsetmacro{\Ra}{1 + \a*\M^(1-\g)/\kamax}
\pgfmathsetmacro{\Rb}{1 + \a*\M^(1-\g)/(4*\kamax)}
\pgfmathsetmacro{\la}{\M/(2*\T*\Ra)}
\pgfmathsetmacro{\lb}{\M/(2*\T*\Rb)}
\begin{axis}[domain=0:\M/\T, xlabel = Rate of consumption, ylabel = Time of purchase, title = Optimal time to purchase, legend pos=north west, axis equal image]
\addplot[color=blue][domain=0:\la] {0};
\addplot[color=blue][domain=\la:\lb] {2*\T - (sqrt(2*\a*\kamax*\M^(1+\g)*\T*\x*(\M-2*\T*\x)))/(\a*\M*\x)};
\addplot[color=blue][domain=\lb:\M/\T] {\T};
\addplot[color=red] coordinates {(\la,0)(\la,\T)};
\addplot[color=red] coordinates {(\lb,0)(\lb,\T)};
\end{axis}
\end{tikzpicture}
In the example, the constants defined with \def are the "essential" constants of the problem I'm studying, and those defined with \pgfmathsetmacro are needed to make the plotting easier.
After plotting the example exposed before, I would like to change some of the values of the "essential" constants and plot the same five plots again (in the same environment) to compare results. My question is: is there a way to create macro or function that takes as input my "essential" constants and returns as output the other constants?
My objective is purely to simplify the .tex reading; if I redefine the constants in the same environment after plotting the .tex compiles just fine.
Thank you very much in advance.

\pgfmathsetmacroin a macro (via\newcommand) and call this macro when you have change your "essential" constants. – Paul Gaborit May 08 '17 at 23:09