0
$\begingroup$

i am new to Mathematica. Here is the situation:

I have a exponential function of n,t that I want to calculate integral over t for different values of n. I want to define this integral as a function of n. I do it with := and it works fine if I provide a number for n but if I put a variable lets say x it tries to evaluate the integral and get an expression of x. This expression leads to precision error and the result for replacing x with a number gives zero at the output which is not correct. This is a sample code that I use:

A[t_]=Exp[-2.005*10^8 t];
B[n_]:=Integrate[A[t] Exp[-4000 I n \[Pi] t], {t, 0, 1/2000}];
B[0]
B[x]

outputs:

General:"Exp[-100250.] is too small to represent as a normalized machine \
number; precision may be lost"
4.98753*10^-9
0. + 0. I

4.9*10^-9 even if not precise is OK for my application.

I have another function as:

C[f_, g_, n_, m_, max_] := 
  ParallelSum[(f /. n :> it ) g /. n :> (m - it), {it, -max, max}];

I want to use B and another function for example F in C like

F[x_]=1;
G[m_]=C[B[x/5],F[x],x,m,100];

Now for every m I get zero instead of a very small value. The precision loss is ok for me but I would like to have some value instead of zero to work with in other parts of my application.

$\endgroup$

1 Answer 1

2
$\begingroup$

If you rationalize A[t] integration works

A[t_] = Exp[-2.005*10^8 t] // Rationalize[#, 0] &;
B[n_]:=Integrate[A[t] Exp[-4000 I n \[Pi] t], {t, 0, 1/2000}]


B[x] (*-((I - I E^(-100250 - 2 I x \[Pi]))/(4000 (-50125 I + x\[Pi])))*)
B[0] (*(-1 + E^100250)/(200500000 E^100250)*)
$\endgroup$
3
  • $\begingroup$ The integration by itself works the problem is using C even for a large F for example F[x_] = Exp[100000]; I get Exp[-50125.] is too small to represent as a normalized machine number; precision may be lost and 0+0I $\endgroup$ Aug 23, 2023 at 15:16
  • 1
    $\begingroup$ @AminGholizad You might increase WorkingPrecision or use an appropriate time scale. $\endgroup$ Aug 23, 2023 at 15:39
  • $\begingroup$ If I do C[B[x],F[x],x,m,100]; it gives zero with precision error but if I do ParallelSum[Integrate[A[t] Exp[-4000 I n \[Pi] t], {t, 0, 1/2000}],F[m-x],{x,-100,100}] it works as expected. $\endgroup$ Aug 24, 2023 at 7:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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