Linear line that passes through the origin as a tangent to Quadratic line

1 visualizzazione (ultimi 30 giorni)
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')

Risposte (1)

Torsten
Torsten il 16 Nov 2022
Modificato: Torsten il 16 Nov 2022
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 Commenti
Torsten
Torsten il 16 Nov 2022
Modificato: Torsten il 16 Nov 2022
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.
Katherine
Katherine il 16 Nov 2022
M is the gradient of the linear line, a standard linear line equation is y=mx+c, so I just used m as the symbol for the gradient, since I know the y intercept is 0 c=0. I know there is 1 intercept between the quadratic and the linear so I equated, them and used the quadratic formula to solve for x, since I also know there is a singular solution for x as the line is a tangent, this means the determinant of the quadratic formula =0, the determinant of the quadratic formula in this case is a quadratic involving m, solving this will give the gradient of the linear line. In this case it gives an imaginary number and I know why now. I thought originally my code might be wrong but I am fairly confident as it works for multiple other lines, so I came to the resolution it must be with the data which considering it worked for other experiments on the same day, so little change in the conditions, I found this hard to believe but must be the only explanation as to why the code doesn't work because math doesn't lie but experiments do XD
Thank you for taking the time to fully explain your method.

Accedi per commentare.

Categorie

Scopri di più su MATLAB in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by