0
$\begingroup$

How can i bound results of my Solve function to variables properly? This metod works but causes unexpected troubles i struggle to resolve

q1 = {tk - T/2, w};
q2 = {tk, ak};
q3 = {tk + T/2, w};
Solve[p == 0, t]; Solve[a1*q1[[1]]^2 + a2*q1[[1]] + a3 == q1[[2]] &&
a1*q2[[1]]^2 + a2*q2[[1]] + a3 == q2[[2]] &&
a1*q3[[1]]^2 + a2*q3[[1]] + a3 == q3[[2]], {a1, a2, a3}]; 
% /. Rule -> Set;
$\endgroup$
  • $\begingroup$ First off, it's best not to use % unless you're doing fast prototyping. It's apt to give you headaches. Second, you can just use {a1, a2, a3} = {a1, a2, a3} /. soln but I'd keep it as rules, myself. $\endgroup$ – b3m2a1 May 27 at 17:58
  • $\begingroup$ Check this carefully to see it works. {{a1,a2,a3}}=ReplaceAll[{a1,a2,a3}, Solve[a1*q1[[1]]^2 + a2*q1[[1]] + a3 == q1[[2]] && a1*q2[[1]]^2 + a2*q2[[1]] + a3 == q2[[2]] && a1*q3[[1]]^2 + a2*q3[[1]] + a3 == q3[[2]], {a1,a2,a3}]] and then look at the value assigned to a1 or the value assigned to a2... As you have seen, you can use /. as an abbreviation for ReplaceAll. Look carefully at how many layers of {{}} there are in the result returned from Solve and make certain those match the number in any assignment. $\endgroup$ – Bill May 27 at 18:05

Your Answer

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

Browse other questions tagged or ask your own question.