1. Computing
RTL reference|Glossary|Tips/Tricks|FREE App/VCL|Books|Link Back

TComplexMath
When using Delphi to develop engineering applications, you'll often find that the mathematics support in the development environment is not enough. TComplexMath unit is a way out! Full source code.
Win prizes by sharing code!
Do you have some Delphi code you want to share? Are you interested in winning a prize for your work?
Delphi Programming Quickies Contest
Join the Discussion
"Post your views, comments, questions and doubts to this article."
Discuss!
Related Resources
Delphi Math unit
Mathematics in Delphi
Developing custom components

Article submitted by: Thomas Bejstam for the Delphi Programming Quickies Contest.

Complex Mathematics
When using Delphi to develop engineering applications, you'll often find that the mathematics support in the development environment is not enough. So, what's the way out?

I was dealing with impedances on transmission lines, and the basic formulas for this can be found in most text-books on the subject. However, the mathematics requires complex capabilities, and I decided to write my own component to support this, TComplexMath.

All complex number has a real and an imaginary part. Therefore the most logical implementation was to use a record, consisting of two real type variables, one for the real part and one for the imaginary part.

The rules for complex mathematics are not any different than those for non-complex mathematics. I actually prefer to see the "normal" non-complex math as a special case. Try using the complex math routines with real numbers (zero imaginary part), and you'll come up with familiar results. Very simple!

Some properties that can be applied to real numbers, e.g. larger than, smaller than, etc., does not exist for complex numbers, since a complex number is not defined by its size.

I hope this component will turn out useful to you. Go complex!

Download full source code!

All graphics (if any) in this feature created by Zarko Gajic.

More Delphi
· Learn another routine every day - RTL Quick Reference.
· Download free source code applications and components.
· Talk about Delphi Programming, real time.
· Link to the Delphi Programming site from your Web pages.
· Tutorials, articles, tech. tips by date: 2003|2002|2001|2000|1999|1998 or by TOPIC.
Stay informed with all new and interesting things about Delphi (for free).
Subscribe to the Newsletter
Name
Email

Got some code to share? Got a question? Need some help?

©2014 About.com. All rights reserved.