-2

I am having an issue integrating a function for which I am getting values for when I evaluate it.

FFF[t_?NumericQ] := 
 Evaluate[(((1/2*k*(1 + Cos[ω t]) + 10) - Paorta[t])/
     Piecewise[{{.05, 
        1/2*k*(1 + Cos[ω t]) + 10 - Paorta[t] > 0}}, 
      x*Ro])] /. 
  NDSolve[{Paorta'[t] == 
     1/Caorta ((1/2*k*(1 + Cos[ω t]) + 10 - Paorta[t])/
         Piecewise[{{Ro, 
            1/2*k*(1 + Cos[ω t]) + 10 - Paorta[t] > 0}}, 
          x*Ro] - Paorta[t]/Rsystemic), 
    Paorta[0] == 90}, {Paorta[t]}, {t, 0, 10}]

When I try to evaluate FFF[t], say FFF[2], I get a numerical answer:

enter image description here

But when I attempt to Integrate, numerically or otherwise, it gives me the error:

"Integrand FFF[t] is not numerical at {t} = {0.07957319952578756`"

I am not trying to evaluate on any undefined domain, I don't understand why this is not working.

PS. I am new to coding in Mathematica and not too great at coding in general so I may be missing something basic so I am sorry if that is the case.

Thanks!

Dr. belisarius
  • 115,881
  • 13
  • 203
  • 453
Dinomite00
  • 87
  • 4

1 Answers1

2

Please behave like a good citizen of the site and read the answers you receive more carefully.
The following is a direct application of my answer to your previous question here.

w[k_, ω_, t_] := 1/2*k*(1 + Cos[ω t]) + 10;

pnd = ParametricNDSolve[{
   Paorta'[t] == 1/Caorta ((w[k,ω,t] - Paorta@t)/ 
                 Piecewise[{{ρ, w[k,ω,t] - Paorta@t >0}}, x*ρ]- Paorta@t/Rsystemic), 
   Paorta[0] == 90},
   {Paorta}, {t, 0, 10}, {Caorta, k, ω, ρ, x, Rsystemic}]

FFF[t_?NumericQ, Caorta_, k_, ω_, ρ_, x_, Rsystemic_] :=
 Module[{p = (Paorta /. pnd)[Caorta, k, ω, ρ, x, Rsystemic][t]},
  (w[k, ω, t] - p)/ Piecewise[{{.05, w[k, ω, t] - p > 0}}, x*ρ]]

Manipulate[
 Row[{"Integral ", NIntegrate[FFF[t, Caorta, k, ω, ρ, x, Rsystemic], {t, 0, 1}, 
                             MaxRecursion -> 12]}],
 {{Caorta, 1/.48}, 1, 6},
 {{Rsystemic, 3.1}, .1, 6},
 {{x, 8000}, 1, 10000},
 {{ω, 2 π}, π, 3 π},
 {{k, 110}, 60, 200},
 {{ρ, .01}, .007, .05}
 ]

Mathematica graphics

Dr. belisarius
  • 115,881
  • 13
  • 203
  • 453
  • Hey there belisarius, thank you so much for your answer. I did see your answer to my previous question and really appreciate that too. The reason that I didn't add to it myself is because I didn't understand it all too well in the first place, which may have seemed like i was ignoring it or not looking at it which I do apologize for. I am not sure how ParametricNDSolve works and why I need to solve it parametrically and what implications it has. Sorry again if I offended you by posting this question, I truly do appreciate your time and your help! – Dinomite00 Jun 17 '15 at 20:01
  • Also, what is module used for, I tried looking it up a few times in the past but never fully understood it if I'm to be honest :/ – Dinomite00 Jun 17 '15 at 20:06