MATLAB: Finding the tangent of two curves

beginnercurvesMATLABtangent

For A Homework Project I have to find the point at which two curves are tangent.
I wrote the following script but it gives me an error:
Warning: 2 equations in 1 variables.
I do not understand this warning, but my teacher said it should not be there. Here is My Script:
syms x y;
y1 = x^3-3*x+4;
y2 = 3*(x^2-x);
y1_prime = diff(y1);
y2_prime = diff(y2);
possible_xs = solve(y1 == y2, x1_prime == x2_prime);
slope = subs(y1_prime, x, x_point);
y_point = subs(y1, x,x_point);
tangent_line = solve(y - y_point == slope*(x - x_point), y);
fprintf('The equation for the tangent line is: %s\n', string(tangent_line));
Please Help. Thank You 🙂

Best Answer

You have
solve(y1 == y2, x1_prime == x2_prime)
y1 and y2 and x1_prime and x2_prime all only involve a single variable, "x". So you are trying to solve two equations that only have a single variable between them. Much of the time if you have two equations in one variable, there is a contradiction between the two equations and there ends up being no solution. So usually having two equations in one variable represents a logic error, so MATLAB gives you a warning about the situation.
Hint: if you were doing a Venn diagram of solutions of the equations, what would the overlap be called?