0
$\begingroup$

I have an equation which is solved by Solve[].

When I define the variables with real numbers, I get an exact solution. However, when I'm trying to use the symbolic expression for the solution, I replace (/.) the variables, and this time, I don't get any solution.

So, when I use :=, the solution exists, when I use /., the solution is 'Indeterminate', but the numbers are the same in both cases.

I need to use the symbolic expression for the solution, because I would like to solve this equation outside Mathematica.

Code:

ClearAll["Global`*"]

pBE := {u1[1], u1[2], u1[3]}
pBH := {u1[4], u1[5], u1[6]}
zBE := {u2[1], u2[2], u2[3]}
zBH := {u2[4], u2[5], u2[6]}
nBE := {u3[1], u3[2], u3[3]}

subst := {
  u1[1] -> 192.2,
  u1[2] -> 47,
  u1[3] -> 0.5,
  u1[4] -> 189.8,
  u1[5] -> 47,
  u1[6] -> 0.5,
  u2[1] -> 0.25,
  u2[2] -> -0.97,
  u2[3] -> 0,
  u2[4] -> 0,
  u2[5] -> -1,
  u2[6] -> 0,
  u3[1] -> 0,
  u3[2] -> 0,
  u3[3] -> 1}

(*u1[1]:=192.2
u1[2]:=47
u1[3]:=0.5
u1[4]:=189.8
u1[5]:=47
u1[6]:=0.5
u2[1]:=0.25
u2[2]:=-0.97
u2[3]:=0
u2[4]:=0
u2[5]:=-1
u2[6]:=0
u3[1]:=0
u3[2]:=0
u3[3]:=1*)

eq3 := pBE + zBE*x1 == pBH + zBH*x2 + nBE*x3
sol3 := Solve[eq3, {x1, x2, x3}]

rBE := zBE*x1 /. sol3
rBE /. subst

Comment in and out the second 'list' with the defined variables.

Images of the two cases:

enter image description here enter image description here

$\endgroup$
1
$\begingroup$

You are getting 0/0 indeterminate forms, just like you would get for something like:

(a^2-b^2)/(a-b)/.{a->2, b->2}

Power::infy: Infinite expression 1/0 encountered.

Infinity::indet: Indeterminate expression 0 ComplexInfinity encountered.

Indeterminate

One possibility to avoid this is to use Cancel:

Cancel[rBE] /. subst

{{-2.4, 9.312, 0.}}

| 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.