Consider the following code:
ClearAll[K, L, λ, q, r, w]
TC[K_, L_, q] := w*L + r*K + 10*q
Phi[K_, L_, λ_] := TC[K, L, q] - λ*(10*K^(4/5)*(L - 40)^(1/5) - q)
Phi[K, L, λ]
FullSimplify[{
D[Phi[K, L, λ], K],
D[Phi[K, L, λ], L],
D[Phi[K, L, λ], λ]
}]
FullSimplify[
Solve[{
D[Phi[K, L, λ], K] == 0,
D[Phi[K, L, λ], L] == 0,
D[Phi[K, L, λ], λ] == 0
}, {K, L, λ}]
]
r = 64;
w = 32;
FullSimplify[TC[K, L, q]]
Is it possible to automatically assign the real-valued solutions for K
and L
to get the output
2 (640 + (5 + 4 2^(1/5)) q)
with executing the last command?
Update
After hints from Artes, I've managed to always get the function TC
for real-valued K
and L
. However, how do I print only the real-values [which I forgot to mention the first time I updated the question] of K
and L
when I solve the system of equations? When executing
F[k_, l_] := 10*k^(4/5)*(l - 40)^(1/5)
TC[k_, l_, q_] := w*l + r*k + 10*q
Phi[k_, l_, λ_] := TC[k, l, q] - λ*(F[k, l] - q)
expressions = {D[Phi[k, l, λ], k], D[Phi[k, l, λ], l], D[Phi[k, l, λ, λ]};
FullSimplify[Solve[expressions == {0, 0, 0}, {k, l, λ}]]
I get five solutions;
{{k -> (q w^(1/5))/(5 2^(3/5) r^(1/5)),
l -> 40 + (q r^(4/5))/(20 2^(3/5) w^(4/5)), λ] -> (
r^(4/5) w^(1/5))/(
4 2^(3/5))}, {k -> -(((-1)^(1/5) q w^(1/5))/(5 2^(3/5) r^(1/5))),
l -> 40 - ((-1)^(1/5) q r^(4/5))/(20 2^(3/5) w^(4/5)), λ ->
r^(4/5) w^(1/5) Root[-1 + 8192 #1^5 &, 2]}, {k -> ((-1)^(2/5) q w^(
1/5))/(5 2^(3/5) r^(1/5)),
l -> 1/40 (1600 + ((-2)^(2/5) q r^(4/5))/w^(
4/5)), λ -> ((-1)^(2/5) r^(4/5) w^(1/5))/(
4 2^(3/5))}, {k -> -(((-1)^(3/5) q w^(1/5))/(5 2^(3/5) r^(1/5))),
l -> 40 - ((-(1/2))^(3/5) q r^(4/5))/(
20 w^(4/5)), λ -> -(((-1)^(3/5) r^(4/5) w^(1/5))/(
4 2^(3/5)))}, {k -> ((-1)^(4/5) q w^(1/5))/(5 2^(3/5) r^(1/5)),
l -> 40 + ((-1)^(4/5) q r^(4/5))/(
20 2^(3/5) w^(4/5)), λ -> ((-1)^(4/5) r^(4/5) w^(1/5))/(
4 2^(3/5))}}
P.S. q
, r
, and w
are all positive numbers.
Solve[FullSimplify[TC[K, L, q]] == 2 (640 + (5 + 4 2^(1/5)) q), {K, L}]
$\endgroup$FullSimplify[ Solve[{ D[Phi[K, L, λ], K] == 0, D[Phi[K, L, λ], L] == 0, D[Phi[K, L, λ], λ] == 0 }, {K, L, λ}] ]
, I get the solutionK -> (q w^(1/5))/(5 2^(3/5) r^(1/5)), L -> 40 + (q r^(4/5))/(20 2^(3/5) w^(4/5))
. Can I automatically assign these values toK
andL
and therefore get2 (640 + (5 + 4 2^(1/5)) q)
if I executer = 64; w = 32; FullSimplify[TC[K, L, q] ]
? $\endgroup$:)
The only thing: Can I make it automatically choose the real-valued solution instead of, say, the first one? $\endgroup$:)
$\endgroup$