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

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

Where did I do wrong in in solving Least Square Method?

Adlil
8-Gravel

Where did I do wrong in in solving Least Square Method?

Hello PTC fam,
I don't know where did I do wrong in this programe.
the question is

Determine least square method value of coefficients Ci( i=0,...,m) in polynomial form.

Adlil_0-1650006616655.png


Calculate the approximation error  where m=3

Adlil_1-1650006637159.png

 



Please advice.
Regards,
Adlil

ACCEPTED SOLUTION

Accepted Solutions
LucMeekes
23-Emerald III
(To:Adlil)

Did you mean to do this:

LucMeekes_0-1650015237550.png

Then:

LucMeekes_1-1650015833487.png

Finally:

LucMeekes_3-1650016354970.png

But there are options for minerr. If you press the right-mouse button on it, you can select other minimisation strategies. The above was done using 'Linear' (The default). For non-linear: Levenberg-Marquardt you may get:

LucMeekes_4-1650016487586.png

Success!
Luc

View solution in original post

7 REPLIES 7
LucMeekes
23-Emerald III
(To:Adlil)

Your sheet does not explain well what you are trying to achieve. Apart from that:

1. The summation for Toc in above picture goes from i=0 to m, when m=3, that means you should get C as a vector of 4 elements. Your sheet shows you calculate a vector C consisting of only three elements. The input for that calculation (matrix A and vector B) do not seem to be related to alpha or T.

2. Instead of the solve block, you can use the lsolve function to determine C from A and B:

LucMeekes_0-1650013718887.png

3. What is the vector K calculated for?

 

Success!
Luc

LucMeekes
23-Emerald III
(To:Adlil)

Did you mean to do this:

LucMeekes_0-1650015237550.png

Then:

LucMeekes_1-1650015833487.png

Finally:

LucMeekes_3-1650016354970.png

But there are options for minerr. If you press the right-mouse button on it, you can select other minimisation strategies. The above was done using 'Linear' (The default). For non-linear: Levenberg-Marquardt you may get:

LucMeekes_4-1650016487586.png

Success!
Luc

Thank you for the reply. Pardon I should reconfirm back with you before hit the "accept the solution" button. I would like to ask 

1. Does Gauss method is that simple ? Mind to explain why Gauss method we need to list like this compare to my version.
2. What is Minerr function is ?
3. Why do you sort vector T and alpha ?

Sorry if my questions didn't look smart since I really want to understand this program and the task given. Thanks again waiting for your reply.

Adlil_0-1650567939938.png

 

Fred_Kohlhepp
23-Emerald I
(To:Adlil)

I've been playing with this.  A direct least squares fit to this data with a third order polynomial isn't great.  But a fourth order fit to the natural logs looks pretty good. (My apologies for diverting the discussion!)  Sheet in Prime 4.0 Express.

Fred_Kohlhepp_0-1650111336924.png

 

Thanks for the reply, didn't expect you achieve that close in the graph. Sadly I don't have Prime 4.0 appreciate for the help.

Werner_E
25-Diamond I
(To:Adlil)

Here is a screenshot of Freds work (I just omitted the grid which can be achieved much easier in real Mathcad)

Werner_E_2-1650570471928.png

 

You can also create his function using Mathcads built-in polyfit function.
Here a comparison of a rational fit (f1), a polynomial fit of fourth order (f2) and Freds approach (f3).

According to the sum of squared errors the polynomial fit (f2) would win, but I bet you don't like the curve in the range from 2 to 5. So I guess that Freds approach rules.

Werner_E_1-1650570381111.png

MC15 sheet attached

 

 

Fred_Kohlhepp
23-Emerald I
(To:Adlil)

Sadly I don't have Prime 4.0 appreciate for the help.

 

Any version of Prime above 3 will read my file.

Announcements

Top Tags