Message Boards Message Boards

0
|
1834 Views
|
4 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Solving system of equations takes too long

Posted 1 year ago

Hi. I am new to Wolfram Mathematica and stuck with the following problem for a few days. I am modelling an optical axis in nonplanar optical cavity. There are 4 planar reflective surfaces, the beam is reflected from each of them so that it turns into itself after one roundtrip, the optical axis is a quadrangle in 3d. Let us assume the beam hits the reflective surfaces in points {x1,y1,z1}...{x4,y4,z4}, 4 linear equations will define that those points belong to corresponding planes, 4 more equations are triple products showing that incident and reflected rays are in the same plane with the normal vector of reflective surface, and 4 more equation are dot product showing that the angle of incidence is equal to the angle of reflection. So we have 12 variables and 12 equation total:

Here I fully defined the reflective planes with a,b,c,d coefficients, ray vectors p1,p2,p3,p4 are defined through dot coordinates, and I expect to find at least one numerical solution. The code runs for hours with no result. I previously solved this problem numerically with a parameterized 3d model in Autocad and a simple python script for sending random initial points in CAD through API and checking if the beam reproduces itself. I tried Mathematica to confirm my results and ideally to find an analytical solution where a,b,c,d are undefined parameters via Reduce[]. However, my code could not find even a single numerical solution over night (this takes a few sec of random search using CAD). What am I doing wrong here?

Attachment

Attachments:
POSTED BY: Val Semenov
4 Replies
Posted 1 year ago

Obviously the task is solvable, and I managed to make it work rewriting the code according to your recommendations:

Thanks for the help, I would still like to know what went wrong in my initial example and how to correctly define temporary variables in order to make my code more readable next time.

POSTED BY: Val Semenov

Your system reduced to the essentials

p1 = {x2 - x1, y2 - y1, z2 - z1};
p2 = {x2 - x3, y2 - y3, z2 - z3};
p3 = {x4 - x3, y4 - y3, z4 - z3};
p4 = {x1 - x4, y1 - y4, z1 - z4};
list = {(p1 - p2) . {a2, b2, c2} == 0, 
  p1 . ({a2, b2, c2}*p2) == 0,
  a2*x2 + b2*y2 + c2*z2 + d2 == 0,
  (p2 - p3) . {a3, b3, c3} == 0,
  p2 . ({a3, b3, c3}*p3) == 0,
  a3*x3 + b3*y3 + c3*z3 + d3 == 0,
  (p3 - p4) . {a4, b4, c4} == 0,
  p3 . ({a4, b4, c4}*p4) == 0,
  a4*x4 + b4*y4 + c4*z4 + d4 == 0, 
  (p1 - p4) . {a1, b1, c1} == 0,
  p1 . ({a1, b1, c1}*p4) == 0,
  a1*x1 + b1*y1 + c1*z1 + d1 == 0}

seems to be not solvable. GroeberBasis yields {1.} that is, there is a solution if 1==0

The equalities for the angles imply equations of the fourth order since

a^2 b^2 Cos[a,b]^2 == (a.b)^2 == c^2 d^2 Cos[c,d]^2 == (c.d)^2

POSTED BY: Roland Franzius
Posted 1 year ago

Yep. Initially I wanted to solve for p1, but it gave out an error. Now it shows no errors, so I assumed the code is okay. Should I define p1...p4 outside of the system of equations?

POSTED BY: Val Semenov
Posted 1 year ago

I don't understand how it's running at all. The p1, p2, et al are not declared as variables to solve for. Are you perhaps trying to use them as temporary variables to avoid duplicating all of the expressions involving x*, y*, z*?

POSTED BY: Eric Rimbey
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract