A
A
Alexander_The_Great2020-10-10 23:06:55
C++ / C#
Alexander_The_Great, 2020-10-10 23:06:55

How to correctly calculate the value of a complex expression in C++?

Let there be a complex expression:

d3 = (k1*k2*exp(-a*k1*1.0i)*exp(a*k2*1.0i)*4.0i)/(k1*k2*2.0i...
        + k1^2*1.0i + k2^2*1.0i - k1^2*exp(a*k2*2.0i)*1.0i - ...
        k2^2*exp(a*k2*2.0i)*1.0i + k1*k2*exp(a*k2*2.0i)*2.0i);

And the task is to calculate with known k1 and k2.
How to do it correctly , are there any ready-made solutions?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman, 2020-10-11
@Alexander_The_Great

look in this direction https://ru.wikipedia.org/wiki/Complex.h
Complex.h is the header file of the standard library of the C programming language, which declares functions for complex arithmetic. These functions use the built-in complex type that was introduced in the C99 standard. Functions in the header file complex.h are presented for three types - double, float and long double (values ​​are presented in radians): for calculating trigonometric values ​​of sine, cosine, tangent and cotangent for complex numbers, logarithm and exponent, root.
I haven't programmed in C++ for 18 years, so don't judge strictly :)))
ready-made code in the sandbox

M
mayton2019, 2020-10-10
@mayton2019

A square is multiplication by itself.
d3*=d3

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question