0
$\begingroup$

enter image description here

New Mathematica user here. I'm using some code from a colleague and editing it to give me more specific results in finding the zeros of a complex polynomial. I am attempting to find a way to assign a value to a variable A symbolically - i.e., give variable A an expression value that depends on other variables. It's a quotient expression, and at one point the variable in the denominator equals zero. How can I use an if statement to say, "If this variable does not equal zero, the value of 'A' should be this expression?"

For clarity, in the picture included above, the line that I'm struggling with is the first line of the second code block, where I'm attempting to assign a value to A by way of an expression. I think the problem is that when I try to put Re[z] in the denominator, there's one point where Re[z] is zero, and I need to somehow have a conditional statement that says 'only assign A the value of this expression when Re[z] does not equal zero'

$\endgroup$
2
  • 2
    $\begingroup$ A[z_] := ConditionalExpression[(z*Conjugate[z] + 1)/(4*Re[z]), Re[z] != 0] $\endgroup$ – Bob Hanlon Jun 23 '20 at 4:28
  • $\begingroup$ If you don't want to write A as a function as in Bob's elegant solution, you can use a substitution rule z->value, where value is a complex number, so you would have something like If[(Denominator[A]/.z->value) !=0, newA=A/.z->value] $\endgroup$ – Randy Marsh Jun 23 '20 at 5:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.