Created
June 3, 2013 12:04
-
-
Save demoth/5697694 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# параметр сглаживания | |
a = 1/100 | |
# аппроксимация модуля | |
ma = (a + x^2)^(1/2) | |
# выражение максимума через модуль | |
var('xm1 xm2') | |
xmax=1/2*(ma(xm1-xm2) + xm1 + xm2) | |
var_names = 'x1 x2 x3 x4' | |
args = var(var_names) | |
# понтовый дифференцируемый максимум нескольких переменных | |
def max_many(args): | |
#args = [] | |
n = len(args) | |
res = args[0] | |
for i in range(n-1): | |
res = xmax.subs({xm1:res, xm2:args[i+1]}) | |
return res |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment