Troubleshooting Complex Number Formulas in Matlab

  • Context: MATLAB 
  • Thread starter Thread starter hokhani
  • Start date Start date
  • Tags Tags
    Complex Complex number
Click For Summary

Discussion Overview

The discussion revolves around troubleshooting issues with complex number formulas in Matlab. Participants explore the discrepancies in results obtained from different forms of the same mathematical expressions involving complex variables, focusing on potential causes and solutions.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant notes encountering different results from mathematically equivalent formulas in Matlab, despite checking their equality.
  • Another participant suggests that issues may arise from multi-valued complex operations, such as logarithms, which could lead to non-equivalence due to the software's handling of principal branches.
  • A participant requests specific examples to better understand the problem and troubleshoot effectively.
  • Concerns are raised about the complexity of the expressions, with one participant questioning the possibility of a small mistake in the code, given the "hideous" nature of the formulas.
  • It is proposed that using computer algebra systems like Mathematica could aid in troubleshooting by allowing for simultaneous tracing of numerical and analytical forms.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the source of the discrepancies, and multiple competing views regarding potential causes remain present throughout the discussion.

Contextual Notes

Limitations include the lack of specific examples provided, which may hinder the troubleshooting process. The discussion also highlights the complexity of the formulas involved, which may obscure potential errors.

hokhani
Messages
601
Reaction score
22
One problem I sometimes encounter is with complex numbers. When a formula including functions of complex variables runs in Matlab, I obtain the corresponding result but if I write that formula in different forms (for example when I arrange the long formula in simpler form) I obtain another result. I always check the equality of these formulas and I am confident that they are mathematically the same. I haven't found yet the source of this problem.
 
Physics news on Phys.org
It is difficult to troubleshoot without any specific examples - could you perhaps provide one such instance? Sometimes these issues arise when you perform certain multi-valued complex map operations such as taking the logarithm. In these instances, there may be non-equivalence because these software are automatically programmed to take the principal branch.
 
In the attached file I have written the two same formulae which give different values numerically.
 

Attachments

These expressions are hideous. I haven't checked the algebra, but I'm just going to assume they're correct for now. At first glance, I don't think I see anything that could likely cause the issue (unless [itex]q_{I}[/itex] and [itex]q_{II}[/itex] are some funny functions). Especially as the expressions are so ugly, might it have been possible that you've made a small mistake in the code somewhere?
Computer algebra systems like Mathematica would probably help greatly in the troubleshooting as well, since you can trace both the numerics and analytical forms at the same time.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
8K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 13 ·
Replies
13
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 12 ·
Replies
12
Views
3K
Replies
2
Views
2K