All problems
Conjugate Function Value
Problem
The convex conjugate of f(x) = e^x is f*(y) = y * log(y) - y for y > 0, with f*(0) = 0.
Given y >= 0, return f*(y). The conjugate is always convex in y.
Hint
Maximize y*x - e^x over x; the optimizer is x = log(y).
Test cases
case 1
in: [1]
expected: -1
case 2
in: [0]
expected: 0
case 3
in: [2]
expected: -0.6137056388801094
case 4
in: [0.5]
expected: -0.8465735902799727
case 5
in: [2.718281828459045]
expected: 0
Starter codePython
def conjugate_exp(y):
# Your code here
pass5 test cases · run your code against them in the editor