# Is there a more concise method to solve the problem of finding tangent lines to curves?

The question is:

If the tangent line to the curve $$y=e^x+x$$ at point $$(0,1)$$ is also a tangent line to the curve $$y=\ln(x+1)+a$$, then $$a=$$ _______

My method is like this, very cumbersome.

Clear["*"]
f[x_] = E^x + x;
pt = {0, 1}; k1 = f' /. x -> pt[[1]]
line = y - 1 == k1 x // Simplify
g[x_] = Log[x + 1] + a
k2 = D[g[x], x]
sol = Reduce[{k1 == k2}, x] // ToRules
sol1 = Reduce[line /. sol, y] // ToRules
pt1 = {x, y} /. Thread[{x, y} -> {sol // Values, sol1 // Values}] //
Flatten[#, 1] &
Reduce[{y == Log[x + 1] + a, x == pt1[[1]], y == pt1[[2]]}, a]


This problem does not require drawing, just calculate the results of the corresponding parameters.

Is there a more concise method to solve the problem?

• This question is similar to: How to make a Line[] with no end?. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem. One might supplement Reduce[{1/(1 + x) == 2, Log[x + 1] + a == 2 x + 1}, a] with this plot: Manipulate[ Plot[{f1[x], 2 x + 1, Log[x + 1] + a}, {x, -1, 1}, AspectRatio -> Automatic, PlotRange -> 2], {{a, 0}, -2, 2}] Commented Jul 14 at 12:39
• @Artes This problem does not require drawing, just calculate the results of the corresponding parameters. Commented Jul 14 at 12:59
• The plot is auxiliary, therein you can find all necessary tools to solve the problem. Commented Jul 14 at 13:03
• @Artes There are two curves in this problem, but the curve you gave only has one. How can we apply it? Commented Jul 14 at 13:07
• This is so obvious that no other hints are necessary, it's been said, the plot is auxiliary. Commented Jul 14 at 13:23

## Method-1

• RegionEqual.
Clear["Global*"];
f[x_] := E^x + x;
g[x_] := Log[x + 1] + a;
line1 = InfiniteLine[{0, f[0]}, {1, f'[0]}];
line2 = InfiniteLine[{x0, g[x0]}, {1, g'[x0]}];
sol = Solve[RegionEqual[line1, line2], Method -> Reduce]


{{a -> Log[2], x0 -> -(1/2)}}.

• plotting
Plot[{Callout[f[x]], Callout[g[x]]} /. sol[[1]] //
Evaluate, {x, -.9, .6}, Axes -> None,
Epilog -> {{Red, line1, line2, Red, PointSize[.02], Point@{0, f[0]},
Point@{x0, g[x0]}} /. sol[[1]]}]


## Method-2

Clear[f, g, pt1, slope1, slope2, sol];
f[x_] := E^x + x;
g[x_] := Log[x + 1] + a;
pt1 = {0, f[0]};
slope1 = f'[0];
slope2 = g'[x];
sol = Solve[{slope2 == slope1}]
Solve[{pt1 ∈ InfiniteLine[{x, g[x]}, {1, slope2}]} /.
sol[[1]]]


{{x -> -(1/2)}}.

{{a -> Log[2]}}.

Here's a possible easier solution.

f[x_] := Exp[x] + x
g[x_] := Log[x + 1] + a
Reduce[ForAll[{x, y}, y - g[x0] - g'[x0] (x - x0) == y - f[0] - f'[0] (x + 0)]]
(* x0 == -(1/2) && a == Log[2] *)

f[t_] := {t, Exp[t] + t}
tv = (D[f[t], t] /. t -> 0);
tg[s_] := tv  s + {0, 1};
g[t_] := {t, Log[1 + t] + a};
sol = Solve[g'[t] == tv, t][[1]]
asol = Solve[g[t] == tg[t] /. sol, a][[1]]
h = g[t] /. asol
ParametricPlot[{f[t], h, tg[t]}, {t, -1, 1},
Epilog -> {Red, PointSize[0.04], Point[tg[t] /. {{t -> 0}, sol}]},
PlotLegends -> "Expressions", AspectRatio -> Automatic]


You can check if this does what you want.

x0 = 0; y0 = 1;
f1 = Exp[x] + x;
f2 = Log[x + 1] + a
slope = D[f1, x] /. x -> x0
equationOftangent = slope*x + y0
aSolution = SolveValues[f2 == equationOftangent, a]


Verify

p1 = Plot[{equationOftangent, f1}, {x, -1, 1},
Epilog -> {Red, PointSize[.03], Point[{x0, y0}]}]


p2 = Plot[f2 /. a -> aSolution , {x, -1, 1}]


• Your value of a depends on x...? This doesn't make sense. Commented Jul 14 at 12:26
• @NajibIdrissi I did not know that $a$ have to be constant. I see no such mention of this in the question asked. Question just asks to find a value for $a$ which makes $g$ have the same equation as tangent of $f$ at that point, and this what the solution does. If OP can clarify this and say $a$ have to constant, then I will be happy to delete this answer. Commented Jul 14 at 13:00

According to Najib Idrissi's answer, the code also can be written as follows:

Clear["*"]
f[x_] := E^x + x; g[x_] := Log[x + 1] + a;
Reduce[ForAll[{x, y}, y - 1 == f'[0] x, y - g[x0] == g'[x0] (x - x0)]]
`

• Why are you posting the same answer as his again? Commented Jul 15 at 13:20