Mathematica: Tangent of Two Curves

落爺英雄遲暮 提交于 2019-12-14 00:26:07

问题


I asked this question yesterday but not sure if I made clear what I was looking for. Say I have two curves defined as f[x_]:=... and g[x_]:=... as shown below. I want to use Mathematica to determine the abscissa intersection of the tangent to both curves and store value for each curve separately. Perhaps this is really a trivial task, but I do appreciate the help. I am an intermediate with Mathematica but this is one I haven't been able to find a solution to elsewhere.


回答1:


f[x_] := x^2
g[x_] := (x - 2)^2 + 3

sol = Solve[(f[x1] - g[x2])/(x1 - x2) == f'[x1] == g'[x2], {x1, x2}, Reals]

(* ==> {{x1 -> 3/4, x2 -> 11/4}} *)

eqns = FlattenAt[{f[x], g[x], f'[x1] x + g[x2] - f'[x1] x2 /. sol}, 3]; 
Plot[eqns, {x, -2, 4}, Frame -> True, Axes -> None]

Please note that there will be many functions f and g for which you won't find a solution in this way. In that case you will have to resort to numerical problem solving methods.




回答2:


You just need so solve a system of simultaneous equations:

The common tangent line is y = a x + b.

The common slope is a = f'(x1) = g'(x2)

The common points are a x0 + b = f(x0) and a x1 + b = g(x1).

Depending on the nature of the functions f and g this may have no, one, or many solutions.



来源:https://stackoverflow.com/questions/8592200/mathematica-tangent-of-two-curves

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!