cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

Mathcad giving wrong answer for Fourier series of a half-wave rectifier? Provide assistance !

AS_9824434
11-Garnet

Mathcad giving wrong answer for Fourier series of a half-wave rectifier? Provide assistance !

Hi all, 

I am trying to find out the Fourier series of a half rectified sinusoidal wave for up to six terms. Amplitude= V volts and period of 2pi. 

For B(n) the first term should be 0.5 then 0 afterwards. However, Mathcad is giving a very small number 10^-17 but not zero. Why is this ?

Second problem: When I try to integrate sin(t)*sin(nt), Mathcad should use the orthogonal trig identity to convert it into sin(1-n)t+sin(1-n)t or something along those lines. If this is not done Mathcad can't compute when n=1 because in B(n) it has n^2-1 in the denominator. This is a small problem that I can live with but the one above is a bigger one. 

 

1 ACCEPTED SOLUTION

Accepted Solutions

1) The 10^-17 are small numerical inaccuracies you always have to be aware of when using numerical calculations. Most software use the IEEE format to store real numbers and suffer from the very same problem in one way or another.
If you need exact results you have to use the symbolic evaluation.

Werner_E_0-1614111056758.png

2) Division by zero: Unfortunately the symbolic evaluation does not take in account the case n=1 when using the summation. Its able to evaluate A(1) and B(1), but not in a sum. You may call it a limitation or you may call it a bug. Here are a few more strange (and definitely wrong) results using the new symbolic in Prime 6:

Werner_E_4-1614116211116.png

 

If you are not in desperate need for a symbolic solution, you might use a pure numeric approach:

Werner_E_3-1614116128708.png

Prime 6 sheet attached

 

View solution in original post

7 REPLIES 7
-MFra-
21-Topaz II
(To:AS_9824434)

Hi!
Can the attached file on the subject, be useful to you?

Hi,

Thanks for trying to help. Unfortunately that does not help since the pdf notes you have provided is using different techniques to analyse different frequencies in a signal. 

My question is regarding Fourier series of this signal. For example, how can I find the Fourier series up to 6 terms of half rectified wave? I want to do that in Mathcad 

1) The 10^-17 are small numerical inaccuracies you always have to be aware of when using numerical calculations. Most software use the IEEE format to store real numbers and suffer from the very same problem in one way or another.
If you need exact results you have to use the symbolic evaluation.

Werner_E_0-1614111056758.png

2) Division by zero: Unfortunately the symbolic evaluation does not take in account the case n=1 when using the summation. Its able to evaluate A(1) and B(1), but not in a sum. You may call it a limitation or you may call it a bug. Here are a few more strange (and definitely wrong) results using the new symbolic in Prime 6:

Werner_E_4-1614116211116.png

 

If you are not in desperate need for a symbolic solution, you might use a pure numeric approach:

Werner_E_3-1614116128708.png

Prime 6 sheet attached

 

Thank you for taking time out of your day and giving such a comprehensive response. I had a look at the file you provided it was good. 

 

It seems that using symbolic arrow to find the expression for B(n) gives problems however; when this step is skipped and the symbolic arrow is used on just B(n) then it returns the correct 6X1 matrix with 1/2 or V/2 then 0,0,0,0.... which is the correct(refer to the the screenshot).

 

This is a bit disappointing I have to say but hey; mathcad is still the best in the market. 

I am transitioning from Matlab so I am a bit of newbie when it comes to this. 

You can get what you are looking for if you define A1 and B2 separately:

Werner_E_0-1614125179343.png

The same method fails however if I make the voltage V and additional argument of all functions 😞

 

LucMeekes
23-Emerald III
(To:AS_9824434)

Another method to deal with numerical problems, and especially where division by 0 poses a problem, is to use limits:

LucMeekes_1-1614118278463.png

Success!
Luc

 

One more example:

Fred_Kohlhepp_0-1614177189122.pngFred_Kohlhepp_1-1614177224201.png

Prime 4 file attached

Top Tags