Community Tip - You can change your system assigned username to something more personal in your community settings. X
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
Solved! Go to Solution.
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.
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):
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:
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.
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.
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):
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:
Terry and Werner, thank you for your help. Werner thanks for the in depth explanation which put the finger on the right spot!
Probably, we can add the following values to the starting vectors x and y: x[1=0, y[1=10156.
Thank you Viktor, this is a good suggestion which I will keep in mind