Any way to speed up calculation of a large complex exponential? (2025)

8 views (last 30 days)

Show older comments

Randy A Lemons on 25 Jun 2019

  • Link

    Direct link to this question

    https://support.mathworks.com/matlabcentral/answers/468709-any-way-to-speed-up-calculation-of-a-large-complex-exponential

  • Link

    Direct link to this question

    https://support.mathworks.com/matlabcentral/answers/468709-any-way-to-speed-up-calculation-of-a-large-complex-exponential

Commented: Randy A Lemons on 25 Jun 2019

Accepted Answer: Matt J

Open in MATLAB Online

I am dealing with the repeated calculation of the exponential of a complex array filled with numbers on the order of 1.04*10^8. This is for use in a FFT based laser propagation code that I have been tasked with implementing. The issue is that I often have to deal with arrays that are 2^12 by 2^12 elements and this means that each iteration of the exponential ends up taking around a second. In my attempts to troubleshoot why this particular computation was taking so long I tried using real numbers and saw that it was significantly faster.

I was wondering if anyone knew why computing the exponential of a complex number is so much slower than the exponential of a real number? In case you want a code to try out what I mean, this should work (i'm running on 2019a but it should be pretty universal).

Ideally I would like to find a way to speed up this calculation but I am not hopeful. If anything an explanation for why it takes so much longer on comple data than real data would be interesting.

1 Comment

Show -1 older commentsHide -1 older comments

John D'Errico on 25 Jun 2019

Direct link to this comment

https://support.mathworks.com/matlabcentral/answers/468709-any-way-to-speed-up-calculation-of-a-large-complex-exponential#comment_717893

  • Link

    Direct link to this comment

    https://support.mathworks.com/matlabcentral/answers/468709-any-way-to-speed-up-calculation-of-a-large-complex-exponential#comment_717893

Open in MATLAB Online

Do you have any idea how large A is, and what the value of exp(A) would be? if you were to be able to compute it? It should have roughly 30,000,000 decimal digits. It will overflow, so the answer will always overflow to inf. But the exponential of i*A will be a complex number, with magnitude 1.

A = 10^8;

exp(A)

ans =

Inf

exp(i*A)

ans =

-0.36339 + 0.93164i

As such, it will actuallly require a computation for the imaginary argument, instead of just trapping out with an overflow to inf in the code.

Sign in to comment.

Sign in to answer this question.

Accepted Answer

Matt J on 25 Jun 2019

  • Link

    Direct link to this answer

    https://support.mathworks.com/matlabcentral/answers/468709-any-way-to-speed-up-calculation-of-a-large-complex-exponential#answer_380628

  • Link

    Direct link to this answer

    https://support.mathworks.com/matlabcentral/answers/468709-any-way-to-speed-up-calculation-of-a-large-complex-exponential#answer_380628

Edited: Matt J on 25 Jun 2019

Open in MATLAB Online

One reason exp(A) is signficantly faster is that it is always Inf for the values of A you are feeding in. There is no computation involved. Another reason is that

exp(1i*A) = cos(A)+1i*sin(A)

which therefore takes twice as much memory and computation to evaluate. To speed things up, either use the GPU or consider changing A to type single instead of double.

1 Comment

Show -1 older commentsHide -1 older comments

Randy A Lemons on 25 Jun 2019

Direct link to this comment

https://support.mathworks.com/matlabcentral/answers/468709-any-way-to-speed-up-calculation-of-a-large-complex-exponential#comment_717902

  • Link

    Direct link to this comment

    https://support.mathworks.com/matlabcentral/answers/468709-any-way-to-speed-up-calculation-of-a-large-complex-exponential#comment_717902

Well that really does nake quite a bit of sense. I never really took a look at the output of the calculation for the real numbers. I guess there is a catch for too large of numbers.

I knew that it would take twice the memory at the end of the day but was hoping there was a way to avoid the direct calculation using eulers formula. Or rather I was hoping there was something sneaky that could be done similar to an fft.

I guess if there was Mathworks probably would have implemented it.

Sign in to comment.

More Answers (0)

Sign in to answer this question.

See Also

Categories

RadarPhased Array System ToolboxWaveform Design and Signal SynthesisMatched Filter and Ambiguity Function

Find more on Matched Filter and Ambiguity Function in Help Center and File Exchange

Tags

  • complex
  • exponential
  • fft

Products

  • MATLAB

Release

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.


Any way to speed up calculation of a large complex exponential? (5)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom(English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
  • 日本Japanese (日本語)
  • 한국Korean (한국어)

Contact your local office

Any way to speed up calculation of a large complex exponential? (2025)

FAQs

What is the formula for complex to exponential? ›

The exponential form of a complex number is in widespread use in engineering and science. Since z = r(cosθ + isinθ) and since eiθ = cosθ + isinθ we therefore obtain another way in which to denote a complex number: z = reiθ, called the exponential form.

What is the difference between exponential and complex exponential functions? ›

The exponential function is a basic building block for solutions of ODEs. Complex numbers expand the scope of the exponential function, and bring trigonometric functions under its sway.

How do you multiply two complex exponentials? ›

The steps for multiplying complex numbers are: Step 1: Apply the distributive property and multiply each term of the first complex number with each term of the second complex number. Step 2: Simplify i2 = -1. Step 3: Combine real parts and imaginary parts and simplify them to get the product.

What is the real part of a complex exponential? ›

a = the Real Part of z = Re(z), b = the Imaginary Part of z = Im(z). Note that both Rez and Imz are real numbers. A common mistake is to say that Imz = bi.

Why is complex exponential important? ›

Early applications of eiωt in the context of electromagnetism were understood as a mathematical device: the physical fields are real, and the complex exponential is a convenient method to implement trigonometric relations.

How do you solve exponential problems? ›

Step 1: Isolate the exponential expression. Step 2: Take the natural log of both sides. Step 3: Use the properties of logs to pull the x out of the exponent. Step 4: Solve for x.

How do you solve complex equations? ›

To solve an equation that has a complex number as a solution: Work with the purely real valued terms until no further simplification can be done and all that remains is an answer involving a negative radicand. Rewrite the complex root as the square root of a real number times the square root of -1.

How do you solve exponential growth problems? ›

The exponential growth and decay gives the required needed calculations using the formulas f(x) = a(1 + r)t, and f(x) = a(1 - r)t. Here a is the initial quantity, r is the growth or decay constant, and t is the time period or the time factor.

How do you solve complex operations? ›

To add two complex numbers , add the real part to the real part and the imaginary part to the imaginary part. To subtract two complex numbers, subtract the real part from the real part and the imaginary part from the imaginary part. To multiply two complex numbers, use the FOIL method and combine like terms .

References

Top Articles
Latest Posts
Recommended Articles
Article information

Author: Edwin Metz

Last Updated:

Views: 6446

Rating: 4.8 / 5 (58 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Edwin Metz

Birthday: 1997-04-16

Address: 51593 Leanne Light, Kuphalmouth, DE 50012-5183

Phone: +639107620957

Job: Corporate Banking Technician

Hobby: Reading, scrapbook, role-playing games, Fishing, Fishing, Scuba diving, Beekeeping

Introduction: My name is Edwin Metz, I am a fair, energetic, helpful, brave, outstanding, nice, helpful person who loves writing and wants to share my knowledge and understanding with you.