common tangent of two curves I need simple code

19 visualizaciones (últimos 30 días)
muhsin ider
muhsin ider el 25 de Oct. de 2019
Editada: Adam Danz el 25 de Oct. de 2019
I need the slope of common tangent given in the figure below. Actually I need the coordinates of common tangent touching points to each curve. It seems easy for the curves below but I have very different and difficult curves and I need to find very accurately.
I need the slope of the tangent and I need the equation of tangent line if possible. I can do it analytically but I need a simple code to do it because I will do it for many curves.. I understand gradient or diff but the code I need must be for both numerical and symbolic. The problem is that if I have a very steep curve I may not have a good approximation with numerical methods. Is it possible with simple code?
Thanks,
best wishes,
  4 comentarios
Adam Danz
Adam Danz el 25 de Oct. de 2019
Editada: Adam Danz el 25 de Oct. de 2019
"it is not a math problem. "
It's nearly 90% a math problem.
You can use gradient() to compute the slopes of each line.
"... the program code then compare these slopes and reports which x value these slopes are equal to each other."
I thought of 2 problems with this approach.
  1. There many be many points that have approximately the same slope between the two curves. For example, at the minima of the curves, the slopes are both 0.
  2. The slopes between the two curves will probably not exactly match. For example, at the two points in your image that share the same slope, one may be -0.499124 while the other is -0.498456.
Perhaps another idea would be to find the line that connects two interpolated points, one from each parabola, that has the lowest y-intercept. Or maybe, find the line that connects points from each parabola that contains no coordinates below the line.
muhsin ider
muhsin ider el 25 de Oct. de 2019
Editada: Adam Danz el 25 de Oct. de 2019
Thanks for help.
Actually the tangent equation of a curve at point x1 can be given as z(x) function in the following code.
clear all
clc
close all
syms x f(x) z(x)
t=0;
f(x)=x.*x+2*x+t
df=diff(f,x)
x1=1:1
m=df(x1)
z1=f(x1)
z(x)=z1+(m*(x-x1))
figure
x=-7:5;
plot (x,f(x),x,z(x))
hold on
The code calculates the slope and finds the equation of tangent of x^2+2x. The code will do the same thing for x^2-4x and compare that. Obviously the code will try this procedure for every x. However, when I change the x1=1:3 data point I have following errors. I can not understand the problem.
Error in sym/privBinaryOp (line 1002)
Csym = mupadmex(op,args{1}.s, args{2}.s, varargin{:});
Error in * (line 315)
X = privBinaryOp(A, B, 'symobj::mtimes');
Error in Untitled24 (line 10)
z(x)=z1+(m*(x-x1))

Iniciar sesión para comentar.

Respuestas (0)

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by