Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

Login


Options
Go to last post Go to first unread
Offline kaizh  
#1 Posted : 15 December 2023 01:31:52(UTC)
kaizh

Rank: Newbie

Groups: Registered
Joined: 06/09/2023(UTC)
Posts: 9
China
Location: beijing

hello everyone,
i want to fit a list of data points by picewise quadratic function like this,

1.png
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:
2.png


any suggestion is welcomed, the .sm file is attatched for the datapoints
thanks in advance.
picewise_qudratic_fit.sm (15kb) downloaded 4 time(s).

Edited by user 21 December 2023 03:33:30(UTC)  | Reason: Not specified

Wanna join the discussion?! Login to your SMath Studio Forum forum account. New Registrations are disabled.

Offline StvMath  
#2 Posted : 15 December 2023 03:47:38(UTC)
StvMath


Rank: Advanced Member

Groups: Registered
Joined: 26/07/2022(UTC)
Posts: 35
United Kingdom
Location: UK

Was thanked: 22 time(s) in 19 post(s)
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 (21kb) downloaded 8 time(s).

Edited by user 15 December 2023 04:53:14(UTC)  | Reason: Not specified

thanks 1 user thanked StvMath for this useful post.
on 15/12/2023(UTC)
Offline Jean Giraud  
#3 Posted : 15 December 2023 07:10:16(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
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 (33kb) downloaded 1 time(s).
Offline kaizh  
#4 Posted : 15 December 2023 17:39:33(UTC)
kaizh

Rank: Newbie

Groups: Registered
Joined: 06/09/2023(UTC)
Posts: 9
China
Location: beijing

Originally Posted by: StvMath Go to Quoted Post
though it would be if you had chosen x = 0.555).

picewise_qudratic_fit_b.sm (21kb) downloaded 8 time(s).


thanks for your solution , but even though at 0.555 , the first derivative is not continuous
1.png
2.png

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

tmpB332.png
5.png
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.

Offline Razonar  
#5 Posted : 15 December 2023 19:59:22(UTC)
Razonar


Rank: Advanced Member

Groups: Registered
Joined: 28/08/2014(UTC)
Posts: 1,356
Uruguay

Was thanked: 815 time(s) in 516 post(s)
Originally Posted by: StvMath Go to Quoted Post
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 (21kb) downloaded 8 time(s).


Hi. I just take the excelent Stv work and add some basic maths.

picewise_qudratic_fit_b.sm (31kb) downloaded 6 time(s).

Clipboard01.png

Best regards.
Alvaro.
Offline kaizh  
#6 Posted : 15 December 2023 20:38:51(UTC)
kaizh

Rank: Newbie

Groups: Registered
Joined: 06/09/2023(UTC)
Posts: 9
China
Location: beijing

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.
Offline mkraska  
#7 Posted : 16 December 2023 01:31:12(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,986
Germany

Was thanked: 1124 time(s) in 721 post(s)
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 (83kb) downloaded 7 time(s).

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
Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
Offline Jean Giraud  
#8 Posted : 16 December 2023 02:51:31(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
Originally Posted by: kaizh Go to Quoted Post
hello everyone,

I see 3 plots, 3 correct plots but wrong.
Wrong ... explain:
plot 1000 points to get nice vertical discontinuity.
Jean

Offline Jean Giraud  
#9 Posted : 16 December 2023 03:14:50(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
Originally Posted by: Jean Giraud Go to Quoted Post
I see 3 plots, 3 correct plots but wrong.
Wrong ... explain:
plot 1000 points to get nice vertical discontinuity.
Jean


Worksheet66.sm (6kb) downloaded 6 time(s).

Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.