topic Derivative of regression line in PTC Mathcad
https://community.ptc.com/t5/PTC-Mathcad/Derivative-of-regression-line/m-p/644860#M188582
<P>I have used a regression line to find a curve fitting my datapoints.<BR />Now I want to know the lowest point on my curve and I am trying to find that by finding the point where the derivative of the regression line is 0.</P>
<P> </P>
<P>So I made a formula g(a) using the results from the regress function (by refering to entries in the regress solution matrix). I can use this function correctly to plot the curve and to calculate results for different values of a.</P>
<P>However when I want to get the derivative it gives me a formula including the regress function. Solving the derivative for 0 is impossible.</P>
<P> </P>
<P>To check if I use the correct functions I also made a formula h(a). Basically the same as g(a), but now I have manually typed the results from the regress function in the formula, instead of linking to the regress solution matrix.</P>
<P>Now I can get the derivative and solve for equal to 0.</P>
<P>However this is not convenient if my datapoints change, because I have to manually update h(a) each time.</P>
<P> </P>
<P>Is what I want possible and how to solve this? In other words, what am I doing wrong?</P>
<P> </P>
<P>Attached a mathcad 15 file with an example.</P>
<P> </P>
<P>Thanks in advance for your replies.</P>Sun, 19 Jan 2020 07:53:52 GMTcorne_m2020-01-19T07:53:52ZDerivative of regression line
https://community.ptc.com/t5/PTC-Mathcad/Derivative-of-regression-line/m-p/644860#M188582
<P>I have used a regression line to find a curve fitting my datapoints.<BR />Now I want to know the lowest point on my curve and I am trying to find that by finding the point where the derivative of the regression line is 0.</P>
<P> </P>
<P>So I made a formula g(a) using the results from the regress function (by refering to entries in the regress solution matrix). I can use this function correctly to plot the curve and to calculate results for different values of a.</P>
<P>However when I want to get the derivative it gives me a formula including the regress function. Solving the derivative for 0 is impossible.</P>
<P> </P>
<P>To check if I use the correct functions I also made a formula h(a). Basically the same as g(a), but now I have manually typed the results from the regress function in the formula, instead of linking to the regress solution matrix.</P>
<P>Now I can get the derivative and solve for equal to 0.</P>
<P>However this is not convenient if my datapoints change, because I have to manually update h(a) each time.</P>
<P> </P>
<P>Is what I want possible and how to solve this? In other words, what am I doing wrong?</P>
<P> </P>
<P>Attached a mathcad 15 file with an example.</P>
<P> </P>
<P>Thanks in advance for your replies.</P>Sun, 19 Jan 2020 07:53:52 GMThttps://community.ptc.com/t5/PTC-Mathcad/Derivative-of-regression-line/m-p/644860#M188582corne_m2020-01-19T07:53:52ZRe: Derivative of regression line
https://community.ptc.com/t5/PTC-Mathcad/Derivative-of-regression-line/m-p/644863#M188583
<P>Hi</P>
<P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="corn-m answer.jpg" style="width: 512px;"><img src="https://sejnu66972.i.lithium.com/t5/image/serverpage/image-id/22796i175371CB9459778A/image-size/large?v=1.0&px=999" title="corn-m answer.jpg" alt="corn-m answer.jpg" /></span></P>Sun, 19 Jan 2020 10:06:51 GMThttps://community.ptc.com/t5/PTC-Mathcad/Derivative-of-regression-line/m-p/644863#M188583-MFra-2020-01-19T10:06:51ZRe: Derivative of regression line
https://community.ptc.com/t5/PTC-Mathcad/Derivative-of-regression-line/m-p/644866#M188584
<P>Try this</P>
<P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LucMeekes_0-1579434008712.png" style="width: 400px;"><img src="https://sejnu66972.i.lithium.com/t5/image/serverpage/image-id/22797iBF9530F14A8BAB1E/image-size/medium?v=1.0&px=400" title="LucMeekes_0-1579434008712.png" alt="LucMeekes_0-1579434008712.png" /></span></P>
<P>then:</P>
<P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LucMeekes_1-1579434032454.png" style="width: 400px;"><img src="https://sejnu66972.i.lithium.com/t5/image/serverpage/image-id/22798iEB76391218807680/image-size/medium?v=1.0&px=400" title="LucMeekes_1-1579434032454.png" alt="LucMeekes_1-1579434032454.png" /></span></P>
<P> </P>
<P>Success!<BR />Luc</P>Sun, 19 Jan 2020 11:41:19 GMThttps://community.ptc.com/t5/PTC-Mathcad/Derivative-of-regression-line/m-p/644866#M188584LucMeekes2020-01-19T11:41:19ZRe: Derivative of regression line
https://community.ptc.com/t5/PTC-Mathcad/Derivative-of-regression-line/m-p/644868#M188585
<P>Mathcad has done the differentiation!</P>
<P>If you look at the error message it says the result is too big to display. However, you can still use the result.</P>
<P> </P>
<P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="gradient.jpg" style="width: 550px;"><img src="https://sejnu66972.i.lithium.com/t5/image/serverpage/image-id/22799i700D234B11A28BFD/image-size/large?v=1.0&px=999" title="gradient.jpg" alt="gradient.jpg" /></span></P>
<P> </P>
<P> </P>
<P>Alan</P>Sun, 19 Jan 2020 11:52:23 GMThttps://community.ptc.com/t5/PTC-Mathcad/Derivative-of-regression-line/m-p/644868#M188585AlanStevens2020-01-19T11:52:23ZRe: Derivative of regression line
https://community.ptc.com/t5/PTC-Mathcad/Derivative-of-regression-line/m-p/644872#M188586
<P>Incidentally, If all your polynomes are 3rd order and like the one given, the (positive) zero always occurs at</P>
<P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LucMeekes_1-1579434821667.png" style="width: 400px;"><img src="https://sejnu66972.i.lithium.com/t5/image/serverpage/image-id/22801i94FEE33D409D63BB/image-size/medium?v=1.0&px=400" title="LucMeekes_1-1579434821667.png" alt="LucMeekes_1-1579434821667.png" /></span></P>
<P>And instead of symbolically solving this, you could also use a numeric solver, which can happily work with the output of the interp function:</P>
<P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LucMeekes_2-1579434977532.png" style="width: 400px;"><img src="https://sejnu66972.i.lithium.com/t5/image/serverpage/image-id/22802i048B6902BC4A0318/image-size/medium?v=1.0&px=400" title="LucMeekes_2-1579434977532.png" alt="LucMeekes_2-1579434977532.png" /></span></P>
<P> </P>
<P>Success!<BR />Luc</P>
<P> </P>Sun, 19 Jan 2020 11:56:34 GMThttps://community.ptc.com/t5/PTC-Mathcad/Derivative-of-regression-line/m-p/644872#M188586LucMeekes2020-01-19T11:56:34ZRe: Derivative of regression line
https://community.ptc.com/t5/PTC-Mathcad/Derivative-of-regression-line/m-p/644875#M188587
<P>Rather than "regress" you might try "polyfit." Polyfit returns a function so you don't have to extract the coefficients from a vector.</P>Sun, 19 Jan 2020 16:46:20 GMThttps://community.ptc.com/t5/PTC-Mathcad/Derivative-of-regression-line/m-p/644875#M188587FredKohlhepp2020-01-19T16:46:20ZRe: Derivative of regression line
https://community.ptc.com/t5/PTC-Mathcad/Derivative-of-regression-line/m-p/644877#M188588
<P>Hello !,</P>
<P>you simply have to reset the symbolic variables</P>
<P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="corn-m answer 1.jpg" style="width: 698px;"><img src="https://sejnu66972.i.lithium.com/t5/image/serverpage/image-id/22803i537A7050A90BE16B/image-size/large?v=1.0&px=999" title="corn-m answer 1.jpg" alt="corn-m answer 1.jpg" /></span></P>Sun, 19 Jan 2020 16:56:11 GMThttps://community.ptc.com/t5/PTC-Mathcad/Derivative-of-regression-line/m-p/644877#M188588-MFra-2020-01-19T16:56:11ZRe: Derivative of regression line
https://community.ptc.com/t5/PTC-Mathcad/Derivative-of-regression-line/m-p/645079#M188603
<P>Thanks all for your replies.</P>
<P> </P>
<P>My datasets are a result of a longwinding calculation, which I want to perform using tabulated input for multiple sets if input parameters. As I need to put all calculations into a program and repeat that program for all rows of the input tables, it is must useful if I can determine derivative=0 by simple formula. This is also easy because the output/result I want is the a value for all different inputs in a table to be able to calculate average a and so on.</P>
<P>As I am sure a is always between 0 and 1 (actually being 0 to 100%) I used the root function because it is the easiest solution for my problem.</P>Tue, 21 Jan 2020 07:30:14 GMThttps://community.ptc.com/t5/PTC-Mathcad/Derivative-of-regression-line/m-p/645079#M188603corne_m2020-01-21T07:30:14Z