0
$\begingroup$

I have the following function:

test = D[(a - A)^2 + (b - B)^2 + (c - C)^2 + 
         ( a + b - (S + c) - D)^2 - λ1*a - λ2* b - λ3*c  - λ4*(a + b - (S + c)), 
        {{a, b, c}}]

Then I solve for a,b,c, and get:

solutions = Solve[Thread[test == 0], {a, b, c}]

So now, I plug the results of a,b,c back into test to remove a,b,c from my original equation and take the derivatives with respect to Lambda1, Lambda2,Lambda3,Lambda4. So I get the following:

results = 
 ExpandAll[
  D[(a - A)^2 + (b - B)^2 + (c - C)^2 + 
    ( a + b - (S + c) - D)^2 - λ1*a - λ2* b - λ3*c - λ4*( a + b - (S + c)) /. 
    solutions[[1]], {{λ1, λ2, λ3,  λ4}}]]

However, when I try to solve for Lambda1, Lambda2,Lambda3,Lambda4, I get nothing back:

lambdasolutions = Solve[Thread[ results == 0], {λ1, λ2, λ3, λ4}]

Am I doing something wrong?

$\endgroup$
  • 2
    $\begingroup$ Do NOT use capitals for variable names. $\endgroup$ – Histograms Jun 12 '15 at 4:23
  • 1
    $\begingroup$ @Histograms where did I use capitals? the A,B,C,D are constants. $\endgroup$ – kolonel Jun 12 '15 at 4:25
  • $\begingroup$ Look at the following: C; D. In particular: you seem to know that D[] is a built in function, but then you used it as a constant as well!? $\endgroup$ – MarcoB Jun 12 '15 at 4:34
  • $\begingroup$ @Histograms ok I removed the capitals thanks. However, I am still getting nothing. Did you get a result when you ran it? $\endgroup$ – kolonel Jun 12 '15 at 4:40
  • $\begingroup$ @kolonel I got nothing too. Perhaps there are no solutions. $\endgroup$ – Histograms Jun 12 '15 at 4:45
2
$\begingroup$

Use Reduce[ ] instead of Solve[ ]

exp = (a - A)^2 + (b - B)^2 + (c - CC)^2 + (a + b - (S + c) - 
      DD)^2 - λ1*a - λ2*b - λ3* c - λ4*(a + b - (S + c));
test = D[exp, {{a, b, c}}];
solutions = Solve[Thread[test == 0], {a, b, c}];
results = ExpandAll[  D[exp /. solutions[[1]], {{λ1, λ2, λ3, λ4}}]];
lambdasolutions = Reduce[Thread[ results == 0], {λ1, λ2, λ3, λ4}]

(* S == 0 && λ2 == 2 A - 2 B + λ1 && λ3 == -2 A - 2 CC - λ1 && λ4 == -2 A - 2 DD - λ1 *)
$\endgroup$
  • $\begingroup$ should I interpret this as this solution could only hold if S == 0? Also thanks. $\endgroup$ – kolonel Jun 12 '15 at 5:27
  • 1
    $\begingroup$ @kolonel there is no solution if S != 0 $\endgroup$ – Dr. belisarius Jun 12 '15 at 5:38
  • $\begingroup$ alright thank you sir. $\endgroup$ – kolonel Jun 12 '15 at 6:01

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.