1
$\begingroup$

I want to evaluate a Blaschke product based on the set of zeroes, and compute its preimage for some points.

The Blaschke Product looks like:

$$B(z) = z^n\prod_{a_k\in \text{zeroes}} \frac{z - a_k}{1 - \bar{a_k}z} $$

where the set zeroes is a set of numbers where the Blaschke Product is designated to vanish.

The code I wrote looks like

BP [z_, zeroes_List] = Product[z^Boole[a == 0], {a, zeroes}] * 
Product[((z - a)/(1 - a\[Conjugate]*z))^Boole[a != 0], {a, zeroes}] 

but for some reason Mathematica evaluates this function as something completely different. So I don't know how to proceed.

I do have other code that works in evaluating some input, but Mathematica couldn't find the preimages of it, so this is also undesirable. It looks like this:

BP := {z, zeroes} |-> Product[z^Boole[a == 0], {a, zeroes}] * 
Product[((z - a)/(1 - a\[Conjugate]*z))^Boole[a != 0], {a, zeroes}] 

I'm completely new to the language, so any help would be appreciated!

$\endgroup$
8
  • $\begingroup$ Welcome to MMA SE! Here are some notes about function definition. It's all about when expressions get evaluated. When using =, the right hand side is evaluated first, and then the left hand side is set to it. Be careful: named patterns on the left hand side, like z_ and zeroes_List, aren't bound, as you can see from the syntax highlighting (they'll appear in blue or black). So if you have another definition for those symbols somewhere, it could mess up your intended code! consider x = 4; f[x_] = x + 1. This will always evaluate to 5, no matter the input. $\endgroup$
    – thorimur
    Jun 30, 2021 at 7:13
  • $\begingroup$ In general, it's typical to define functions with :=, or SetDelayed, which does not evaluate the right hand side until the function is called and the patterns are replaced. Unlike =, it does bind its patterns, so x = 4; f[x_] := x + 1 will behave nicely, and e.g. f[9] will give 10. (Sometimes you will want to force the right hand side to evaluate first; this is not one of those times. For that, you could use Block[{x}, f[x_] = x + 1], effectively temporarily clearing x for the duration of the definition, without fear.) $\endgroup$
    – thorimur
    Jun 30, 2021 at 7:16
  • 2
    $\begingroup$ The issue is premature evaluation, as mentioned by @thorimur. Since the right side of your definition is evaluated before zeroes has a value, Product interprets {a, zeroes} as {a, 1, zeroes}, i.e. "the product with a going from 1 to zeroes". The second example works, because Function (|->) always prevents evaluation of the right side until arguments are given. $\endgroup$
    – Lukas Lang
    Jun 30, 2021 at 7:17
  • $\begingroup$ Now, note that the syntax BP := {z, zeroes} |-> ... is highly nonstandard. Why? Because functions (defined with |->, Function, or &) don't evaluate their bodies (right hand sides) anyway until called. But neither does :=, so you're avoiding evaluation twice! So, you could use BP = {z, zeroes}, |-> ... to the same effect. At that point, though, you may as well simply use BP[z_, zeroes_List] := ..., as you get all the benefits of pattern-matching (like constraining zeroes to be a list) that |-> leaves you without. $\endgroup$
    – thorimur
    Jun 30, 2021 at 7:21
  • 1
    $\begingroup$ @thorimur thanks so much for your help!! yep it unfortunately was a typo :(. But it is also nice to know how to construct piecewise function. $\endgroup$
    – duang
    Jun 30, 2021 at 19:29

1 Answer 1

1
$\begingroup$

When you use =, Mathematica evaluates the right hand side of your equation first - then sets the left hand side equal to that. So

BP[z_, zeroes_List] = Product[z^Boole[a == 0], {a, zeroes}] * Product[((z - a)/(1 - a\[Conjugate]*z))^Boole[a != 0], {a, zeroes}] 

First calculates

Product[z^Boole[a == 0], {a, zeroes}] * Product[((z - a)/(1 - a\[Conjugate]*z))^Boole[a != 0], {a, zeroes}]

which gives a Piecewise

\[Piecewise]    -1  zeroes==1
(z^-zeroes Pochhammer[1-z,zeroes])/Pochhammer[(-1+z)/z,zeroes]  True

and then sets BP equal to that. You instead want to use the := which is SetDelayed and waits until you give BP the arguments z and zeros before evaluating the right hand side. This way the product will be done only once the list of zeros is provided. So what you want to do is

BP[z_, zeroes_List] := Product[z^Boole[a == 0], {a, zeroes}] * Product[((z - a)/(1 - a\[Conjugate]*z))^Boole[a != 0], {a, zeroes}] 
$\endgroup$

Your Answer

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

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