I'm trying to illustrate the solutions numerically and graphically for an equation such as Tan[x] == x
. I think I did everything ok except I wanted to mark each intersection between Tan[x]
and x
.
Does anyone know how such a thing can be done?
Answer
Edited to make it a function. For the strange Exclusions
specification I use below, see my answer here. Thanks to @Oleksandr and @JM for their great comments.
plInters[{f1_, f2_}, {min_, max_}] :=
Module[{sol, x},
sol = x /. NSolve[f1[x] == f2[x] && min < x < max, x];
Framed@Show[
ListPlot[{#, f1[#]} & /@ sol, PlotStyle -> PointSize[Large]],
Plot[{f1[x], f2[x]}, {x, min, max}, Exclusions -> {True, f2[x] == 10, f1[x] == 10}]
]
]
GraphicsRow[plInters[#, {-10, 10}] & /@ {{# &, Tan}, {Tan, Coth}, {Sin, 1/# &}}]
Comments
Post a Comment