find equation of plane intersect
3 views (last 30 days)
Show older comments
Elinor Ginzburg
on 7 Apr 2020
Commented: Elinor Ginzburg
on 8 Apr 2020
hello,
I'm trying to find the equation of the line where two planes intersect. basically, I'm trying to find x as function of y or the opposite which solves the following equation:
I've tried using the following code:
syms x y
ekv1=x+y==0
ekv2=x*log(y)==0
xyz = solve([ekv1, ekv2])
x = xyz.x
y = xyz.y
but it gives me numbers. this is the output:
xyz =
struct with fields:
x: [2×1 sym]
y: [2×1 sym]
x =
0
-1
y =
0
1
what did I do wrong? or perhaps I just don't know how to read it?
Thank you very much!
0 Comments
Accepted Answer
John D'Errico
on 7 Apr 2020
Edited: John D'Errico
on 7 Apr 2020
Ok, first, the solution set is NOT a line. It is a curve, that lives in the (x,y) plane. Next, There is NO plane of intersection.
Before we try to find any kind of a solution, plot things. How? Use a contour plot. Contour plots are greatly underappreciated things. Another option that is just as good is to use fimplicit, which will give you the same capability.
syms x y
f = x + y - x*log(y);
For any real solution to exist, we will need to stay away from negative values of y given the log. What kind of bounds would there be on x? Let me look at a plot first.
fimplicit(fun,[-20,20,0,20]);
grid on
xlabel X
ylabel Y
I would note the importance of a plot here, to help us to realize there are two branches to the solution set. As well, we need to recognize this is an implicit and multi-valued relationship, where for SOME values of x, there are apparently two possible choices for y that satisfy the relation.
Now, it is time to revisit the problem itself. If we have
x*log(y) = x+y
then we can solve for x, as a function of y. Thus
x*(log(y) - 1) = y
and therefore
x = y/(log(y) - 1)
Chose any value for y that is greater than 0, and a single value of x will result. However, we cannot go in the other direction, since there are clearly some values of x that would yield two solutions for y. As well, there are some values for x such that no real solutions exist. Thus for x > 0, but less than roughly 7, there is no real value of y that produces a valid solution.
Sadly, I'm afraid you cannot do something significantly simpler than I have done here. That is the "equation" of the intersection. The equation you want to find is a vaguely hyperbolic thing.
I suppose you could flip the axes.
funy_x = @(y,x) x + y - x.*log(y)
fimplicit(funy_x,[0,20,-20,20])
xlabel y
ylabel x
grid on
What else? Where does the singularity lie? That is, what value of y produces a singularity? This is easy. That must arise when
log(y) -1 == 0
or
y = exp(1)
3 Comments
John D'Errico
on 8 Apr 2020
This will be a little problem. It is doable, but not without something "special", and a branch.
Think of it like this, as you can see in the plot, for SOME values of x, though not all of them, there are apparently two solutions, and zero solutions for other values of x.. For something to be a function of x, you would need only one solution to exist.
For example, when x==10, y can be either roughly 4, or around 20. Which should it return?
How about for x==5? Which real value of y would that function return?
For an even simpler problem, consider the circle equation:
x^2 + y^2 == 2
for y as a function of x? This is the equation of a circle, as an implicit function. We might write the solution as either of:
y = sqrt(2 - x^2)
y = - sqrt(2 - x^2)
Essentially, you need to decide which branch of the sqrt function to take. Do you want the upper semi-circle, or the lower one?
That was the branch problem. Next, we need to talk about special functions. In some cases, we might have a function created essentially to solve a given class of problem.
syms x y
ysol = solve(x + y - x*log(y) == 0,y)
ysol =
-x*wrightOmega(1 - log(-x))
So the solution invokes the wrightOmega function, not something very commonly seen.
help wrightOmega
--- help for double/wrightOmega ---
wrightOmega Wright omega function.
W = wrightOmega(X) is a solution of the equation Y + log(Y) = X.
Reference:
[1] Corless, R. M. and Jeffrey, D. J. "The Wright omega Function."
In Artificial Intelligence, Automated Reasoning, and Symbolic
Computation (Ed. J. Calmet, B. Benhamou, O. Caprotti, L. Henocque
and V. Sorge). Berlin: Springer-Verlag, pp. 76-89, 2002.
However, there are usually two solutions. Again, you need to choose one of them. For a specific value of x, MATLAB will give us two branches.
ysol = solve(subs(x + y - x*log(y) == 0,x,5),y)
ysol =
-5*wrightOmega(1 - log(5) - pi*1i)
-5*wrightOmega(1 - log(5) + pi*1i)
vpa(ysol)
ans =
3.6866964841013638434743319605884 + 4.3238545895155040032223119600973i
3.6866964841013638434743319605884 - 4.3238545895155040032223119600973i
ysol = solve(subs(x + y - x*log(y) == 0,x,10),y)
ysol =
-10*wrightOmega(1 - log(10) - pi*1i)
-10*wrightOmega(1 - log(10) + pi*1i)
vpa(ysol)
ans =
19.914462029240513053822952868431
4.0931510756366501153312734723131
So, is that a solution? Yes, as long as you choose which branch to take, and you don't care if the result is sometimes complex.
More Answers (1)
Ameer Hamza
on 7 Apr 2020
See this code
syms x y
ekv1=x+y;
ekv2=x*log(y);
X = solve(ekv1==ekv2,x);
surf1 = matlabFunction(ekv1, 'Vars', [x y]);
surf2 = matlabFunction(ekv2, 'Vars', [x y]);
intersect_x = matlabFunction(X);
x = -5:0.1:5;
y = 0:0.1:5;
[X_grid,Y_grid] = meshgrid(-5:0.1:5, 0:0.1:5);
Z1 = surf1(X_grid,Y_grid);
Z2 = surf2(X_grid,Y_grid);
figure;
ax = axes();
hold(ax);
view(3);
grid on
mesh(X_grid,Y_grid,Z1)
mesh(X_grid,Y_grid,Z2)
y = 0:0.01:2;
plot3(intersect_x(y), y, surf1(intersect_x(y), y), 'r', 'LineWidth',2);
xlim([-5 5]);
ylim([0 5]);
See Also
Categories
Find more on Mathematical Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!