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
- :
- Implementation of Lagrange Interpolation

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-24-2021
09:18 PM

02-24-2021
09:18 PM

Hello, I am trying to implement a program where I can find out the "y" value for a given "x" value using Lagrange Interpolation with data points (x,y) like the ones shown below:

The program should use these expressions:

Solved! Go to Solution.

Labels:

1 ACCEPTED SOLUTION

Accepted Solutions

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

02-25-2021
11:28 AM

02-25-2021
11:28 AM

It doesn't look like you've put too much thought and effort into this.

However, as promised!

9 REPLIES 9

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

02-25-2021
02:31 AM

02-25-2021
02:31 AM

Re: Implementation of Lagrange Interpolation

While interesting what have you got so far? Couldn't see any attached mcad sheet!

Where are the stumbling blocks?

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

02-25-2021
08:37 AM

02-25-2021
08:37 AM

Re: Implementation of Lagrange Interpolation

Assuming Werner's right, and this IS homework, you need to show an honest effort (AKA, post your worksheet!)

That said, these were developed (as LaGrange polynomial interpolation functions) using Prime 4.0 Express. Worksheet will be posted upon demonstration of honest effort.

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

02-25-2021
08:43 AM

02-25-2021
08:43 AM

Re: Implementation of Lagrange Interpolation

@Fred_Kohlhepp wrote:

Assuming Werner's right, and this IS homework,

The poster himself labelled his question with "Math Homework" 🙂

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

02-25-2021
08:45 AM

02-25-2021
08:45 AM

Re: Implementation of Lagrange Interpolation

Thereby demonstrating (once again) that you are much more observant than I! 😉

But I still enjoyed the challenge.

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

02-25-2021
09:37 AM

02-25-2021
09:37 AM

Re: Implementation of Lagrange Interpolation

This was my original attempt at it. However I realized two things, Mathcad won't simplify the polynomial basis expressions. Secondly, this method is really inefficient as the Lagrange polynomial degree increases. So I stopped trying this method. I figured I could use two loops and the actual expression. However I'm having trouble implementing that.

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

02-25-2021
11:28 AM

02-25-2021
11:28 AM

It doesn't look like you've put too much thought and effort into this.

However, as promised!

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

02-25-2021
11:42 AM

02-25-2021
11:42 AM

Re: Implementation of Lagrange Interpolation

I agree with you and your version looks so familiar compared to what I had prepared 🙂

Splitting may make it better readable

Keep in mind that Freds sheet assumes the default setting for ORIGIN (which is 0). In your sheet you changed ORIGIN to be 1 so you have to slightly modify Freds approach to take that into account.

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

02-25-2021
11:58 AM

02-25-2021
11:58 AM

Re: Implementation of Lagrange Interpolation

Thank you guys! I just needed this because I am new to Mathcad programming and I was just unsure how some of the syntax works for the product function and got completely stuck! thanks for helping me get started!

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

02-25-2021
06:18 AM

02-25-2021
06:18 AM

Re: Implementation of Lagrange Interpolation

As this is obviously homework you should show your attempts for a solution. This also would help us to see where you have problems with the handling of Prime so we can help.

If you already derived a solution you may check your function by creating a plot and also check against the built-in "polyfit" function: