Skip to main content
8-Gravel
November 1, 2024
Solved

Imaginary power by integral

  • November 1, 2024
  • 3 replies
  • 3668 views

Hi Masters

Have a good day.

I have a  question about why the integral values are different between the imaginary conductance is outside and inside the integral function.

or did I miss something on operators as calculating the imaginary term?

tks

 

Kocela_0-1730428288247.png

 

Best answer by Werner_E

Numerical integration always is just an approximation. While integration would be summing up an infinite number of infinite small values, numerical integration basically sums up a larger number of rather small values. Taking into account rounding errors and the like, it does matter if the factor is only used once in front of the integral or if it is used in every summand.
Given that, it can be said that you get the more accurate results by placing the constant factors outside of the integral.

 

So the small differences you experienced are just numerical inaccuracies, a summation of round-off errors, etc.

 

It sometimes helps to set the system variable TOL to a lower value (default is 10^-3), but you may run into troubles (calculation not converging) if you set it too low.

10^-11 is too small in my opinion, but in case of your calculation it makes for equal results.

Werner_E_0-1730434276942.png

Setting TOL to 10^-12 lets the last integral fail.

So generally its better to make it easier to the numerics to get a more accurate result. In your case you may also place Vpk^2 in front of the integral.

 

Another option may be using the symbolics.

Assign the result to a function in all input variables.

You may either do it before you define these variables or use clear.sym(...) to make them unknown to the symbolic engine.

This way may be especially useful if you intend to experiment with different sets of input values and want compare the results

Werner_E_1-1730435065742.png

Of course if you really intend to do so, it would make sense to make Vrms and only fL fcuntion arguments and calculate Vpeak and omega inside the function definition

Werner_E_0-1730436644876.png

 

 

3 replies

ttokoro
21-Topaz I
21-Topaz I
November 1, 2024

Please show the circuit and what value you want to solve.

t.t.
ttokoro
21-Topaz I
21-Topaz I
November 7, 2024

image.pngimage.png

t.t.
Werner_E25-Diamond IAnswer
25-Diamond I
November 1, 2024

Numerical integration always is just an approximation. While integration would be summing up an infinite number of infinite small values, numerical integration basically sums up a larger number of rather small values. Taking into account rounding errors and the like, it does matter if the factor is only used once in front of the integral or if it is used in every summand.
Given that, it can be said that you get the more accurate results by placing the constant factors outside of the integral.

 

So the small differences you experienced are just numerical inaccuracies, a summation of round-off errors, etc.

 

It sometimes helps to set the system variable TOL to a lower value (default is 10^-3), but you may run into troubles (calculation not converging) if you set it too low.

10^-11 is too small in my opinion, but in case of your calculation it makes for equal results.

Werner_E_0-1730434276942.png

Setting TOL to 10^-12 lets the last integral fail.

So generally its better to make it easier to the numerics to get a more accurate result. In your case you may also place Vpk^2 in front of the integral.

 

Another option may be using the symbolics.

Assign the result to a function in all input variables.

You may either do it before you define these variables or use clear.sym(...) to make them unknown to the symbolic engine.

This way may be especially useful if you intend to experiment with different sets of input values and want compare the results

Werner_E_1-1730435065742.png

Of course if you really intend to do so, it would make sense to make Vrms and only fL fcuntion arguments and calculate Vpeak and omega inside the function definition

Werner_E_0-1730436644876.png

 

 

23-Emerald V
November 1, 2024

And sometimes it's worth playing with the integrator used behind the hood of the integral operator.

 

 

2024 11 01 B.png

 

Stuart

25-Diamond I
November 1, 2024

@StuartBruff wrote:

And sometimes it's worth playing with the integrator used behind the hood of the integral operator.

 


Ahh, forgot about this.

The ability to chose the algorithm is a new feature introduce in Prime 10.
Not sure which version of Prime the OP is using, though. As I was able to open the file he posted with Prime 9, I fear the option to chose a different algorithm is not available to him.

12-Amethyst
November 2, 2024

While Werner pointed out how to minimize numerical errors when evaluating the integral, it is worth exploring whether you need the integral in the first place. This appears to be an evaluation of complex power into a parallel LC with a sinusoidal voltage applied. In the sinusoidal case, the integral in the first line, together with the preceding fL term, has the form

  (1/T)*Integral { v(t)^2 dt } over one full period (= 1/fL). This is precisely the definition of Vrms^2. The complex power can then be evaluated without needing to do any integration. (Result is  -4429.21608641315i W.) 

 

In general, I trust numerical results more if I have made as many simplifications as possible in the math before using numerical evaluation. In general, I think most linear network sinusoidal problems can be solved without requiring numerical integration, but typically at the price of some additional symbolic manipulations. I try to make use of the symbolic processor to check my math manipulations for errors, with the goal of simplifying as much as possible before resorting to numerical evaluation. I'm always more comfortable if I can avoid numerical integration.

 

Lou