Group Abstract Group Abstract

Message Boards Message Boards

0
|
1.5K Views
|
0 Replies
|
0 Total Likes
View groups...
Share
Share this post:

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

Posted 10 years ago

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}]

wrong

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

Attachments:
POSTED BY: Simon B.
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard