-2
$\begingroup$

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!

$\endgroup$
3
  • $\begingroup$ Please post your Integration attempt $\endgroup$ Jun 17, 2015 at 16:50
  • $\begingroup$ Also, you aren't posting the values for the parameters Omega, Ro ... etc. Without them NDSolve won't work $\endgroup$ Jun 17, 2015 at 16:52
  • $\begingroup$ And again, when posting a question, please be sure that the code you're posting is complete. $\endgroup$ Jun 17, 2015 at 16:52

1 Answer 1

2
$\begingroup$

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

$\endgroup$
2
  • $\begingroup$ 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! $\endgroup$
    – Dinomite00
    Jun 17, 2015 at 20:01
  • $\begingroup$ 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 :/ $\endgroup$
    – Dinomite00
    Jun 17, 2015 at 20:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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