Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>SetDelayed</code> acts as a scoping construction. Arguments are localized if necessary. Any variables that <em>explicitly</em> match the arguments are bound within this scope, others are not.</p> <pre><code>In[78]:= a[x_] := x^2 + b b = x^4; (* the first x^2 is explicitly present and bound to the argument. The x in x^4 present via b is not bound *) In[80]:= a[x] Out[80]= x^2 + x^4 (* this is what you would expect *) In[81]:= a[y] Out[81]= x^4 + y^2 (* surprise *) In[82]:= a[1] Out[82]= 1 + x^4 (* surprise *) </code></pre> <p>So, what you could do is one of two things:</p> <ul> <li>Use <code>Evaluate</code>: <code>functionB2[x_] := Evaluate[model /. fit];</code></li> <li><p>Make dependence of <code>model</code> on x explicit: </p> <p>In[68]:= model2[x_] = 4/Sqrt[3] - a1/(x + b1) - a2/(x + b2)^2 - a3/(x + b3)^4;</p> <p>In[69]:= functionB3[x_] := model2[x] /. fit;</p> <p>In[85]:= functionB3[Sqrt[0.2]]</p> <p>Out[85]= 2.01415</p></li> </ul> <p><strong>Edit</strong> because of question update<br> Because of your definition of functionB2 any argument value yields the same result, as explained above:</p> <pre><code>In[93]:= functionB2[1] Out[93]= 4/Sqrt[3] - 0.335/(0.435 + x)^2 + 0.347/(0.712 + x)^4 - 0.27/(4.29 + x) In[94]:= functionB2["Even a string yields the same ouput"] Out[94]= 4/Sqrt[3] - 0.335/(0.435 + x)^2 + 0.347/(0.712 + x)^4 - 0.27/(4.29 + x) </code></pre> <p>However, this expression contains x's and therefore it can get a numerical value if we provide a numerical value for x:</p> <pre><code>In[95]:= functionB2["Even a string yields the same ouput"] /. x -&gt; 1 Out[95]= 2.13607 </code></pre> <p>Well, this basically what <code>Plot</code> does too. This is why you still get a plot.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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