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

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

Curve fitting of a complex function

Gigiont
1-Newbie

Curve fitting of a complex function

Hello,
I'm trying to fit the imaginary component of an electrical impedance as a function of the real component. Both depend on frequency and I don't see how to express explicitly the imaginary component as a function of the real one.
To do the fit I tried to use a solve block and minimize the residuals for both real and imaginary parts but the result is not that good. Also all the parameters' values need to be positive. I understand that this may not give the best fit, but why MathCad ignores the constraint "Lsc>0"?
I there a better way to fit Im(Re, parameters)?
Thanks,
Gigi
63 REPLIES 63

The imaginary part is not a proper function of the real part. The curve loops around. What's wrong with just doing everything as a function of frequency?

You positivity constraint is not being ignored. It is being considered like every other constraint when minimizing the overall error. It is not very negative, and so contributes little to the overall error.
__________________
� � � � Tom Gutman

Could you convert this file to MC11 for me?
KL


__________________
� � � � Tom Gutman

There is a very similar task. Somehow the Minerr does not converge even if guess values look quite close.
Is this a problem of the type of the function that is being used, or have I put there something wrong?
As a remark: -Im(Z) is a convention in impedance spectroscopy (if the network is "capacitive in general").

KL

On 4/14/2010 4:12:27 AM, KristjanLaes wrote:
>There is a very similar task.
>Somehow the Minerr does not
>converge even if guess values
>look quite close.
>Is this a problem of the type
>of the function that is being
>used, or have I put there
>something wrong?

You redefine Re and Im functions.

In the attached, seems to be a good visual fit, even the errors for high frequencies are very big. Also, need a set of guesses for each j.

Regards. Alvaro.

Values of n1, n2 and n3 are expected to lie in the range of +/-1. n3 is too great.
I wonder that the manual fit looks fine, but such mysteries appear with the help of solve block.

KL

On 4/14/2010 7:00:39 AM, KristjanLaes wrote:
>Values of n1, n2 and n3 are
>expected to lie in the range
>of +/-1. n3 is too great.

Point is just restrict the domain inside the target function because this looks better idea to add restrictions in the given / minerr block. Take a look then to the attached. Seems to work to all values of j, with enough visual approximation.

Also there a chance to make all of the calculations vectorized and plot them at the same time, but probably it take a long time to solve for all j's.

Regards. Alvaro.

On 4/14/2010 4:12:27 AM, KristjanLaes wrote:
>There is a very similar task.
>Somehow the Minerr does not
>converge even if guess values
>look quite close.
>Is this a problem of the type
>of the function that is being
>used, or have I put there
>something wrong?
>As a remark: -Im(Z) is a
>convention in impedance
>spectroscopy (if the network
>is "capacitive in general").
>
>KL
______________________________

Too many problems, comments attached.

jmG



Did you forget the attachment?

KL

On 4/14/2010 11:37:20 AM, KristjanLaes wrote:
>Did you forget the attachment?
>
>KL
_______________________________

Often the attachment arrives after the message.
I have seen it on the click "Upload now".
It is still there.

jmG



On 4/14/2010 12:52:09 PM, jmG wrote:
>On 4/14/2010 11:37:20 AM, KristjanLaes
>wrote:
>>Did you forget the attachment?
>>
>>KL
>_______________________________
>
>Often the attachment arrives after the
>message.
>I have seen it on the click "Upload
>now".
>It is still there.
>
>jmG
>__________________________

For this particular data set, the continued fraction Minerr is robust and easy to initialise.

Not all cases will be that nice.

jmG



The data collection is more than in serious doubt,
you can't have 7.401e4 followed next -3.475e5.
Just declare the lab test unusable. You might think only part of the collection, OK but how reliable is the "reliable part" ? That data set is scrap ... wrong lab procedure ? inadequate equipment ? Data are just data but the information is embedded and if the data set is wrong, surely the analysis of it.

Worth thinking again.

jmG

Thank you in advance!
I will try to understand that you suppose me to do.
The equipment may have crashed meanwhile. This I have to check. You are right.
But the task for me is principal: to be able to fit complex data from the measurement. Many kind of fitting procedures are needed, this is only a first step.

KL

On 4/14/2010 3:07:45 PM, KristjanLaes wrote:
>Thank you in advance!
...
>But the task for me is
>principal: to be able to fit
>complex data from the
>measurement. Many kind of
>fitting procedures are needed,
>this is only a first step.
>
>KL
_______________________________

Kristjan,

Let's clarify some points:

The phenomenon you are collecting does not have enough data for a Fourier analysis. The phenomenon is not some pure function like sin(x). You would need at least 256 values, you have only 41. Eventually it can be managed from a fit
Comments attached.
Which plot do you want to fit: Y ?, Delta ? both ?

jmG

This can be done: there is another device available for the measurement.
It produces easily these 256 points and probably it gives data without complications. I will come back later with them.

You asked: what is needed to be fitted?
A complex function of frequency is needed to be fitted: Re(F(f,n1,Q1,n2,Q2, etc.))= Z` and Im(F(f,n1,Q1,n2,Q2, etc.))=Z``
or Re(F(f,n1,Q1,n2,Q2,etc.))+j*Im(F(f,n1,Q1,n2,Q2,etc.))= Z, where Z=Z`+j*Z``.
F is there a kind of fitting function, f is frequency and n1, Q1, etc. are fitting parameters.
Is this what you asked?

KL

On 4/15/2010 3:43:40 AM, KristjanLaes wrote:

>You asked: what is needed to
>be fitted?
>A complex function of
>frequency is needed to be
>fitted: Re(F(f,n1,Q1,n2,Q2,
>etc.))= Z` and
>Im(F(f,n1,Q1,n2,Q2, etc.))=Z``
>or
>Re(F(f,n1,Q1,n2,Q2,etc.))+j*Im
>(F(f,n1,Q1,n2,Q2,etc.))= Z,
>where Z=Z`+j*Z``.

Attached file

http://collab.mathsoft.com/upload/CdTe%205_2_09(2).mcd

don't do this?

Regards. Alvaro.

Alvaro,

this fitting has a strange result.
It says that there is a capacitor (n3=1) with a capacitance of 618 Farad.

This would not go.

KL

On 4/15/2010 5:26:49 AM, KristjanLaes wrote:
>Alvaro,
>
>this fitting has a strange
>result.
>It says that there is a
>capacitor (n3=1) with a
>capacitance of 618 Farad.
>
>This would not go.

Can you provide valid ranges for the parameters? Without units it's hard to identify. And a minimization problem it's not complete without having the correct domain.

The method that I propose consists in
1. usual guessing
2. applying to the parameters of the target function those restrictions defining the new target,
3. minimize equating zero weighted square real part plus square imaginary part,
4. with this values as new guesses, minimize the complex target equated to zero
5. apply to the parameters the restrictions to gave the final result.

Regards. Alvaro.

That's about the all that can be done,
fit the two columns separately, replot.

jmG

That's my interpretation from your attempted model and plot. This linfit is manual but it does a lot better fit and the model is visual. By the time you twist a model that you can't modify, this one is done in much less time. The point is that now you can reconstruct in the PW Minerr technique. You try, but you will get all sorts of weird exponents.

jmG

On 4/15/2010 3:43:40 AM, KristjanLaes wrote:
>This can be done: there is
>another device available for
>the measurement.
>It produces easily these 256
>points and probably it gives
>data without complications. I
>will come back later with
>them.
>
>You asked: what is needed to
>be fitted?
>A complex function of
>frequency is needed to be
>fitted: Re(F(f,n1,Q1,n2,Q2,
>etc.))= Z` and
>Im(F(f,n1,Q1,n2,Q2, etc.))=Z``
>or
>Re(F(f,n1,Q1,n2,Q2,etc.))+j*Im
>(F(f,n1,Q1,n2,Q2,etc.))= Z,
>where Z=Z`+j*Z``.
>F is there a kind of fitting
>function, f is frequency and
>n1, Q1, etc. are fitting
>parameters.
>Is this what you asked?
>
>KL
_____________________________

Yes, Kristjan !

But you have two project in one. And you don't say what is what in the data table. Those data aren't just numbers, those number they qualify something . In my reply "Proposal" , what is column 1 ? just time stamp labels ? What is column 2 ? the real part collected ? What is column 3 ? the imaginary part collected ?
What I'm saying is that you are trying to design a circuit to model some data but you don't know which data it should model. Up until now, your data, they just plot but plot what ? In your very initial premises, you have a "snail plot" and you proposed an RLC circuit to imitate the plot. The answer is: not possible with a linear design. You must have lot more components, some of them to model more involved mathematical functions. That is going back to the days of analog computers [Systron Doner to name one ... check Doner spelling]

Read that work sheet again. No problem to fit the snail in pieces, and if that's what you want, you will just have to designer the circuits with all the necessary choppers.

Cheers Kristjan,

Jean

Kristjan,

Here is your "snail plot" fit.
deCasteljau 5 pairs [4 segments].
Done rough in few minutes while waiting "a Lady' !
No idea how to automate it in Mathcad1 11 ?
Less idea how to implement it in physical circuit.
It just shows that if the bridge does not cross the river,
it's like having no bridge crossing the river.

jmG

On 4/15/2010 4:14:10 PM, jmG wrote:
>Kristjan,
>
>Here is your "snail plot" fit.
>deCasteljau 5 pairs [4
>segments].
>Done rough in few minutes
>while waiting "a Lady' !
>No idea how to automate it in
>Mathcad1 11 ?
>Less idea how to implement it
>in physical circuit.
>It just shows that if the
>bridge does not cross the
>river,
>it's like having no bridge
>crossing the river.
>
>jmG
___________________________

Deceptively simple, the project ends there.
Your part is to model the circuit and build it.
Saved in Mathcad 8 for more collabs to comment/collaborate.

jmG





jmG,
is this type of function that is there in my first post in this thread, a Bernstein polynomial or a representation of a B�zier curve?

Maybe this is not?

KL

On 4/16/2010 6:08:43 AM, KristjanLaes wrote:
>jmG,
>is this type of function that
>is there in my first post in
>this thread, a Bernstein
>polynomial or a representation
>of a B�zier curve?
>
>Maybe this is not?
>
>KL
>______________________________

All those things are horribly explained, in fact not demonstrated in any valid terms from the web. Bernstein is B�zier in suite, i.e: continuously stepping from points to points. In the same way that the mid point of the B�zier quadratic is a control point, in the Bernstein suite you can add two more vectors of control points.

That said, Piere B�zier and Paul De Casteljau ignored themselves as each one was working for two different car manufacturers [competitors]. The Mathcad De Casteljau recursive does in 3 lines of programme what several lines of C does. This recursive is the same as the Bernstein suite. Both, B�zier-Berstein suite and De Casteljau recusive start and end at the first and last pairs of coordinates. All the pairs in between are control points. The difference is that in B�zier-Bernstein the control points are in a "weight vector" unlike De Casteljau that takes the control points as "valued". They both construct the same but De Casteljau is immediately easier to manipulate and constructs the polygon in true values in the graph.

In that work sheet, I was able to manipulate the recursive quite a number of times, even in few minutes ... everything was fine. As soon as the Fourier CFFT/ICFFT was added for exploring the project, it is then that the mysterious yet unexplained "memory leak" appeared. Some Mathcad functionalities aren't compatible and this is the best proof that Alvaro has just confirmed. What I was saying in the other thread about the Mathcad 14 "memory leak", is that the attractive recursive ways of computing might have been implemented in too many built-in function, or simply made more available and/or suggested.

Whatever, the missing link is about there.
Mona will surely catch this big fish .

The memory leak can be resumed as the lack of logic path finding between certain functionalities. Some collabs have never experienced since 14, but too many have and that renders their previous working version saturate. Maybe too many random stack addressing or whatever technical explanation.

Few more hours and the collection "MCADeng splines" might be ready for the collab. The very early "memory leak" dates back from Xavier [Mathcad 11]. I'm not surprised because Xavier was very exhaustive in programming Mathcad and by the same token scratching Mathcad.
Memory leak is when Mathcad loses the "sky hoke".

jmG
Top Tags