TransWikia.com

Getting two different results for the same computation

Mathematica Asked on October 22, 2021

I have the following two codes:

In[1]:=f = 10^5;
u = 1;
m = (R1 + R3)/(c*R1*R3);
R1 = 100;
R3 = 100;
n = 100;
k = c*R1;
c = 100*10^(-9);
FullSimplify[
 f*Integrate[(Integrate[(((((u*Sin[2*Pi*f*x])*Sign[u*Sin[2*Pi*f*x]])/
             2) + ((u*Sin[2*Pi*f*x])/2)))*((Exp[-m*(t - x)])/k), {x, 
        0, t}])^2/n, {t, 0, 1/f}]]

Out[1]=(E^4 + (-1 + 
    E (-2 + E (1 + E) (-1 + 3 E))) [Pi]^2)/(1600 E^4 (1 + [Pi]^2)^2)

And:

In[2]:=f = 10^5;
u = 1;
m = (R1 + R3)/(c*R1*R3);
R1 = 100;
R3 = 100;
n = 100;
k = c*R1;
c = 100*10^(-9); 
FullSimplify[
 f*Integrate[(Integrate[(((((u*Sin[2*Pi*f*x])*Sign[u*Sin[2*Pi*f*x]])/
             2) + ((u*Sin[2*Pi*f*x])/2)))*((Exp[-m*(t - x)])/k), {x, 
        0, t}, Assumptions -> 
        u > 0 && f > 0 && t >= 0 && m > 0 && k > 0])^2/n, {t, 0, 1/f},
    Assumptions -> 
    n > 0 && u > 0 && f > 0 && t >= 0 &&  m > 0 && 
     k > 0], Assumptions -> 
  n > 0 && u > 0 && f > 0 && t >= 0 && m > 0 && k > 0]

Out[2]=(1 + (2 - 1/E^4) [Pi]^2)/(1600 (1 + [Pi]^2)^2)

They both are representing the same computation but gave different results, why is that? And which one is true?

One Answer

The numeric integration confirms the former

f = 10^5;u = 1;m = (R1 + R3)/(c*R1*R3);R1 = 100;R3 = 100;n = 100;k = c*R1;c = 100*10^(-9);
g[t_?NumericQ] := (NIntegrate[(((((u*Sin[2*Pi*f*x])*
          Sign[u*Sin[2*Pi*f*x]])/2) + ((u*Sin[2*Pi*f*x])/
        2)))*((Exp[-m*(t - x)])/k), {x, 0, t}])^2/n;
f*NIntegrate[g[t], {t, 0, 1/f}]
(*0.000187112*)

in view of

N[(E^4 + (-1 + 
E (-2 + E (1 + E) (-1 + 3 E))) [Pi]^2)/(1600 E^4 (1 + [Pi]^2)^2)]
(*0.000187112*)

The superfluous assumptions may cause the incorrect result of the latter.

Answered by user64494 on October 22, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP