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

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

Why is d undefined

FDS
13-Aquamarine
13-Aquamarine

Why is d undefined

In the attached worksheet (Mathcad 15) d is apparently undefined. Why is this, it is defined before the solve block as a guess? I assume I am overlooking the obvious

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:FDS)

Error messages of solve blocks unfortunately never/seldom will tell you the real reason for its failing. You could use "trace error" from the right click menu to find out.

In your solve block you are using variables ssd and vector dev to split the single expression you want to minimize into better readable parts. Mathcad does not know what to to with those variables. You could either solve for those variables additionally to b, k, etc. but this would unnecessary clutter the minerr command.

So the other option (if you don't want to do it with one big equation like terry) is to turn those variables to functions. Fortunately those five expressions are the same - calculation of the difference (BTW, what would you do if you have to fit a data set consisting of 500 data points and not just 5?). So the calculation could be done for the whole vector in just one function.

B1.png

The fit we get is a rather bad one as you will see later and I'll show in a moment how to do it better.

The fit we get that way is the very same you get with Terrys sheet if you correct his typo (the last expression should be squared, too and not taken to the power of 6). EDIT: Just see that Terry had already corrected that error in a follow up post.

 

Are you aware that Mathcad offers a genfit function which you could use to fit your data to an arbitrary function. Its quite easy to use and the only drawback is that you can't use your constraints with genfit. Fortunately all of your constraints are fulfilled by the genfit solution and as you can see in the next picture, the fit is better than that of the former solve block (SQE 2863 vs. 76):

B2.png 

 

Now why is the solve block doing so bad? The reason is the way you have set it up. You simply demand that the sum of the squared differences should be zero. Thats not much Mathcads algorithm can ply with. Its far better to calculate the whole vector of differences and demand that this should be the zero vector. Doing so gives you the same quality fit as genfit and you can use constraints if needed:

B3.png

View solution in original post

6 REPLIES 6

Hi,

 

You only have one equation to minimise the error on.

Define it as one equation without all the other intermediate variables.

You get a working solve block.

The intermediate values are not defined.

 

Hi,

 

Sorry one of the exponents wrong:=}

Werner_E
25-Diamond I
(To:FDS)

Error messages of solve blocks unfortunately never/seldom will tell you the real reason for its failing. You could use "trace error" from the right click menu to find out.

In your solve block you are using variables ssd and vector dev to split the single expression you want to minimize into better readable parts. Mathcad does not know what to to with those variables. You could either solve for those variables additionally to b, k, etc. but this would unnecessary clutter the minerr command.

So the other option (if you don't want to do it with one big equation like terry) is to turn those variables to functions. Fortunately those five expressions are the same - calculation of the difference (BTW, what would you do if you have to fit a data set consisting of 500 data points and not just 5?). So the calculation could be done for the whole vector in just one function.

B1.png

The fit we get is a rather bad one as you will see later and I'll show in a moment how to do it better.

The fit we get that way is the very same you get with Terrys sheet if you correct his typo (the last expression should be squared, too and not taken to the power of 6). EDIT: Just see that Terry had already corrected that error in a follow up post.

 

Are you aware that Mathcad offers a genfit function which you could use to fit your data to an arbitrary function. Its quite easy to use and the only drawback is that you can't use your constraints with genfit. Fortunately all of your constraints are fulfilled by the genfit solution and as you can see in the next picture, the fit is better than that of the former solve block (SQE 2863 vs. 76):

B2.png 

 

Now why is the solve block doing so bad? The reason is the way you have set it up. You simply demand that the sum of the squared differences should be zero. Thats not much Mathcads algorithm can ply with. Its far better to calculate the whole vector of differences and demand that this should be the zero vector. Doing so gives you the same quality fit as genfit and you can use constraints if needed:

B3.png

FDS
13-Aquamarine
13-Aquamarine
(To:Werner_E)

Terry and Werner, thank you for your help. Werner thanks for the in depth explanation which put the finger on the right spot!

ViktorKorobov
14-Alexandrite
(To:FDS)

Probably, we can add the following values to the starting vectors x and y:  x[1=0, y[1=10156.

290418.png

Viktor
FDS
13-Aquamarine
13-Aquamarine
(To:ViktorKorobov)

Thank you Viktor, this is a good suggestion which I will keep in mind

Announcements

Top Tags