# Complicated function on TIKZ, Error: “Cannot calculate the log of negative number”

I try to graph the following function, but it gives me the error "cannot calculate the log of negative number.

\begin{document}
\usepackage{pgfplots}
\usetikzlibrary{fixedpointarithmetic}
\begin{minipage}{0.48\textwidth}
\begin{tikzpicture}[scale=1.3]
\clip (-0.7,-0.5) rectangle (4,4);
{
\draw[\Col, \dashing] plot[domain=0:4, range=0:4, variable=\x,samples=90] ({\x},{max(3*log10(\x+0.23)+4*(\x-0.35)^0.1-2.6+0.67*(\x-0.35)^1.63/12,0)});
}
\draw (0,0) rectangle (4,4);
\draw [dotted] (1,0) node[below]{$1$} -- (1,4);
\draw [dotted] (0,1.1) node[left]{$0.5$} -- (4,1.1);
\node at (3.6,-.2) {$v_i$};
\node at (-.4,3.85) {q};
\end{tikzpicture}
\end{minipage}
\end{figure}
\end{document}

How do I fix this?

• (x-0.35)^0.1 actually uses exp(0.1*log(x-0.35)) hence x>0.35 is the domain. – John Kormylo Sep 11 '18 at 13:24

Just spelling out what John Kormylo mentioned. You cannot take a negative number to a fractional power.

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfplots,fp}
\usetikzlibrary{fixedpointarithmetic}
\begin{document}
\begin{tikzpicture}[scale=1.3]
\clip (-0.7,-0.5) rectangle (4,4);
{
\draw%[\Col, \dashing]
plot[domain=0:4, range=0:4, variable=\x,samples=90]
({\x},{max(3*log10(\x+0.23)+4*(abs(\x-0.35))^0.1-2.6+0.67*(abs(\x-0.35))^1.63/12,0)});
}
\draw (0,0) rectangle (4,4);
\draw [dotted] (1,0) node[below]{$1$} -- (1,4);
\draw [dotted] (0,1.1) node[left]{$0.5$} -- (4,1.1);
\node at (3.6,-.2) {$v_i$};
\node at (-.4,3.85) {q};
\end{tikzpicture}
\end{document}