1 страниц (9 вхождений)
picewise quadratic fit - maybe a newbie question.. - Сообщения
#1 Опубликовано: 14.12.2023 19:31:52
hello everyone,
i want to fit a list of data points by picewise quadratic function like this,

where 0.6 is the break point that i chose in advance .
the requirements are:
1. the function and its first derivetive at the break point should be continuous,
2. the break point is not known thus is also a parameter to fit.
(but in my data points, i wold like to choose 0.6 as breakpoint in advance )
this picewise quadratic is taken from a empirial expression , so it's not appropriate to take other function forms
The Fit function provided by Maxima plugin seems can not do that:

any suggestion is welcomed, the .sm file is attatched for the datapoints
thanks in advance.
picewise_qudratic_fit.sm (14 КиБ) скачан 26 раз(а).
i want to fit a list of data points by picewise quadratic function like this,
where 0.6 is the break point that i chose in advance .
the requirements are:
1. the function and its first derivetive at the break point should be continuous,
2. the break point is not known thus is also a parameter to fit.
(but in my data points, i wold like to choose 0.6 as breakpoint in advance )
this picewise quadratic is taken from a empirial expression , so it's not appropriate to take other function forms
The Fit function provided by Maxima plugin seems can not do that:
any suggestion is welcomed, the .sm file is attatched for the datapoints
thanks in advance.
picewise_qudratic_fit.sm (14 КиБ) скачан 26 раз(а).
#2 Опубликовано: 14.12.2023 21:47:38
Maxima isn't required! See the attached. (This simple approach isn't quite continuous at the cross-over point, though it would be if you had chosen x = 0.555).
picewise_qudratic_fit_b.sm (20 КиБ) скачан 35 раз(а).
picewise_qudratic_fit_b.sm (20 КиБ) скачан 35 раз(а).
1 пользователям понравился этот пост
Alvaro Diaz Falconi 15.12.2023 13:58:00
#3 Опубликовано: 15.12.2023 01:10:16
I want to fit a list of data points by picewise quadratic function
the requirements are:
1. the function and its first derivative at the break point should be continuous,
2. the break point is not known thus is also a parameter to fit.
................
Quadratic joins at support points automated wrt X vector.
Quadratic derivative can't be smooth at junctions.
Only cubic derivative is smooth at junctions.
Jean
Worksheet30.sm (32 КиБ) скачан 19 раз(а).
the requirements are:
1. the function and its first derivative at the break point should be continuous,
2. the break point is not known thus is also a parameter to fit.
................
Quadratic joins at support points automated wrt X vector.
Quadratic derivative can't be smooth at junctions.
Only cubic derivative is smooth at junctions.
Jean
Worksheet30.sm (32 КиБ) скачан 19 раз(а).
#4 Опубликовано: 15.12.2023 11:39:33
Wrotethough it would be if you had chosen x = 0.555).
picewise_qudratic_fit_b.sm (20 КиБ) скачан 35 раз(а).
thanks for your solution , but even though at 0.555 , the first derivative is not continuous
maybe the first derivative continuity of quadratic function at joint point can not be achieved in theory as Jean Giraud said , though the empirial expression I refer to does have continuity at joint point, the empirial expression ,which only needs the max y value , the min y value and a paticular x value , can give the picewice qudratic function , as below
the below figure have some typos in formula of a1 and b1 ,the above figue is correct
well i think it must have some additonal constraint conditon to achieve that.
if intrested , you can find this empirial function at :
[1] Li X, Shao W, Tang J, et al. An Investigation of the Contact Fatigue Characteristics of an RV Reducer Crankshaft, Considering the Hardness Gradients and Initial Residual Stress[J]. Materials, 2022, 15(21): 7850.
[2] Wang W, Liu H, Zhu C, et al. Evaluation of contact fatigue risk of a carburized gear considering gradients of mechanical properties[J]. Friction, 2020, 8(6): 1039-1050.
#5 Опубликовано: 15.12.2023 13:59:22
WroteMaxima isn't required! See the attached. (This simple approach isn't quite continuous at the cross-over point, though it would be if you had chosen x = 0.555).
picewise_qudratic_fit_b.sm (20 КиБ) скачан 35 раз(а).
Hi. I just take the excelent Stv work and add some basic maths.
picewise_qudratic_fit_b.sm (30 КиБ) скачан 30 раз(а).
Best regards.
Alvaro.
#6 Опубликовано: 15.12.2023 14:38:51
Thank you all guys and have a nice day, looks like I'll have to accept the fact that the jump point derivatives are discontinuous.
#7 Опубликовано: 15.12.2023 19:31:12
General remark for Fit():
- names for the variables and the parameters must be undefined. Use Clear for repeated fits if assignment was used.
- You can do the fit, evaluate the mean square error and plot the function without actually assigning the variables.
- Sometimes the default precision is not sufficient, then it is advisable to reduce the tolerance (optional argument)
For piecewise functions, use conditionals wrapped in charfun(). In Maxima conditionals evaluate to true or false, charfun() converts that to 1 or 0, so you can do arithmetics and plotting
If you want continuity between the functions, use the conditions to eliminate some parameters symbolically. This enforces these conditions exactly.
For the discontinuous independent functions, the fit can't include x.0 because the target function's dependence on x.0 is piecewise constant between data points. x.0 essentially assigns the data points to the independent fit ranges. So the derivative is zero or undefined, which Fit() can't handle.
For the continuous fit, the inclusion of x.0 as fit variable also fails but with less obvious reason, at least the derivatives of the error wrt x.0 should not be zero between data points.
picewise_qudratic_fit_Kr.sm (82 КиБ) скачан 29 раз(а).
![2023-12-15 12_10_11-SMath Solver - [picewise_qudratic_fit_Kr.sm_].png](/ru-RU/file/ZeHabc/2023-12-15-12_10_11-SMath-Solver---_picewise_qudratic_fit_Kr_sm___png)
![2023-12-15 12_09_29-SMath Solver - [picewise_qudratic_fit_Kr.sm_].png](/ru-RU/file/QwndV6/2023-12-15-12_09_29-SMath-Solver---_picewise_qudratic_fit_Kr_sm___png)
- names for the variables and the parameters must be undefined. Use Clear for repeated fits if assignment was used.
- You can do the fit, evaluate the mean square error and plot the function without actually assigning the variables.
- Sometimes the default precision is not sufficient, then it is advisable to reduce the tolerance (optional argument)
For piecewise functions, use conditionals wrapped in charfun(). In Maxima conditionals evaluate to true or false, charfun() converts that to 1 or 0, so you can do arithmetics and plotting
If you want continuity between the functions, use the conditions to eliminate some parameters symbolically. This enforces these conditions exactly.
For the discontinuous independent functions, the fit can't include x.0 because the target function's dependence on x.0 is piecewise constant between data points. x.0 essentially assigns the data points to the independent fit ranges. So the derivative is zero or undefined, which Fit() can't handle.
For the continuous fit, the inclusion of x.0 as fit variable also fails but with less obvious reason, at least the derivatives of the error wrt x.0 should not be zero between data points.
picewise_qudratic_fit_Kr.sm (82 КиБ) скачан 29 раз(а).
Martin Kraska
Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#8 Опубликовано: 15.12.2023 20:51:31
Wrotehello everyone,
I see 3 plots, 3 correct plots but wrong.
Wrong ... explain:
plot 1000 points to get nice vertical discontinuity.
Jean
#9 Опубликовано: 15.12.2023 21:14:50
WroteI see 3 plots, 3 correct plots but wrong.
Wrong ... explain:
plot 1000 points to get nice vertical discontinuity.
Jean
Worksheet66.sm (5 КиБ) скачан 25 раз(а).
1 страниц (9 вхождений)
-
Новые сообщения
-
Нет новых сообщений