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

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

Solving Kramers- Kronig from absorbance: Difficulty in interp function

HirakChatterjee
1-Visitor

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

12 REPLIES 12

What is the link to the dropbox for?

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

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.

1.png

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.

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:

1.png

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.

2.png

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.

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?

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.

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.

Look if the attached is somwhere wher you want to go

Thank you Mr. Exinger for providing me such good lessons.

The attachment you have posted here opens up as a blank worksheet. I don't see any formulations there. It might not be uploaded correctly. Would you mind to resend me the worksheet?

Thanking you again,

Hirak

Hirak Chatterjee wrote:

Thank you Mr. Exinger for providing me such good lessons.

The attachment you have posted here opens up as a blank worksheet. I don't see any formulations there. It might not be uploaded correctly. Would you mind to resend me the worksheet?

Thanking you again,

Hirak

No, the attachment is OK. The problem seems to be that you never stated which version of Prime you are using and I guess its Prime2. The worksheet I sent was in Prime3 format and its normal behaviour (from PTC's point of view, not my opinion) that it shows blank when opened in Prime2.

Thanks to PTC there is no way to convert that sheet back to Prime2 format, so all I can do is sending you a pdf printout of that file so you can retype it if you are interested.

BTW, are you sure about the limits in your integrals? Look at the last calculation and plot in my sheet.

Announcements

Top Tags