To use the simple notation for Pattern
, e.g. x_
, you need the "x" part to be a symbol. Otherwise Mathematica will interpret that expression differently. For example, look at
Subscript[Y, 0, A] _ // FullForm
It gives Times[Blank[], Subscript[Y, 0, A]]
, which is not a Pattern
expression at all. What your definition of f
ended up being was a definition for a single, specific f-headed expression. That is, if you evaluate
f[Subscript[Y, 0, A] _, Subscript[Y, 0, B] _, Subscript[\[Eta], A] _, Subscript[\[Eta], B] _, \[Lambda]_ ]
you will get a new expression, but it will be the exact expression you provided with no argument replacements happening.
I find using Subscript
for variables very tedious, verbose, and error-prone, so I'm going to show you one way to define your function, but with more typical argument patterns. I'm also going to avoid special named characters, because it just clutters things up when posting code to this forum.
f2[Y0A_, Y0B_, etaA_, etaB_, lambda_] :=
(1 - ((1 - Y0A)/(1 + etaA*lambda)^2) - ((1 - Y0B)/(1 + etaB*lambda)^2) +
((1 - Y0A)*(1 - Y0B)/(1 + etaA*lambda + etaB*lambda - etaA*etaB*lambda)^2))
Notice I used :=
instead of =
. That's not absolutely necessary, but it avoids problems if you had previous definitions for the symbols appearing here.
Test:
f2[10^-5, 10^-5, 10, 10, 10^-2]
gives 1178376600121/48400000000