Get Help

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Community
- :
- PTC Mathcad
- :
- PTC Mathcad
- :
- Mathcad giving wrong answer for Fourier series of ...

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

02-23-2021
11:44 AM

02-23-2021
11:44 AM

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.

Solved! Go to Solution.

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

02-23-2021
04:38 PM

02-23-2021
04:38 PM

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.

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:

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

Prime 6 sheet attached

7 REPLIES 7

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

02-23-2021
01:09 PM

02-23-2021
01:09 PM

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

Hi!

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

02-23-2021
04:18 PM

02-23-2021
04:18 PM

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

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

02-23-2021
04:38 PM

02-23-2021
04:38 PM

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.

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:

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

Prime 6 sheet attached

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

02-23-2021
05:40 PM

02-23-2021
05:40 PM

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

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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

02-23-2021
07:07 PM

02-23-2021
07:07 PM

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

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

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

02-23-2021
05:11 PM

02-23-2021
05:11 PM

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

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

Success!

Luc

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

02-24-2021
09:34 AM

02-24-2021
09:34 AM

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

One more example:

Prime 4 file attached