# How do I assign via /. and have a function as an output?

**URL:** <https://community.wolfram.com/t/how-do-i-assign-via-and-have-a-function-as-an-output/7689>\
**Category:** Questions\
**Tags:** mathematica, equation-solving\
**Created:** [January 16, 2016, 3:04pm UTC](https://community.wolfram.com/t/how-do-i-assign-via-and-have-a-function-as-an-output/7689 "2016-01-16T15:04:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![simonbattenfeld](https://avatars.discourse-cdn.com/v4/letter/s/54ee81/32.png) [@simonbattenfeld](https://community.wolfram.com/u/simonbattenfeld)\
**Post date:** [January 16, 2016, 3:04pm UTC](https://community.wolfram.com/t/how-do-i-assign-via-and-have-a-function-as-an-output/7689/1 "2016-01-16T15:04:37Z")

</div>

Hi,

after searching the web for at least an hour I give up and try asking instead.  
I have a mathematica notebook in which I solve a differential equation. I have four constants for which everything is solved and it does indeed work. I get `{{c0 -> 1.33812, c1 -> 0., c2 -> -0.0000688351, c3 -> 0.}} ` as solution which is correct. I now want to use the function for some analysis. Therefore I create a function f(x) and apply the solution.

```
f[r_] = w[r] /. csol 
{1.33812 - 0.0000688351 r^2 + r^4/1120000000}

```

and it works. But as that is only part of the solution I want to define a Piecewise function fsol

```
fsol[r_] = Piecewise[{{f[r] , 0 < r <= b}, {v[r], b < r <= a}}]

```

which gives me

```
{1.33812 -0.0000688351 r^2+8.92857*10^-10 r^4}	0.<r<=150.
-5.46124-0.000954473 r^2+1.80804 Log[r]+0.000160714 r^2 Log[r]	150.<r<=200.
0.	True

```

That looks correct but is not. For example when i Plot it, the second part (after 150) is cut off.

```
Plot[fsol[r], {r, 0, 200}]

```

 ![wolfram.png](https://global.discourse-cdn.com/wolfram/original/3X/9/9/9900abdd332aae57d3fe3df6cdd36d74345fe348.png)

When I do the same input manually, it works flawlessly

```
fsol[r_] = 
 Piecewise[{{1.3381194672188788` - 0.00006883506521546477` r^2 + r^4/
      1120000000 , 0 < r <= b}, {v[r], b < r <= a}}] 

```

How can I solve this?

Thanks in advance, Simon
