I do the calculus exercise. You wonder about the intersection, if any of `$e^x$` with `$u x + v$`. We examine the difference `$e^x- ux -v$`. It is a strictly convex function.
- if `$u<0$`, the function is strictly increasing and vanishes at a unique abscissa which will be the one of the your intersection point. Newton method whatever the starting point will converge to the root. Better to start on its right, I have not detailed more.
- if `$u=0$` we have horizontal lines, left to reader.
- if `$u>0$`, this time the difference is still convex but with a minimum. The value is `$u - u \log u - v$`. If this quantity is negative you have two intersection points, if it vanishes you have a tangent, if it is positive you have no intersection points. To find the intersection points do Newton method with either large positive or large negative starting point.
Hope it helps.
Edit: the starting point is crucial so the above is ill-advised to say "large starting point". Because as long as `$e^x$` is large Newton's method will simply do roughly `$x\mapsto x-1$` and take a long time to reach the root if you started too far (but I assume your real life examples have some reasonable bounds ,say `$-10<x<10$)`. If `$x$` is very negative (and slope `$u$` positive), then situation is better, because the studied function whose root is aimed at is quasi linear, so after one iteration we are near `$-v/u$` it seems and it should go fast (untested). So it seems to be easier to find the left-intersection point. In the case with negative slope, the sole intersection point can presumably be obtained starting Newton with the `$-v/u$` mentioned above. Well, may be not the place for a mathematical treatise, let's leave some work to the AIs.
## Mathematical treatise
I will focus on the case `u>0`. In order to analyze mathematically it is convenient to make a translation. The equation to solve is `e^x = ux+v`. Let `t= x+v/u`. On finds that the equation becomes `e^t = ct` with `c= u exp(v/u)`. This can be transformed if one so wishes into a Lambert-W function type of equation `-texp(-t)=-1/c` so `z exp(z)=-1/c` with `z=-t` I will not use that.
Geometrically, as `c>0` we see clearly that there is a `c_0` such that `c<c_0` give no solution, `c=c_0` one, and `c>c_0` gives two. It turns out that `c_o = e`: the line with slope `e` touches the exponential at point `(1,e)`. Thus we can say in advance that for `c>e` we will have a solution `w_1` in `(0,1)` and a solution `w_2>1`. This second solution is the most delicate because it probes when `c` increases the exponential regime.
Let's start with `w_1`. It is clear geometrically that it is larger than the abscissa of intersection of our line through the origin of slope `c` and the tangent to the exponential at `t=0` of slope `1`. So `w_1 > 1/(c-1)`. We are in the convex decreasing part of the difference `e^t - ct`, so put `t_0 = 1/(c-1)` and apply Newton iteration, this gives a strictly increasing sequence which should be efficient to find the limit `w_1`. The formula to iterate is `next(t) = (1-t)/(c exp(-t) - 1)`.
More challenging is finding `w_2`. We would like a starting point to the right of it. I convert the equation `e^t = c t` into the equation `t = d + log (t)`with `d = log(c) >1`. If we plot the line of equation `y = t-d` we want its intersection the graph of log with abscissa `w_2>1`. The difference `t - d - log(t)` is convex and increasing for `t>1` with zero slope at `t=1` and negative value `1-d` at `t=1`. We look for starting point sufficiently to the right but not too much so that Newton will not start from too far. Now if `d` is large, the solution should be approximately `t=d + log(d)`. In fact we see that iterating `t<- d+log(t)` will converge geometrically, and stay always to the left of the seeked root `w_2`. So perhaps do this a couple of times, then apply Newton which will give us a point on the right of `w_2` hopefully not too far and continue with Newton. So we set `t_0=d`, iterate a bunch of times
`t<- d +log(t)`, then switch to `next(t) = ((d-1)+log(t))/(1 - 1/t)`.
Posting this for now, a numerical example later.
## Numerical example
Please convert this into your favorite language. This handles only the equation `exp(t) = ct` with `c>exp(1)`.
```
\documentclass{article}
\usepackage{xintexpr}
\newcommand\SolveExpEqualLin[1]{%
\begingroup\long\def\STOP##1\endgroup{}%
\xintdeffloatvar c:= #1;%
\xintifboolexpr{c>exp(1)}
{}
{Bad input $\xintfloateval{c}$ not greater than $\exp(1)$, Aborting!\STOP}%
\xintdeffloatfunc f(t):=(1-t)/(c*exp(-t) - 1);%
\xintdeffloatvar tn:=1/(c-1);%
\xintdeffloatvar eps:=tn * 5e-16;%
\xintloop
\xintdeffloatvar new:=f(tn);%
\xintifboolexpr{abs(new-tn)<eps}
{\iffalse}%
% maybe not update eps?
{\xintdeffloatvar tn, eps :=new, new * 5e-16;\iftrue}
\repeat
\xintdeffloatvar w_1 := tn;%
%
\xintdeffloatfunc g(t):=log(c) + log(t);%
\xintdeffloatvar tn:=log(c);%
\xintdeffloatvar tn:=g(tn);%
\xintdeffloatvar tn:=g(tn);%
\xintdeffloatvar tn:=g(tn);%
\xintdeffloatvar eps:=tn* 5e-16;%
\xintdeffloatfunc k(t):=(g(t)-1)/(1 - 1/t);%
\xintloop
\xintdeffloatvar new:=k(tn);%
\xintifboolexpr{abs(new-tn)<eps}
{\iffalse}%
% maybe not update eps?
{\xintdeffloatvar tn, eps :=new, new * 5e-16;\iftrue}
\repeat
\xintdeffloatvar w_2 := tn;%
%
The solutions to the equation $\exp(t) = \xintfloateval{c}t$ are
$t_1\approx\xintfloateval[-1]{w_1}$ and $t_2\approx\xintfloateval[-1]{w_2}$.
\endgroup
\par
}
\begin{document}
\xintFor* #1 in {\xintSeq{1}{10}}\do{\SolveExpEqualLin{#1}}
\end{document}
```
[![solving exp(t)=ct][1]][1]
## With TikZ (general case)
The code is extended to handle all possibilities, I also declared once and for all some functions of two variables for efficiency, and was more careful in termination criterion for Newton's method. I am not nimble with TikZ and can not do easily some obvious improvements the displayed plots are in need of. Incidentally I found a bug of `\xintifsgnexpr` and had to renounce using it.
```
\documentclass[tikz,border=1cm]{standalone}
\usepackage{xintexpr}
\xintdeffloatfunc F(t,c) := (1-t)/(c*exp(-t) - 1);
\xintdeffloatfunc G(t,d) := d + log(t);
\xintdeffloatfunc K(t,d) := (G(t,d)-1)/(1 - 1/t);
\newcommand\SolveExpEqualLin[2]{%
\begingroup
\xintdeffloatvar u:= #1;%
\xintdeffloatvar v:= #2;%
% There appears to be a bug in XINT with \xintifsgnexpr
% when used with input starting with a zero. (I was
% skeptical but it seems to be real, I reported to maintainer
% and I am awaiting response).
\xintifboolexpr{u>0}
{\SolveExpEqualLinPos}%
{\xintifboolexpr{u<0}
{\SolveExpEqualLinNeg}
{\SolveExpEqualLinZero}}
\endgroup
}
% negative slope. Always exactly one root.
% Attention to computation of epsilon. If the root is exactly zero
% we are doomed if we let it evolve to be dynamically proportional
% to the computed approximation.
% So we compute eps only at first ieration. The value is then 1/(c-1)
% which is not zero.
\newcommand\SolveExpEqualLinNeg{%
\xintdeffloatvar delta:= v/u;%
\xintdeffloatvar c:= u * exp(delta);% c<0
\xintdeffloatvar tn:= F(0, c);%
% it turned out that it was too small here with 5e-16
% because it could be that iteration fell into
% infinite loop ...6-->...8-->...6-->..6 etc as last
% significant figure. So let's be more cautious.
\xintdeffloatvar eps:=abs(tn) * 1e-15;% attention to sign...
\xintloop
\xintdeffloatvar new:=F(tn,c);%
\xintifboolexpr{abs(new-tn)<eps}
{\iffalse}%
{\xintdeffloatvar tn := new;\iftrue}
\repeat
\xdef\roots{\xintfloateval{tn-delta}}%
}
% zero slope
\newcommand\SolveExpEqualLinZero{%
\xintifboolexpr{v<=0}{\xdef\roots{}}{\xdef\roots{\xintfloateval{log(v)}}}%
}
% positive slope
\newcommand\SolveExpEqualLinPos{%
\xintdeffloatvar delta:= v/u;%
\xintdeffloatvar c:= u * exp(delta);%
\xintdeffloatvar d:= log(u) + delta;%
\xintifboolexpr{d-1>1e-15}
{\SolveExpEqualLinPosTwo}
{\xintifboolexpr{d-1<-1e-15}
{\xdef\roots{}}%
{\xdef\roots{\xintfloateval{1 - delta}}}%
}%
}
% positive slope, two roots
\newcommand\SolveExpEqualLinPosTwo{%
\xintdeffloatvar tn:=1/(c-1);%
\xintdeffloatvar eps:=tn * 1e-15;%
\xintloop
\xintdeffloatvar new:=F(tn,c);%
\xintifboolexpr{abs(new-tn)<eps}
{\iffalse}%
{\xintdeffloatvar tn:=new;\iftrue}
\repeat
\xintdeffloatvar w_1 := tn;%
%
\xintdeffloatvar tn:=d;%
\xintdeffloatvar tn:=G(tn, d);%
\xintdeffloatvar tn:=G(tn, d);%
\xintdeffloatvar tn:=G(tn, d);%
\xintdeffloatvar eps:=tn* 1e-15;% careful not too small
\xintloop
\xintdeffloatvar new:=K(tn, d);%
\xintifboolexpr{abs(new-tn)<eps}
{\iffalse}%
{\xintdeffloatvar tn :=new;\iftrue}%
\repeat
\xintdeffloatvar w_2 := tn;%
%
%The solutions to the equation $\exp(t) = \xintfloateval{c}t$ are
%$t_1\approx\xintfloateval[-1]{w_1}$ and $t_2\approx\xintfloateval[-1]{w_2}$.
\xdef\roots{\xintfloateval{w_1-delta}, \xintfloateval{w_2-delta}}%
}
\begin{document}
\begin{tikzpicture}
\def\xmin{-0.5}
\def\xmax{3.6}
\draw[->] (\xmin,0) -- (\xmax,0);
\draw[->] (0,-0.2) -- (0,{exp(\xmax)});
\draw[domain=\xmin:\xmax,samples=200] plot (\x,{exp(\x)});
\xintFor* #1 in {\xintSeq{3}{10}}\do{%
\draw[domain=-0.1:\xmax,samples=2,color=gray,line width=0.1] plot (\x,{#1*\x});
\SolveExpEqualLin{#1}{0}%
\foreach \r in \roots { \fill[red] (\r,{exp(\r)}) circle (1.2pt); }
}
\end{tikzpicture}
\begin{tikzpicture}
\def\xmin{-3}
\def\xmax{1.5}
\def\step{0.25}
\draw[->] (\xmin,0) -- (\xmax,0);
\draw[->] (0,-0.2) -- (0,{exp(\xmax)});
\draw[domain=\xmin:\xmax,samples=200] plot (\x,{exp(\x)});
\edef\tmp{\xinteval{\xmin..[\step]..\xmax}}
\xintFor #1 in {\tmp}\do{%
\draw[domain=\xmin:#1,samples=2,color=blue!50,line width=0.3] plot (\x,{-\x+#1});
\SolveExpEqualLin{-1}{#1}%
\foreach \r in \roots { \fill[blue] (\r,{exp(\r)}) circle (1.2pt); }
}
\end{tikzpicture}
\begin{tikzpicture}
\def\xmin{-3}
\def\xmax{1.5}
\def\step{0.25}
\draw[->] (\xmin,0) -- (\xmax,0);
\draw[->] (0,-0.2) -- (0,{exp(\xmax)});
\draw[domain=\xmin:\xmax,samples=200] plot (\x,{exp(\x)});
\edef\tmp{\xinteval{\xmin..[\step]..\xmax}}
\xintFor #1 in {\tmp}\do{%
\draw[domain=#1:\xmax,samples=2,color=red!50,line width=0.3] plot (\x,{\x-#1});
\SolveExpEqualLin{+1}{-#1}%
\foreach \r in \roots { \fill[red] (\r,{exp(\r)}) circle (1.2pt); }
}
\end{tikzpicture}
\end{document}
```
[![intercepts with exponential][2]][2]
[![intercepts, negative slope][3]][3]
[![intercepts, positive slope][4]][4]
[1]: https://i.sstatic.net/1eKhRV3L.png
[2]: https://i.sstatic.net/3GnD6uIl.png
[3]: https://i.sstatic.net/Fya9S2KV.png
[4]: https://i.sstatic.net/DdRtDNN4.png