0
$\begingroup$

I've been struggling with this a bit. I've been googling in search for an answer but failed to do so. I want to solve this system of equations with a parameter

Solve[
 {x == light[[1]] + (i[[1]] - light[[1]]) t,
  y == light[[2]] + (i[[2]] - light[[2]]) t,
  z == light[[3]] + (i[[3]] - light[[3]]) t,
  Z == 0},
 {x, y, z}]

In the end to get the answer i wanted i just got rid off variable z and used something like this

Solve[
  {x == light[[1]] + (1 - light[[1]]) t,
   y == light[[2]] + (2 - light[[2]]) t,
   0 == light[[3]] + (1 - light[[3]]) t},
   {x, y, t}] // N

But it bugs me, is there a way to get the same answer using more readable and flexible code which presents the equation in a more general way (something which looks closer to my first attempt at this Solve). And sorry if my english is weird, not my first language.

$\endgroup$
  • $\begingroup$ Mathematica cannot solve your first Solve command, because it cann't fullfill the equation Z==0Perhaps itshould be z==0? $\endgroup$ – Ulrich Neumann Nov 23 '18 at 20:08
  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$ – Michael E2 Nov 23 '18 at 21:56
  • $\begingroup$ You have 4 equations and 4 unknowns, just need to solve for all of them. Ulrich has it correct, below. $\endgroup$ – MikeY Dec 23 '18 at 22:24
1
$\begingroup$

Assuming the last equation z==0 you can solve your equations for x,y,z,t

Solve[{x == light[[1]] + (i[[1]] - light[[1]]) t, 
y == light[[2]] + (i[[2]] - light[[2]]) t, 
z == light[[3]] + (i[[3]] - light[[3]]) t, z == 0}, {x, y, z , t}]

(*{{x -> -((-i[[3]] light[[1]] + i[[1]] light[[3]])/(i[[3]] - light[[3]])), 
y -> -((-i[[3]] light[[2]] + i[[2]] light[[3]])/(i[[3]] - light[[3]])), 
z -> 0, 
t -> light[[3]]/(-i[[3]] + light[[3]])}}*)
| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.