# Solve for a variable using expression involving sum of quantities

I am trying to solve for h1 using function solve as in below code, Expression in solve equates sum of two expression. Both left hand and right hand side of expression is the sum of four quantities defined by n = 1 to 4. Can any body help in solving the following expression.

Solve[
Sum[50*0.25*n*0.97*Exp[-h1*0.25*n], {n, 1, 4}] ==
Sum[0.5*0.25*n*0.97*(Exp[-h1*0.25*(n - 1)] - Exp[-h1*0.25*n]), {n, 1, 4}],
h1]


I am getting the error

Solve::ratnz: Solve was unable to solve the system with inexact coefficients.The answer was obtained by solving a corresponding exact system and numericizing the result. >>

• And does Solve still return a result after that warning? Jun 7 '15 at 14:37
• yes. I got following{{h1 -> ConditionalExpression[4. (4.61512 + (0. + 6.28319 I) C), C [Element] Integers]}, {h1 -> ConditionalExpression[ 4. ((0.501157 + 3.14159 I) + (0. + 6.28319 I) C), C [Element] Integers]}, {h1 -> ConditionalExpression[ 4. ((0.442569 + 1.68325 I) + (0. + 6.28319 I) C), C [Element] Integers]}, {h1 -> ConditionalExpression[ 4. ((0.442569 - 1.68325 I) + (0. + 6.28319 I) C), C [Element] Integers]}} Jun 7 '15 at 14:50
• So it seems to me that you did in fact obtain a solution set. Those conditional expressions restrict the value of the C[n] constants to integer values only. Are those solutions not what you expected? Alternatively, of you want e.g. real solutions or other restrictions on the domain, you can specify that as a third argument to Solve, or include more complicated restrictions as further equalities / inequalities in the first argument to Solve. Jun 7 '15 at 14:57
• I expect a fraction as solution. I can solve it in excel using goal seek but not sure what other arguments. can you pl help. Jun 7 '15 at 15:19

As you mentioned in comments, you solved the equation using Excel, which to me indicates that you are looking for the real solution(s) to your equation.

You can restrict the domain over which Solve looks for solutions to the reals (notice the third argument to Solve):

Solve[
Sum[50*0.25*n*0.97*Exp[-h1*0.25*n], {n, 1, 4}] ==
Sum[0.5*0.25*n*0.97*(Exp[-h1*0.25*(n - 1)] - Exp[-h1*0.25*n]), {n, 1, 4}],
h1, Reals
]

(* Out: {{h1 -> 18.4605}} *)


If you use exact numbers in your Solve expression, you can get an exact result, as well as avoid the warning you mentioned:

Solve[
Sum[50*1/4*n*97/100*Exp[-h1*1/4*n], {n, 1, 4}] ==
Sum[1/2*1/4*n*97/100*(Exp[-h1*1/4*(n - 1)] - Exp[-h1*1/4*n]), {n, 1, 4}],
h1, Reals
]

(* Out: {{h1 -> 4 Log}} *)