3
$\begingroup$

I import an interpolation from C++ into mathematica which I then modify. Is there a way to obtain the conjugate of the interpolation? Or do I need to use $(f g)^* = f^* g^*$ and export the conjugated interpolation from C++ as well?

Clear[data, f, g, x]
data = {{1, 1 - 1 I}, {2, 3 - 2 I}, {3, 5 - 4 I}, {4, 7 - 8 I}};
f = Interpolation[data] (* this is what I directly export from C++ *)
g = 1/(x - I) f[x] (* some random modifying function *)
Integrate[g[x] Conjugate[g[x]], {x, 01, 4}] (* what I actually want to evaluate in Mathematica *)

This just returns the unevaluated integral. I also tried NIntegrate but that complains about non-numerical values. I assumed this should work, since g[x] can clearly be evaluated and as such, the complex conjugate is trivial.

$\endgroup$
1
  • $\begingroup$ Try defining g using ClearAll[g]; g[x_] := 1/(x - I) f[x]. I would also switch from Integrate to NIntegrate to calculate your integral. $\endgroup$
    – MarcoB
    Jun 25 at 8:57

1 Answer 1

3
$\begingroup$
Clear[data, f, g, x]
data = {{1, 1 - 1 I}, {2, 3 - 2 I}, {3, 5 - 4 I}, {4, 7 - 8 I}};
f = Interpolation[data] (*this is what I directly export from C++*)
g[x_?NumericQ] := 1/(x - I) f[x] (*some random modifying function*)
NIntegrate[g[x] Conjugate[g[x]], {x, 1, 4}]

Mathematica graphics

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.