為什麼使用外部函數會導致崩潰?

為什麼使用外部函數會導致崩潰?

大家好,這裡是 MWE:

    \documentclass[border=2pt]{standalone}
    \usepackage[utf8]{inputenc}

    \usepackage{graphics}
    \usepackage{tikz,pgfplots}
    \usetikzlibrary{math} % Pour evaluate

    \def\FTUn(#1){1/( W*(#1-sqrt((#1*#1) -1)))}
    \def\FTDeux(#1){1/(W *(#1+sqrt((#1*#1) -1)))}
    \def\FSupAUn(#1,#2){ \Kg * (1 - ( 1/( #1 - #2 ) )*( #1 *exp(-x/ #1 ) - #2 *exp(-x/ #2 ) ))   }

    \begin{document}
        \begin{tikzpicture}[  declare function={ W=pi*2;  }]
            \def\Kg{2}
            \def\Ezero{1}
            \def\Ttrace{3}
            \begin{axis}
                \addplot[thick=3pt,ultra thick,domain=0:(1/10),samples=50,
                evaluate={  \Tun = \FTUn(2) ;
                                \Tdeux =  \FTDeux(2); }
                ] {  \FSupAUn(\Tun, \Tdeux)  };
        %       ] {  \FSupAUn( \FTUn(2) , \FTDeux(2) )  };
            \end{axis}
        \end{tikzpicture}
    \end{document}

這工作正常,但使用註釋而不是上面的,你會得到:

TeX capacity exceeded, sorry [main memory size=5000000].

答案1

與 tikz 中的許多其他地方一樣,我們需要大括號來告訴它計算函數。

所以使用

{\FTUn(2)}

ETC。

(正如 Thorbjørn 在評論中提到的,整個問題可能是TikZ 參數解析器令人困惑。記住,如果遇到問題,()添加計算通常會有所幫助,這是一件好事){}

相關內容