Find the function for a decision variable

Hi, I’m currently trying to find the equation for a decision variable from a total profit equation using Mathematica. From what I’ve read, I can use the solve function to do this. Here’s a example i found:

(*Define the total cost function*)
TC[Q_] := (D S/Q) + (H Q/2)

(*Compute the first derivative*)
dTCdQ = D[TC[Q], Q]

(*Solve for Q*)
solution = Solve[dTCdQ == 0, Q]

(*Simplify the solution*)
simplifiedSolution = Simplify[solution]

However, when I try to apply this to my actual equation, the program runs for hours without completing (it stuck). Here is my specific code:

TP[x_] = pr/x ((a (1 - b) (x^2))/(2 L) ((y g)/(1 + y g)))^(1/(
   1 - b)) - ((c + 1) (Kr/x + Kp/(n x) + Kf/(
      n x) + (hr + g)/
       x (2 x (-((a (-1 + b) g x^2 y)/(L + g L y)))^(1/(1 - b))) + (
       hp + g)/(2 R x) ((a (1 - b) (x^2))/(2 L) ((y g)/(1 + y g)))^(
       2/(1 - b)) + ((hp + g) (n - 1))/(
       2 x) ((a (1 - b) (x^2))/(2 L) ((y g)/(1 + y g)))^(2/(
       1 - b)) (x ((a (1 - b) (x^2))/(2 L) ((y g)/(1 + y g)))^(1/(
          1 - b)) - 1/R) + 
      1/x^2 S + (v/x + vp/(n x)) ((a (1 - b) (x^2))/(
         2 L) ((y g)/(1 + y g)))^(1/(1 - b)) + 
      1/(n x)^2 Sv + (Pv w)/( 
       x f ww) ((a (1 - b) (x^2))/(2 L) ((y g)/(1 + y g)))^(1/(
       1 - b)) + (((cf f) + (m bk))/( 
        x f ww ) {k n x + 
          k/q (Log[1 + z E^(-q n x)] - Log[1 + z])}) )) + (c ((pp/x + 
        pf/x) ((a (1 - b) (x^2))/(2 L) ((y g)/(1 + y g)))^(1/(
      1 - b)))) + (pr/x l (
     2 a g (x^2)
       y (((-((a (-1 + b) g x^2 y)/(L + g L y)))^(1/(1 - b)))^b) )/(
     L + g L y) - ((a (1 - b) (x^2))/(2 L) ((y g)/(1 + y g)))^(1/(
     1 - b)) (M - x))
(*Compute the first derivative*)
dTPdx = D[TP[x], x]

(*Solve for p*)
solution = Solve[dTPdx == 0, x]

(*Simplify the solution*)
simplifiedSolution = Simplify[solution]

Any suggestions on how to resolve this issue? Are there more efficient methods or best practices I should consider for solving complex equations in Mathematica?

coba2.nb (40.5 KB)

Given the state of today’s mathematical knowledge, the only way is to calculate it numerically.
Transcendental equation can’t be solved analytically.

If Mathematics can’t do then Mathematica either.

Regards M.I.

Depending on the parameters, your equation has a variable number of solutions:

TP[x_] = 
 pr/x  ((a  (1 - b)  (x^2))/(2  L)  ((y  g)/(1 + y  g)))^(1/(1 - 
         b)) - ((c + 1)  (Kr/x + Kp/(n  x) + 
       Kf/(n  x) + (hr + g)/
         x  (2  x  (-((a  (-1 + b)  g  x^2  y)/(L + g  L  y)))^(1/(1 -
                b))) + (hp + 
           g)/(2  R  x)  ((a  (1 - b)  (x^2))/(2  L)  ((y  g)/(1 + 
               y  g)))^(2/(1 - b)) + ((hp + g)  (n - 
             1))/(2  x)  ((a  (1 - b)  (x^2))/(2  L)  ((y  g)/(1 + 
               y  g)))^(2/(1 - 
             b))  (x  ((a  (1 - b)  (x^2))/(2  L)  ((y  g)/(1 + 
                  y  g)))^(1/(1 - b)) - 1/R) + 
       1/x^2  S + (v/x + 
          vp/(n  x))  ((a  (1 - b)  (x^2))/(2  L)  ((y  g)/(1 + 
               y  g)))^(1/(1 - b)) + 
       1/(n  x)^2  Sv + (Pv  w)/(x  f  ww)  ((a  (1 - 
                b)  (x^2))/(2  L)  ((y  g)/(1 + y  g)))^(1/(1 - 
             b)) + (((cf  f) + (m  bk))/(x  f  ww)  (k  n  x + 
           k/q  (Log[1 + z  E^(-q  n  x)] - 
              Log[1 + z]))))) + (c  ((pp/x + 
         pf/x)  ((a  (1 - b)  (x^2))/(2  L)  ((y  g)/(1 + 
              y  g)))^(1/(1 - b)))) + (pr/
       x  l  (2  a  g  (x^2)  y  (((-((a  (-1 + b)  g  x^2  y)/(L + 
                   g  L  y)))^(1/(1 - b)))^b))/(L + 
         g  L  y) - ((a  (1 - b)  (x^2))/(2  L)  ((y  g)/(1 + 
             y  g)))^(1/(1 - b))  (M - x)) // Simplify
(*Compute the first derivative*)
dTPdx = D[TP[x], x] // Simplify;
effe = Block[{a = 1, b = 2, bk = 1, c = 1, cf = 4, f = 1, g = 1, 
   hp = 1, hr = 1, k = 1, Kf = 1, Kp = 1, Kr = 1, l = 1, L = 1, m = 1,
    M = 1, n = 1, pf = 1, pp = 1, pr = 1, Pv = 1, q = 1, R = 1, S = 1,
    Sv = 1, v = 1, vp = 1, w = 1, ww = 1, y = 1, z = 1},
  dTPdx]
Plot[effe, {x, -10, 10}, PlotRange -> {-1, 1}]
Solve[effe == 0, x, Reals]
gi = Block[{a = 1, b = 0, bk = 1, c = 1, cf = 4, f = 1, g = 1, hp = 1,
    hr = 1, k = 1, Kf = 1, Kp = 1, Kr = 1, l = 1, L = 1, m = 1, M = 1,
    n = 1, pf = 1, pp = 1, pr = 1, Pv = 1, q = 1, R = 1, S = 1, 
   Sv = 1, v = 1, vp = 1, w = 1, ww = 1, y = 1, z = 1},
  dTPdx]
Plot[gi, {x, -10, 10}, PlotRange -> {-1, 1}]
Solve[gi == 0, x, Reals]
acca = Block[{a = 4, b = 2, bk = 1, c = 1, cf = 4, f = 3, g = 2, 
   hp = 1, hr = 1, k = 1, Kf = 2, Kp = 1, Kr = 5, l = 3, L = 1, m = 1,
    M = 1, n = 1, pf = 4, pp = 1, pr = 1, Pv = 1, q = 1, R = 10, 
   S = 1, Sv = 1, v = 1, vp = 1, w = 1, ww = 1, y = 1, z = 2},
  dTPdx]
Plot[acca, {x, -10, 10}]
Solve[acca == 0, x, Reals]

You cannot expect a simple analytical solution for the general case.