Mathematica and complex numbers

Click For Summary

Discussion Overview

The discussion revolves around solving for the variables a and b in the equation x + I y = Sqrt[a + I b] using Mathematica. Participants explore different methods and functions within Mathematica to handle complex numbers and real-valued assumptions.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Debate/contested

Main Points Raised

  • One participant attempts to solve the equation directly using Solve, but encounters issues with variable assumptions.
  • Another participant suggests using an Assumptions clause to specify that the variables are real-valued, but notes that the Element command does not seem to have the desired effect.
  • There is a suggestion to use the Assuming function to set assumptions globally, although its effectiveness is questioned.
  • A participant expresses a belief that Solve may not be primitive enough for the task and mentions the use of InverseFunction, indicating uncertainty about its application.
  • Another participant shares their experience with Mathematica, indicating familiarity but not deep knowledge, and recalls having previously resolved similar issues by splitting into real and imaginary parts.
  • One participant proposes using the Reduce function as an alternative approach, providing specific examples of its application.
  • There are mixed experiences reported with the Reduce function, with one participant expressing uncertainty about its reliability in this context.
  • A participant mentions manually simplifying the equation and obtaining partial results, indicating that some variables remain unresolved.
  • There are suggestions that using FullSimplify might help in clarifying results and that it allows for setting assumptions.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the best method to solve the problem, with multiple competing approaches and varying levels of success reported. The discussion remains unresolved regarding the most effective technique.

Contextual Notes

Participants express uncertainty about the capabilities of different Mathematica functions and their interactions with assumptions, indicating potential limitations in their understanding or the software's functionality.

Phrak
Messages
4,266
Reaction score
7
I can't come up with the code to solve for a and b in terms of x and y.

Code:
x + I y = Sqrt[a + I b]

Code:
In[84]:= Clear["Global`*"]
Solve[x + I y == Sqrt[a + I b], {a, b}]

During evaluation of In[84]:= Solve::svars: 
Equations may not give solutions for all "solve" variables. >>

Out[85]= {{a -> -I b + x^2 + 2 I x y - y^2}}
 
Physics news on Phys.org
It's assuming all of the variables are complex-valued. You need to tell it they are real-valued with an Assumptions clause.
 
Hurkyl said:
It's assuming all of the variables are complex-valued. You need to tell it they are real-valued with an Assumptions clause.

Assumptions is an unknow option to Solve, so I tried

Code:
Element[{a, b, x, y}, Reals]
Solve[x + I y == Sqrt[a + I b], {a, b}]
obtaining
Code:
(a | b | c | d) \[Element] Reals

During evaluation of In[34]:= Solve::svars: 
Equations may not give solutions for all "solve" variables. >>

{{a -> -I b + x^2 + 2 I x y - y^2}}
 
Solve doesn't deal with assumptions? :frown:

Try wrapping the whole thing in an Assuming function then (I think that's the right name), to set the assumptions.


I think the Element command you used is just a test (boolean-valued expression of the variables a,b,c,d) -- it has to be added to the equation to be solved or made into an assumption or something to have an effect.


There might be some way to tell Mathematica that a variable is real in the way you tried with Element (i.e. to make a global assumption) or an annotation you can put on the variable itself, but I don't know it.
 
Last edited:
I tried doing what you had in mind, as far as mathematica would allow them. I think you're right about the Element function. It doesn't seem to have an effect. I think that Solve is not primitive enough. It uses the more primative InverseFunction. I don't know how to apply InverseFunction.

My guess is that you don't have mathematica but have studied it. I think it's made for someone like you. The single data-type in mathematica is an acyclic directed tree. Interesting... Why? The terminating nodes are the more familiar sorts of data types such as real, integer, string. So the terminating nodes are things that don't act on other things. The non-terminating nodes are functions that act on it's branches. (Interestingly, transcendental numbers like Pi are something else. I haven't discovered what.) All nodes are a common class called symbol. This is the core language. There are other elements like a pre-reader.

The syntax of mathematica, and the more primitive functions will allow you to create your own data syntax and algebras. If you want things other than acycle directed trees, you can probably make them out of trees.

Anyway, I'm still asking "what is mathematics, and what is doing mathematics?" You could probably get a lot further than me if you bought a copy--assuming you don't already have a copy, of course.
 
Last edited:
I use it at work, but don't have it at home. I use it enough to be able to do/know where to find these sorts of things, but I've never actually "studied" it and have nowhere near the depth of knowledge as I do a language like C++.

I'm sure I've had this problem before and worked through it -- I thought I had used the Assuming function to do it. But maybe I just wound up working out how to split it into real and imaginary parts? e.g. using FullSimplify on Re[expr] with the appropriate assumptions clauses.
 
Hurkyl said:
I use it at work, but don't have it at home. I use it enough to be able to do/know where to find these sorts of things, but I've never actually "studied" it and have nowhere near the depth of knowledge as I do a language like C++.

I'm sure I've had this problem before and worked through it -- I thought I had used the Assuming function to do it. But maybe I just wound up working out how to split it into real and imaginary parts? e.g. using FullSimplify on Re[expr] with the appropriate assumptions clauses.

Oh! "Assuming". I don't know Assuming. I assumed :redface: you meant Assumptions. I'll try it.
 
You will probably have better luck with Reduce:

Reduce[{x + I y == Sqrt[a + I b], Im[x] == 0, Im[y] == 0, Im[a] == 0,
Im == 0}, {a, b}]

or

Reduce[{x + I y == Sqrt[a + I b], x \[Element] Reals,
y \[Element] Reals, a \[Element] Reals, b \[Element] Reals}, {a, b}]
 
Hrm. I've had good luck with Reduce and bad luck with Reduce. I thought it wouldn't work here -- but I certainly don't have enough experience to be sure without trying!
 
  • #10
Thanks Dale. I've tried some variations with mixed results. Suprisingly, manually simplifying to

Code:
Reduce[{ a + I b == (x + I y)^2, {x, y, a, b} \[Element] Reals}, {a, 
  b}]
yields the result
Code:
(x | y) \[Element] Reals && a == x^2 - y^2 && 
 b == -I (-a + x^2 + 2 I x y - y^2)
where 'b remains unresolved,
although the contained expression
Code:
{x, y, a, b} \[Element] Reals
works well.

I'm still playing with Assuming, Hurkyl.
 
Last edited:
  • #11
Sometimes, FullSimplfy'ing results helps. I suspect it will help here.
 
  • #12
Hurkyl said:
Sometimes, FullSimplfy'ing results helps. I suspect it will help here.
Yes, and FullSimplify definitely allows you to set assumptions.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 19 ·
Replies
19
Views
3K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
5
Views
4K