Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>In some ways, you are encountering the difference between <a href="http://reference.wolfram.com/mathematica/ref/Set.html?q=Set&amp;lang=en" rel="nofollow"><code>Set</code></a> (<code>=</code>) and <a href="http://reference.wolfram.com/mathematica/ref/SetDelayed.html?q=SetDelayed&amp;lang=en" rel="nofollow"><code>SetDelayed</code></a> (<code>:=</code>). For instance, if you wrote <code>f = 7</code>, <code>f</code> becomes <code>7</code> in all occurrences of <code>f</code> after it was initialized. But, if you wrote <code>f = 7 t</code> instead, and tried to use it as you would a function, i.e. <code>f[8]</code>, you'd get <code>(7 t)[8]</code> because <code>Set</code> says that the value of <code>f</code> is unchanging. <code>SetDelayed</code>, however, implies that the value of <code>f</code> will change and must be reevaluated every time it occurs. Your initial case, though, is special.</p> <p>When you wrote</p> <pre><code>Beta = Piecewise[{{0.01, Inf[t] &gt; 20}, {.06, Inf[t] &lt;= 20}}] </code></pre> <p><code>Inf[t]</code> was undefined, so that it remained unevaluated. But, every occurence of <code>Beta</code> in your differential equations was replaced by the above formula, courtesy of <code>Set</code>, so <code>NDSolve</code> only saw the <code>Piecewise</code> functions. In your second case, you wrote</p> <pre><code>Beta = UpdateTransmission[Inf[t]] </code></pre> <p>Here the problem is that <code>UpdateTransmission</code> is executed only when <code>Beta</code> is initially defined, and while <code>Piecewise</code> remains unevaluated, <code>UpdateTransmission</code> most likely still gives a result for a purely symbolic input. I'd try one of three things, </p> <ol> <li>replace every occurrence of <code>Beta</code> in you equations with <code>UpdateTransmission[Inf[t]]</code>,</li> <li><p>redefine <code>Beta</code> using <code>SetDelayed</code>, e.g. </p> <pre><code>Beta := UpdateTransmission[Inf[t]] </code></pre> <p>so that it will be reevaluated every time it is encountered, or</p></li> <li><p>redefine <code>UpdateTransmission</code> to not accept symbols via either </p> <pre><code>UpdateTransmission[x_?(Head[#]=!=Symbol&amp;)] := ... </code></pre> <p>or</p> <pre><code>UpdateTransmission[x_] /; Head[x]=!= Symbol := ... </code></pre></li> </ol> <p>Option 3 works by forcing <code>UpdateTransmission[Inf[t]]</code> to remain unevaluated, and effectively does the same thing as option 1. But, it requires a minimum of change. Personally, I'm in favor of options 1 or 3, as I don't know how many times <code>Beta</code> will need to be reevaluated as <code>NDSolve</code> operates.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload