Skip to content

Commit dbf57e3

Browse files
authored
Fix derivative term for odd power rule (#68)
Adjusted the derivative term for the odd power rule to correct edge case where convex relaxations are above the function.
1 parent 6453afd commit dbf57e3

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
with:
3535
version: ${{ matrix.version }}
3636
arch: ${{ matrix.arch }}
37-
- uses: actions/cache@v1
37+
- uses: actions/cache@v4
3838
env:
3939
cache-name: cache-artifacts
4040
with:

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "McCormick"
22
uuid = "53c679d3-6890-5091-8386-c291e8c8aaa1"
33
authors = ["Matthew Wilhelm <[email protected]>"]
4-
version = "0.13.7"
4+
version = "0.13.8"
55

66
[deps]
77
DiffRules = "b552c78f-8df3-52c6-915a-8e097449b14b"

src/forward_operators/power.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ end
193193
(0.0 <= xL) && (return x^n, n*x^(n - 1))
194194

195195
root_f(x::Float64, xL::Float64, xU::Float64) = (x^n - xL^n) - (x-xL)*(n)*(x^(n-1));
196-
root_df(x::Float64, xL::Float64, xU::Float64) = n*x^(n-1) + xL*n*(n-1)*x - n*x^(n-1) - n*(n-1)*x^(n-1);
196+
root_df(x::Float64, xL::Float64, xU::Float64) = (n-1)*n*x^(n-2)*(xL-x);
197197
inflection, flag = newton(xU, 0.0, xU, root_f, root_df, xL, xU)
198198
flag && (inflection = golden_section(xL, xU, root_f, xL, xU))
199199
if x <= inflection
@@ -207,7 +207,7 @@ end
207207
(0.0 <= xL) && (return dline_seg(^, pow_deriv, x, xL, xU, n))
208208

209209
root_f(x::Float64, xL::Float64, xU::Float64) = (xU^n-x^n) - (xU-x)*(n)*(x^(n-1));
210-
root_df(x::Float64, xL::Float64, xU::Float64) = -n*x^(n-1) - xU*n*(n-1)*x + n*x^(n-1) + n*(n-1)*x^(n-1);
210+
root_df(x::Float64, xL::Float64, xU::Float64) = -n^2*xU*x^(n-2) + n^2*x^(n-1) + n*xU*x^(n-2) - n*x^(n-1);
211211
inflection, flag = newton(xL, xL, 0.0, root_f, root_df, xL, xU)
212212
flag && (inflection = golden_section(xL, xU, root_f, xL, xU))
213213
if x <= inflection

0 commit comments

Comments
 (0)