1
$\begingroup$

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. >>

$\endgroup$
  • $\begingroup$ And does Solve still return a result after that warning? $\endgroup$ – MarcoB Jun 7 '15 at 14:37
  • $\begingroup$ yes. I got following{{h1 -> ConditionalExpression[4. (4.61512 + (0. + 6.28319 I) C[1]), C[1] [Element] Integers]}, {h1 -> ConditionalExpression[ 4. ((0.501157 + 3.14159 I) + (0. + 6.28319 I) C[1]), C[1] [Element] Integers]}, {h1 -> ConditionalExpression[ 4. ((0.442569 + 1.68325 I) + (0. + 6.28319 I) C[1]), C[1] [Element] Integers]}, {h1 -> ConditionalExpression[ 4. ((0.442569 - 1.68325 I) + (0. + 6.28319 I) C[1]), C[1] [Element] Integers]}} $\endgroup$ – Kausik Jun 7 '15 at 14:50
  • $\begingroup$ 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. $\endgroup$ – MarcoB Jun 7 '15 at 14:57
  • $\begingroup$ 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. $\endgroup$ – Kausik Jun 7 '15 at 15:19
2
$\begingroup$

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[101]}} *)
$\endgroup$

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.