Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I want to solve the underneath equation. If I try Solve[AAA,dc], then I get no solution. Can anybody explain this?

AAA = {80000 If[0.1 (0.00005 - dc) + dc <= -0.00175, -35, 
      If[-0.00175 <= 0.1 (0.00005 - dc) + dc < 0, 20000. (0.1 (0.00005 - dc) + dc), 
       If[0 < 0.1 (0.00005 - dc) + dc <= 0.00015, 20000. (0.1 (0.00005 - dc) + dc), 
        If[0.00015 <= 0.1 (0.00005 - dc) + dc < 0.00115, 
         3.15 - 1000. (0.1 (0.00005 - dc) + dc), 
         If[0.00115 <= 0.1 (0.00005 - dc) + dc < 1/4, 
          2.00462 - 4.01849 (0.1 (0.00005 - dc) + dc)]]]]] + 
    80000 If[0.3 (0.00005 - dc) + dc <= -0.00175, -35, 
      If[-0.00175 <= 0.3 (0.00005 - dc) + dc < 0, 20000. (0.3 (0.00005 - dc) + dc), 
       If[0 < 0.3 (0.00005 - dc) + dc <= 0.00015, 20000. (0.3 (0.00005 - dc) + dc), 
        If[0.00015 <= 0.3 (0.00005 - dc) + dc < 0.00115, 
         3.15 - 1000. (0.3 (0.00005 - dc) + dc), 
         If[0.00115 <= 0.3 (0.00005 - dc) + dc < 1/4, 
          2.00462 - 4.01849 (0.3 (0.00005 - dc) + dc)]]]]] + 
    80000 If[0.5 (0.00005 - dc) + dc <= -0.00175, -35, 
      If[-0.00175 <= 0.5 (0.00005 - dc) + dc < 0, 20000. (0.5 (0.00005 - dc) + dc), 
       If[0 < 0.5 (0.00005 - dc) + dc <= 0.00015, 20000. (0.5 (0.00005 - dc) + dc), 
        If[0.00015 <= 0.5 (0.00005 - dc) + dc < 0.00115, 
         3.15 - 1000. (0.5 (0.00005 - dc) + dc), 
         If[0.00115 <= 0.5 (0.00005 - dc) + dc < 1/4, 
          2.00462 - 4.01849 (0.5 (0.00005 - dc) + dc)]]]]] + 
    80000 If[0.7 (0.00005 - dc) + dc <= -0.00175, -35, 
      If[-0.00175 <= 0.7 (0.00005 - dc) + dc < 0, 20000. (0.7 (0.00005 - dc) + dc), 
       If[0 < 0.7 (0.00005 - dc) + dc <= 0.00015, 20000. (0.7 (0.00005 - dc) + dc), 
        If[0.00015 <= 0.7 (0.00005 - dc) + dc < 0.00115, 
         3.15 - 1000. (0.7 (0.00005 - dc) + dc), 
         If[0.00115 <= 0.7 (0.00005 - dc) + dc < 1/4, 
          2.00462 - 4.01849 (0.7 (0.00005 - dc) + dc)]]]]] + 
    80000 If[0.9 (0.00005 - dc) + dc <= -0.00175, -35, 
      If[-0.00175 <= 0.9 (0.00005 - dc) + dc < 0, 20000. (0.9 (0.00005 - dc) + dc), 
       If[0 < 0.9 (0.00005 - dc) + dc <= 0.00015, 20000. (0.9 (0.00005 - dc) + dc), 
        If[0.00015 <= 0.9 (0.00005 - dc) + dc < 0.00115, 
         3.15 - 1000. (0.9 (0.00005 - dc) + dc), 
         If[0.00115 <= 0.9 (0.00005 - dc) + dc < 1/4, 
          2.00462 - 4.01849 (0.9 (0.00005 - dc) + dc)]]]]]} == 0
share|improve this question
4  
Boy that's one hairball of an expression. I wouldn't be surprised if Solve doesn't help much anyway, but I believe that If should be expressed as Boole or Piecewise. Also, you may have better luck Rationalizeing your numbers. –  Mr.Wizard Jul 23 '13 at 11:11
add comment

1 Answer

You can use Reduce

Reduce[AAA // Rationalize, dc]

dc == -(1/20000) || dc >= 49991/20000

Rationalize isn't necessary, without it a warning will be generated, it doesn't hurt much though.

Another approach, as sebhofer suggested in the comment below, is to use Simplify together with PiecewiseExpand or LogicalExpand, it works probably because generally conditionals written with Piecewise, or And and Or is more robust in Mathematica.

It's a pity that this solution isn't so perfect in version 8:

AAA // PiecewiseExpand // Simplify 

Version 9: dc == -0.00005 || dc >= 2.49955

Version 8: (0.00005 + dc == 0 && 160000. + 3.2*10^9 dc == 0) || dc >= 2.49955

AAA // LogicalExpand // Simplify

Version 9: dc == -0.00005 || dc >= 2.49955

Version 8: (0.00005 + dc == 0 && 160000. + 3.2*10^9 dc == 0) || dc >= 2.49955

share|improve this answer
1  
Nice, it's quite amazing that this works. Just an aside: You don't even need the Reduce, a simple AAA // PiecewiseExpand // Simplify does the job (even without the warning). –  sebhofer Jul 23 '13 at 11:26
    
@sebhofer BTW, the output of Simplify isn't so perfect in version 8: what I get is (0.00005 + dc == 0 && 160000. + 3.2*10^9 dc == 0) || dc >= 2.49955. It's different in other version? –  xzczd Jul 23 '13 at 11:35
1  
Yes, in version 9 AAA // PiecewiseExpand // Simplify yields dc == -0.00005 || dc >= 2.49955 and AAA // Rationalize // PiecewiseExpand // Simplify gives 1 + 20000 dc == 0 || 20000 dc >= 49991. –  sebhofer Jul 23 '13 at 11:39
    
@sebhofer I've made a mistake 囧, see my edit. –  xzczd Jul 23 '13 at 12:52
1  
Why don't you just integrate the PiecewiseExpand//Simplify solution in your answer? It was your idea anyway. And I think you can get rid of the obsolete part of the answer, nobody will mind. –  sebhofer Jul 23 '13 at 13:15
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.