I probably missed a question already posted as this topic seems common, but I looked at several, e.g. Using result of Solve in further calculations
and am a little stuck. I didn't understand the use of Prefix
in this one (which only had 1 solution anyway): Using Solve outputs for further calculations
Even this one: Using the result of Solve in subsequent calculations which looked promising, doesn't seem to have a way of automatically selecting solutions (this one only had 1 again). Maybe I am overlooking how to use these methods but I cannot make the connection...
If I have something like,
eq1 = x^2 - 3*y^2 + 3
sol = Reduce[eq1 == 0, y, Complexes]
sol[[1]][[2]]
eq2[i_] = 100 + (y /. y -> sol[[i]][[2]])
Part::pkspec1: The expression i cannot be used as a part specification.
I made sure not to use SetDelayed, and I know I can do things like,
100 + (y /. y -> sol[[1]][[2]])
where 100 + y
is a new function, but the 1
is chosen by the script itself automatically and can't be 'hard-coded'.
What kind of methodology can one use when there are functions calling functions calling.... etc, that ultimately depend on an automatic choice of a solution set?
PS.
I also tried name a set of rules, but I cannot hold the left side unevaluated (like a ' in Lisp), how do I control the output of Reduce function?
solSet = Table[Unevaluated[y] -> y /. y -> sol[[i]][[2]], {i, 1, 2}]
I guess this is more likely to be (though still fails)
solSet = {ToRules[sol]}
eq3[i_] = 100 + y/.solSet[[i]]
What I would want is (in pseudo-code):
eq1 = x^2 -3*y^2 + 3
sol = Reduce[eq1==0,y,Complexes]
eq2[i_] = 100 + sol[[i]][[2]]
eq2[1] = 100 + solution_one
eq2[2] = 100 + solution_two
eq3[i_,j_] = A*eq2[i] + B*eq2[j];
etc
etc
sol
isy == -(Sqrt[3 + x^2]/Sqrt[3]) || y == Sqrt[3 + x^2]/Sqrt[3]
. You can use a replacementeq2[i_] := sol[[i]] /. {y -> 100 + z}
$\endgroup$ – Alex Trounev Feb 25 '19 at 1:21100 + z == -(Sqrt[3 + x^2]/Sqrt[3])
which isn't really a result (unless I'm doing something wrong). But also, if the enveloping function isn't simple (like 100 + last_choice_of_solution) then it would be difficult to type. $\endgroup$ – nate Feb 25 '19 at 1:31