# Using Piecewise with DSolve

**URL:** <https://community.wolfram.com/t/using-piecewise-with-dsolve/17810>\
**Category:** Questions\
**Tags:** calculus, equation-solving\
**Created:** [March 16, 2021, 2:59pm UTC](https://community.wolfram.com/t/using-piecewise-with-dsolve/17810 "2021-03-16T14:59:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![srinivasgk](https://avatars.discourse-cdn.com/v4/letter/s/f07891/32.png) [@srinivasgk](https://community.wolfram.com/u/srinivasgk)\
**Post date:** [March 16, 2021, 2:59pm UTC](https://community.wolfram.com/t/using-piecewise-with-dsolve/17810/1 "2021-03-16T14:59:14Z")

</div>

Hello,  
I am trying to solve a set of differential equations with Piecewise functions. It seems to work if using only one piecewise function, but does not work with two. I am not sure if I am missing something in the setup.  
I thought the problem was with using units, but that doesn’t seem to be the case.  
Appreciate the help. Here is the code.

```
DSolve[{0.31918 (Piecewise[{{10.268 + 0.0239 x, x <= 2000}, {58.068, 
           x > 2000}}] - TAnnulus[x])/(0.00256455 + 
        1/Piecewise[{{25, x <= 1900}, {100000, x > 1900}}]) - 
    4.63572 (TAnnulus[x] - TIn[x]) == 3976 D[TAnnulus[x], x], 
  4.635726619241774` (TAnnulus[x] - TIn[x]) == 
   3976 Derivative[1][TIn][x], TAnnulus[0] == 1, 
  TAnnulus[3000] == TIn[3000]}, {TAnnulus, TIn}, {x, 0, 3000}]

```

---

<div class="post-metadata">

**Author:** ![gianlucagorni](https://avatars.discourse-cdn.com/v4/letter/g/ec9cab/32.png) [@gianlucagorni](https://community.wolfram.com/u/gianlucagorni)\
**Post date:** [March 16, 2021, 3:45pm UTC](https://community.wolfram.com/t/using-piecewise-with-dsolve/17810/2 "2021-03-16T15:45:19Z")

</div>

Use `NDSolve` instead of `DSolve`.

---

<div class="post-metadata">

**Author:** ![mariuszi28cg](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/mariuszi28cg/32/308_2.png) [@mariuszi28cg](https://community.wolfram.com/u/mariuszi28cg)\
**Post date:** [March 16, 2021, 3:52pm UTC](https://community.wolfram.com/t/using-piecewise-with-dsolve/17810/3 "2021-03-16T15:52:08Z")

</div>

Answer **only** with numerics:

```
 SOL = NDSolve[{0.31918 (Piecewise[{{10.268 + 0.0239 x, 
              x <= 2000}, {58.068, x > 2000}}] - 
           TAnnulus[x])/(0.00256455 + 
           1/Piecewise[{{25, x <= 1900}, {100000, x > 1900}}]) - 
       4.63572 (TAnnulus[x] - TIn[x]) == 3976 D[TAnnulus[x], x], 
     4.635726619241774` (TAnnulus[x] - TIn[x]) == 
      3976 Derivative[1][TIn][x], TAnnulus[0] == 1, 
     TAnnulus[3000] == TIn[3000]}, {TAnnulus, TIn}, {x, 0, 3000}];

 Plot[{TAnnulus[x], TIn[x]} /. SOL // Evaluate, {x, 0, 3000}, 
  PlotLegends -> {"TAnnulus", "TIn"}]

```

Probably symbolic solution can’t be found.

---

<div class="post-metadata">

**Author:** ![srinivasgk](https://avatars.discourse-cdn.com/v4/letter/s/f07891/32.png) [@srinivasgk](https://community.wolfram.com/u/srinivasgk)\
**Post date:** [March 17, 2021, 3:45pm UTC](https://community.wolfram.com/t/using-piecewise-with-dsolve/17810/4 "2021-03-17T15:45:40Z")

</div>

Thank you that seems to have solved the problem.
