Linear line that passes through the origin as a tangent to Quadratic line
2 次查看(过去 30 天)
显示 更早的评论
I have a known quadratic line and I need a linear line that passes through the origin and is a tangent to my quadratic line. I originally tried to solve it by equating the quadratic to a linear line, ax^2 +bx+c=mx, rearranging to equal 0, 0= ax^2+(b-m)x+c. Solve for x, x=(-(b-m)+-sqrt((b-m)^2-4ac))/2a. For one solution the determinant (bit under the sqrt) must equal 0, 0=(b-m)^2-4ac, 0= b^2+m^2-2mb-4ac, solving for m should equal the gradient I need for a tangent, 0=m^2-2mb+(b^2-4ac). However this gives me an imaginary number and I can't understand it. Code and line used below
y=-0.008877*x^2+0.9859*x+5.509 % line, to speed up the process
% I have written it out here, it is in a polyfit for some massive dataset
syms V0 m a b d
help=solve(b^2 - 2*b*m + m^2 - 4*a*d==0,m)
gradient=subs(help,[a,b,d],[-0.008877,0.9859,5.509])
eqn = eval(coeffs(gradient(2))) % I have tried both solutions and work it
% out by hand equally an imaginary answer as well
tangentX=[-50:1:100]
tangentY=[-50:1:100].*(eqn)
hold on
plot(tangentX,tangentY,'k')
0 个评论
回答(1 个)
Torsten
2022-11-16
编辑:Torsten
2022-11-16
The tangent to your quadratic through a point
(x0,a*x0^2+b*x0+c)
is given by
y(x) = (2*a*x0+b) * x + ((a*x0^2+b*x0+c) - (2*a*x0+b) * x0)
For the tangent to pass through (0,0), the y-intercept of the line must be equal to 0, thus
((a*x0^2+b*x0+c) - (2*a*x0+b) * x0) = 0.
Solve for x0.
6 个评论
Torsten
2022-11-16
编辑:Torsten
2022-11-16
You have the quadratic
f(x) = a*x^2 + b*x + c
Now I want to calculate the slope in a point (x0,f(x0));
f'(x) = 2*a*x + b
evaluated in x0:
slope = 2*a*x0 + b.
Now the equation of the tangent in (x0,f(x0)) is
t(x) = slope*x + n
To determine n, you know that t passes through (x0, a*x0^2+b*x0+c), thus
a*x0^2+b*x0+c = t(x0) = slope*x0 + n
thus
n = -slope*x0 + (a*x0^2+b*x0+c).
Thus the equation of the tangent through (x0,a*x0^2+b*x0+c) is
t(x) = slope*x + (-slope*x0 + (a*x0^2+b*x0+c))
Now you want to determine a point x0 for which the tangent passes through (0,0).
For this, the y-intercept of the tangent t
-slope*x0 + (a*x0^2+b*x0+c) = -(2*a*x0 + b)*x0 + (a*x0^2+b*x0+c)
must be 0.
Now you can continue with my solution with the symbolic toolbox.
The fact that x0_tangent and y0_tangent become complex shows that there does not exist a real-valued point (x0,f(x0)) on your quadratic such that the tangent in this point passes through the origin. This can easily be seen from the graph of your quadratic.
Most probably, this will be the reason with your code, too, but I could not follow your deduction of computing m.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!