如何使用 \def\func(#1,#2...) 构建函数 f(g(h(...)))?

如何使用 \def\func(#1,#2...) 构建函数 f(g(h(...)))?
\usepackage{tikz,pgfplots}
\pgfplotsset{compat=1.11}

\def\g(#1,#2,#3,#4,#5,#6,#7,#8,#9){(#6)*exp((#2)/(#7))+((#6)**2)*exp(2*(#2)/(#7))*(#9)*exp((#4)/(#7)}%

\def\f(#1,#2,#3,#4,#5,#6,#7,#8,#9){1+2*(#6)*exp((#2)/(#7))+((#6)**2)*exp(2*(#2)/(#7))*exp((#4)/(#7))}%

\def\b(#1,#2,#3,#4,#5,#6,#7,#8,#9){exp(-(#3)/(#7))+(#6)*exp(-(#2)/(#7))*exp((#5)/(#7))*exp(-(#3)/(#7))*(1-(#8)*((\f(#1,#2,#3,#4,#5,#6,#7,#8,#9) )/(\g(#1,#2,#3,#4,#5,#6,#7,#8,#9) ))))}%

\def\c(#1,#2,#3,#4,#5,#6,#7,#8,#9){exp(-(#3)/(#7))*(\f(#1,#2,#3,#4,#5,#6,#7,#8,#9) )}%

\def\v(#1,#2,#3,#4,#5,#6,#7,#8,#9){exp((#1)/(#7))*(-(\b(#1,#2,#3,#4,#5,#6,#7,#8,#9) )+\sqrt{ (\b(#1,#2,#3,#4,#5,#6,#7,#8,#9) )**2+\c(#1,#2,#3,#4,#5,#6,#7,#8,#9) })*10**3}%   

\begin{document}
\begin{tikzpicture}

\begin{axis}[
           xlabel= $\Updelta \upepsilon_I (K_BT) $,
            ylabel=${IC_{50}(mM)}$ / ${[H_2O]}$,
            legend pos=north west,
             grid=major , ymax=20, ymin=0, xmax=-4, xmin=-8] 


 \addlegendimage{empty legend}\addlegendentry[font=\footnotesize ]{$\Updelta \upepsilon_S=-5K_BT $}

%%%%%%%%% MENOS SUBSTRATO %%%%%%%%%%%%
    \addplot[blue,mark=none,
         domain=-8:-3,samples=300, line width=1]
    gnuplot{\v(x,5.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0) };\addlegendentry[font=\footnotesize ]{${[S]}$/${[H_2O]}$$=10^{-6}$}

%%%%%%%%% MAIS SUBSTRATO %%%%%%%%%%%%
   \addplot[red,mark=none,
         domain=-8:-3,samples=300, line width=1]
    gnuplot{\v(x,5,0,0,0,2,1,1,1) };\addlegendentry[font=\footnotesize ]{${[S]}$/${[H_2O]}$$=10^{-2}$}

 %\addlegendentry{Velocidade Normalizada}  
\end{axis}

\end{tikzpicture}

答案1

你的方法很有效如果在 的定义\sqrt{...}中用替换。sqrt(...)\v

\documentclass{standalone}
\usepackage{upgreek}
\usepackage{tikz,pgfplots}
\pgfplotsset{compat=1.11}

\def\g(#1,#2,#3,#4,#5,#6,#7,#8,#9){(#6)*exp((#2)/(#7))+((#6)**2)*exp(2*(#2)/(#7))*(#9)*exp((#4)/(#7)}%

\def\f(#1,#2,#3,#4,#5,#6,#7,#8,#9){1+2*(#6)*exp((#2)/(#7))+((#6)**2)*exp(2*(#2)/(#7))*exp((#4)/(#7))}%

\def\b(#1,#2,#3,#4,#5,#6,#7,#8,#9){exp(-(#3)/(#7))+(#6)*exp(-(#2)/(#7))*exp((#5)/(#7))*exp(-(#3)/(#7))*(1-(#8)*((\f(#1,#2,#3,#4,#5,#6,#7,#8,#9) )/(\g(#1,#2,#3,#4,#5,#6,#7,#8,#9) ))))}%

\def\c(#1,#2,#3,#4,#5,#6,#7,#8,#9){exp(-(#3)/(#7))*(\f(#1,#2,#3,#4,#5,#6,#7,#8,#9) )}%

\def\v(#1,#2,#3,#4,#5,#6,#7,#8,#9){exp((#1)/(#7))*(-(\b(#1,#2,#3,#4,#5,#6,#7,#8,#9)
)+sqrt( (\b(#1,#2,#3,#4,#5,#6,#7,#8,#9) )**2+\c(#1,#2,#3,#4,#5,#6,#7,#8,#9) ))*10**3}%   
\begin{document}
\begin{tikzpicture}

\begin{axis}[
           xlabel= $\Updelta \upepsilon_I (K_BT) $,
            ylabel=${IC_{50}(mM)}$ / ${[H_2O]}$,
            legend pos=north west,
             grid=major ,% ymax=2000, ymin=0, 
             xmax=-4, xmin=-8] 


 \addlegendimage{empty legend}
 \addlegendentry[font=\footnotesize ]{$\Updelta \upepsilon_S=-5K_BT $}


%%%%%%%%% MENOS SUBSTRATO %%%%%%%%%%%%
\addplot [
        blue,id=DoG,
        samples=100,domain=-8:-4,
    ] gnuplot {1.3*exp(-x**2/10) - exp(-x**2/20)};

     \addplot[blue,mark=none,
         domain=-8:-4,samples=300, line width=1]
   gnuplot {\v(x,5.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0)};
    \addlegendentry[font=\footnotesize ]{${[S]}/{[H_2O]}=10^{-6}$}

% %%%%%%%%% MAIS SUBSTRATO %%%%%%%%%%%%
   \addplot[red,mark=none,
         domain=-8:-4,samples=300, line width=1] 
   gnuplot {\v(x,5,0,0,0,2,1,1,1) };
    \addlegendentry[font=\footnotesize ]{${[S]}/{[H_2O]}=10^{-2}$}

 %\addlegendentry{Velocidade Normalizada}  
\end{axis}

\end{tikzpicture}
\end{document}

在此处输入图片描述

为了完整性,你可以f(g(...))使用 TiZ 的declare function。也就是说,原则上 TiZ 有针对这种情况的命令。如果没有gnuplot,我需要稍微限制一下你的图的范围,因为你的函数似乎爆炸了。

\documentclass{standalone}
\usepackage{upgreek}
\usepackage{tikz,pgfplots}
\pgfplotsset{compat=1.11}

%
\tikzset{declare
function={g(\Xa,\Xb,\Xc,\Xd,\Xe,\Xf,\Xg,\Xh,\Xj)=(\Xf)*exp((\Xb)/(\Xg))+((\Xf)^2)*exp(2*(\Xb)/(\Xg))*(\Xj)*exp((\Xd)/(\Xg);}}%

\tikzset{declare
function={f(\Xa,\Xb,\Xc,\Xd,\Xe,\Xf,\Xg,\Xh,\Xj)=1+2*(\Xf)*exp((\Xb)/(\Xg))+((\Xf)^2)*exp(2*(\Xb)/(\Xg))*exp((\Xd)/(\Xg));}}%

\tikzset{declare
function={b(\Xa,\Xb,\Xc,\Xd,\Xe,\Xf,\Xg,\Xh,\Xj)=exp(-(\Xc)/(\Xg))+(\Xf)*exp(-(\Xb)/(\Xg))*exp((\Xe)/(\Xg))*exp(-(\Xc)/(\Xg))*(1-(\Xh)*((f(\Xa,\Xb,\Xc,\Xd,\Xe,\Xf,\Xg,\Xh,\Xj)
)/(g(\Xa,\Xb,\Xc,\Xd,\Xe,\Xf,\Xg,\Xh,\Xj) ))));}}%

\tikzset{declare
function={c(\Xa,\Xb,\Xc,\Xd,\Xe,\Xf,\Xg,\Xh,\Xj)=exp(-(\Xc)/(\Xg))*(f(\Xa,\Xb,\Xc,\Xd,\Xe,\Xf,\Xg,\Xh,\Xj)
);}}%

\tikzset{declare
function={v(\Xa,\Xb,\Xc,\Xd,\Xe,\Xf,\Xg,\Xh,\Xj)=exp((\Xa)/(\Xg))*(-(b(\Xa,\Xb,\Xc,\Xd,\Xe,\Xf,\Xg,\Xh,\Xj)
)+sqrt(
(b(\Xa,\Xb,\Xc,\Xd,\Xe,\Xf,\Xg,\Xh,\Xj))^2+
c(\Xa,\Xb,\Xc,\Xd,\Xe,\Xf,\Xg,\Xh,\Xj)))*10^3;}}%   

\begin{document}
\begin{tikzpicture}

\begin{axis}[
           xlabel= $\Updelta \upepsilon_I (K_BT) $,
            ylabel=${IC_{50}(mM)}$ / ${[H_2O]}$,
            legend pos=north west,
             grid=major , %ymax=20, ymin=0, 
             xmax=-4, xmin=-8] 


 \addlegendimage{empty legend}
 \addlegendentry[font=\footnotesize ]{$\Updelta \upepsilon_S=-5K_BT $}

%%%%%%%%% MENOS SUBSTRATO %%%%%%%%%%%%
    \addplot[blue,mark=none,
         domain=-8:-5,samples=300, line width=1] 
    ({\x},{v(\x,5.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0)});
    \addlegendentry[font=\footnotesize ]{${[S]}/{[H_2O]}=10^{-6}$}

% %%%%%%%%% MAIS SUBSTRATO %%%%%%%%%%%%
   \addplot[red,mark=none,
         domain=-8:-5,samples=300, line width=1] 
    {v(x,5,0,0,0,2,1,1,1) };
    \addlegendentry[font=\footnotesize ]{${[S]}/{[H_2O]}=10^{-2}$}

 %\addlegendentry{Velocidade Normalizada}  
\end{axis}

\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容