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
- :
- Solving Kramers- Kronig from absorbance: Difficult...

Options

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

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

Showing results for

Highlighted
##

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

07-31-2014
04:20 AM

07-31-2014
04:20 AM

Solving Kramers- Kronig from absorbance: Difficulty in interp function

Hi Freinds,

I was seriously ill, so I have to be discontinued.

Thank you for your kind replies of my preveous post.

Here are the data file and the mathcad worksheet.

https://www.dropbox.com/sh/pnkvpzrq2of2u71/AAB-sgy0eEMz0vS3l59FUEoGa

I cant set the limits.So that it fails to converge.

Help is required.

Thanks to all.

Hirak

Labels:

12 REPLIES 12

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

07-31-2014
04:07 PM

07-31-2014
04:07 PM

Re: Solving Kramers- Kronig from absorbance: Difficulty in interp function

What is the link to the dropbox for?

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

07-31-2014
05:27 PM

07-31-2014
05:27 PM

Re: Solving Kramers- Kronig from absorbance: Difficulty in interp function

Hirak Chatterjee wrote:

Hi Freinds,

I was seriously ill, so I have to be discontinued.

Thank you for your kind replies of my preveous post.

Here are the data file and the mathcad worksheet.

https://www.dropbox.com/sh/pnkvpzrq2of2u71/AAB-sgy0eEMz0vS3l59FUEoGa

I cant set the limits.So that it fails to converge.

Not sure what you mean!?

Some errors spotted:

1) Don't use a vector index on x when calling interpolate, use the whole vector

2) It seems you have mixed up the order of a and lamda either when calling loess or when calling interpolate

3) If you want to evaluate the function Delta_alpha for all values of the vector omega, you have to vectorize the expression

4) You values of a are in the range of 0.6 to 1.7 but you try to feed the function Delta_alpha with values in the range of 10^15. Do you really want that kind of extrapolation. Furthermore loess cannot extrapolate.

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

08-01-2014
06:20 AM

08-01-2014
06:20 AM

Re: Solving Kramers- Kronig from absorbance: Difficulty in interp function

this is the link for the data file, in case its not uploaded properly.

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

08-01-2014
06:32 AM

08-01-2014
06:32 AM

Re: Solving Kramers- Kronig from absorbance: Difficulty in interp function

Thanks Warner,

1) I am to call the index due to fit the loess fit in interpolation. Otherwise the matrix rows will become unequal.

2) the number of rows in each cases are equal,* viz. *61 rows are in each matrix.

3) I am a newbie in this software, I dont know how to vectorize one expression. If you kindly help me to find this out, I will be oblized.

4) Thank you for this. That should be alpha. But the problem is that, in that case, the error tales me " the values must be an integer."

I need to solve it urgently, please help.

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

08-01-2014
07:20 AM

08-01-2014
07:20 AM

Re: Solving Kramers- Kronig from absorbance: Difficulty in interp function

Hirak Chatterjee wrote:

Thanks Warner,

1) I am to call the index due to fit the loess fit in interpolation. Otherwise the matrix rows will become unequal.

Anyway, its wrong to use the range variable i as index here and is one of the reasons, the interpolation fails. The first and second arguments of loess have to be vectors. And a and lamda are of equal maginitude anyway (61 rows each).

2) the number of rows in each cases are equal,

viz.61 rows are in each matrix.

Nevertheless you changed the order of a and lamda in loess and interpolate which is wrong! Whatever kind the values of omega should be (lamda's or a's), that vetcor has to be first. Guessing from the plots you do this possible should be lamda (independend variable) first, then a (dependend variable). It has to be the same order in loess AND interpolate.

3) I am a newbie in this software, I dont know how to vectorize one expression. If you kindly help me to find this out, I will be oblized.

The function you get with interpolate expects a single scalar as argument, not a whole vector. To let Prime take the elements of a vector omega one by one, feed them into your function and return a vector of results you have to use vectorization (the arrow over the expression) which you get from the operators menu bottom right.

4) Thank you for this. That should be alpha. But the problem is that, in that case, the error tales me " the values must be an integer."

This error is because of the index i in the call of interpolate. As the a values are in the magnitude of alpha I guess a should be the independend variable of your function Delta_alpha, so the order in loess AND interpolate has to be a first, then lamda. The interpolation will not work though, as the localized polynomial regression (loess) you have chosen for your curve fit does not allow extrapolation. It will only allow arguments within the limits of a, that is from 0.6124 to 1.7241. Because the max value of alpha (2.112) is bigger than 1.7241 the function fails.

You will either have to use a different kind of curve fit. Maybe a different kind of reression, maybe an interpolation (polynomial?) instead of a regression - I don't know about your needs.

Later in the sheet I see that you still try to feed very high omega values in your function (inside the integral) - this sure has to fail again.

In the screenshot below I simply took a subvector of the first 21 elelements of alpha (which are in the allowed range) to show that the function work if setup the correct way:

Some other remarks. If you really are after the inverse of lamda-->a you have to be aware that its not unique! E.g. you get two values of lamda for a=1.

Also when I look the the two plots below I think that the function you get with loess is not what you want. For an interpolation to work the function has to be unique and the values of the first vector have to be in ascending order.

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

08-06-2014
02:17 PM

08-06-2014
02:17 PM

Re: Solving Kramers- Kronig from absorbance: Difficulty in interp function

Thanks a lot for your genious comment Mr. Exinger. I have modified my code likewise your guidence , yet the final convergence did not come. Plz chek the modified code. I want to plot del n with omega for the given range and want to export the result in excel as a tabular form.

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

08-06-2014
03:21 PM

08-06-2014
03:21 PM

Re: Solving Kramers- Kronig from absorbance: Difficulty in interp function

Don't use vectors in the definition of Delta_n.

Setup that function so that it works for single values of the argument. Later you can vectorize the call.

What do you intend with the vector at the nominator? How and what should Mathcad calculate here when it integrates?

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

08-06-2014
04:47 PM

08-06-2014
04:47 PM

Re: Solving Kramers- Kronig from absorbance: Difficulty in interp function

Thank you Mr. Exinger for your reply.

For the calculation of delta n, I want to specify that , for each omega, they pick up corresponding omega one, and corresponding alpha for the whole dataset. Then I can obtain the plot for omega vs, del n. That is why I have vectorise all the denominators.

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

08-06-2014
05:31 PM

08-06-2014
05:31 PM

Re: Solving Kramers- Kronig from absorbance: Difficulty in interp function

Hirak Chatterjee wrote:

Thank you Mr. Exinger for your reply.

For the calculation of delta n, I want to specify that , for each omega, they pick up corresponding omega one, and corresponding alpha for the whole dataset.

Corresponding? They are of different magnitude!

omega1 is not a vector at all (it should be) but a range variable and takes 56 values

omaga consists of 55 values but this does not matter for the integrals as omega is the variable of integration

alpha1 and so also Deltaalpha(alpha1) have just 21 elements.

Guess you have some things to sort out.

BTW, you are using vecorization too often.

Top Tags