MVR5
I,simplify/cfR6"6(%"iG%$locG%$outG%%restG%$varG%*mid_pointG6$%(remembeG%^pCopyr
ight~(c)~1997~by~Heinz~Bauschke,~Martin~v.~Mohrenschildt.~All~rights~reserved.G
F$@)-%%typeG6$9"%"+GC%>8%-%0fenchel/cfadderG6$-%)simplifyG6#-%#opG6$"""F3-F<6#-
F?6$""#F3?(8$""$FA-%%nopsG6#F3%%trueG>F7-F96$F7-F<6#-F?6$FHF3-F<6#F7-F16$F3%"*G
C*@$0-FK6#-%'selectG6%%$hasG-%(convertG6$F3%%listG.%#cfGFA-%&ERRORG6#%/Product~
of~cf~G>F7-F?Fhn>8'-%'removeG6%F\oF3Fao>8&%%NULLG>8(-F?6$FFF7>F7-F?6$FAF7?&FHF7
FM>F_p6$F_p7%-F?6$FAFH*&FjoFA-F?6$FFFHFA-F?6$FIFH-F<6#-Fao6$7#F_pFbp3/9#FA-%#is
G6#/-F?6$""!F3FaoC+>F7-F?6$FA&F36#FA>Fbp-F?6$FFFfr>F_pF`p?&FHF7FMC%>8)F_q@$-%(h
astypeG6$F_s%)infinityG>F_sFds>F_p6$F_p7%F\qF_sFaq>F7Fgq>F_pF`p>FHFA?(F$FAFAF$-
F\r6#1FH-FKFVC$@$-F\r6#2F`t,&FHFAFFFAC$>F_p6$F_p&F76#FH%&breakG@'3-%0fenchel/is
equalG6$-F?6$7$FHFFF7Fds-F`u6$-F?6$7$FftFFF7Fds@%-F`u6$-F?6$7$,&FHFAFAFAFFF7Fds
C$>F_p6$F_p7%-F?6$7$FHFAF7Fds-F?6$7$FftFIF7@%-F\r6#2F`t,&FHFAFIFAF\uC%>F_p6$F_p
&F76#F_w>FH,&FHFA""%FA%%nextGC%>F_p6%F_pFjt&F76#F`v>FHFftFhw3-%/fenchel/islessG
Fau-FaxFfu@%-F\r6#/FbuFguC$>F_p6$F_p7%FevFbuFhv@%F\wF\uC%>F_pFbw>FHFfwFhwC%>F_p
F[x>FHFftFhwC%>F_pF[x>FHFftFhw@%2-FK6#Fgq-FK6#FdrFcqFeqF3F$F$F$F$,
I#sdR6$%#liG%"xGF$6#F.F$-.F[zFLF$F$F$F$,
I2fenchel/sigsimperR6&%'x_leftG%%exprG%(x_rightGF_z6$%#xxGF(F`zF$C'-%-additiona
llyG6#29$FH-F][l6#2FH9&>F7-F<6#-%%subsG6$/9'FH9%-%)unassignGF[u-Fi[l6$/FHF\\lF7
F$F$F$F$,
I)sdevalatR6$%#saG%#eqGF$F`zF$-%&evalfG6#-Fi[l6$F]\lF`[lF$F$F$F$,
I(subdiffR6#%#aaG6/%"aGF^zF_zF(F&%"fGFfzFhz%%subdG%'x_currG%'y_currG%(df_leftG%
)df_rightGF`zF$C(>FHF`[l>F7-%2fenchel/read_listGF[u>F_p-%)read_varGF[u>FjoF`p?(
FbpFAFAF`tFMC'>F_s-%2fenchel/read_funcG6#&F76#Fbp>8*-%2fenchel/read_leftGFg^l>8
+-%3fenchel/read_rightGFg^l@'-F`uFcs>8,7"-Fax6$F[_lF__l>Fe_l7#-F<6#-%%diffG6$F_
sF_pC'>8-F[_l>8.-Fi[l6$/F_pFb`lF_s>8/-%&limitG6%*&,&-Ff^l6#&F76#,&FbpFA!""FAFAF
d`lFdalFA,&F_pFAFb`lFdalFdalFg`l%%leftG>80-F[al6%*&,&-Ff^l6#&F76#,&FbpFAFAFAFAF
d`lFdalFAFealFdalFg`l%&rightG@'5-F`u6$Fi`lFds-F`u6$Fhal,$FdsFdal>Fe_lFf_l-F`u6$
Fi`lFhal>Fe_l7#Fi`l>Fe_l7$Fi`lFhal>Fjo6$Fjo7%F[_lFe_lF__l-Fbz6$7#FjoF_pF$F$F$F$,
I-init/fenchelRF$F$F$F$C$-%*unportectG6#%*PIECEWISEG>F]dlF]dlF$F\dlF$F$,
I(type/cfR6#FgzF$F`zF$-%&evalbG6#/-F?6$FarF`[lFaoF$F$F$F$,
I3fenchel/read_rightR6#'%"lGF`oF$F`zF$-F?6$7#FIF`[lF$F$F$F$,
I)print/cfR6#Fb]l6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<=GC&>FjoFc]q>FbpFg]q>FjoF\^q>F_pFj^qFf\q7$FjoFd]qF$F$F$F$,
I'cfevalR6$Fb]lFg\l6&F&F^zF*F_zF`zF$C(>F7Ffhl>F_p-FbboFb`n>Fjo-FhboFb`n@$-F\r6#
0F_pF[il-Fdo6#%7Variables~don't~match!G?&FHF7FM@$-Fiil6%FjoFaflFcfl-Fb_n6#-F<6#
-Fi[l6$F]\lFefl-Fdo6$Ff_nF_pF$F$F$F$,
I2fenchel/read_leftRFjdlF$F`zF$Fi[pF$F$F$F$,
I#cfR6$'F^z%)listlistG'F_zF^[mF[_nF`zF$C(>F]dlF]dl@$43-F`u6$-F?6$7$FAFAF`[lFibl
-F`u6$-F?6$7$-FKF^\mFIF`[lFds-Fdo6$%DSomething~wrong~with~the~infinitiesGF3@$0-
FK6#Fi[pFI-Fdo6#%BItems~should~have~three~elements!G@$-F16$FhbqFb^p-Fdo6#%CTota
l~number~of~items~must~be~odd!G?(FHFAFAFhbqFM@%-F1F]do@$4-Fax6$-F?6$FgvF`[l-F?6
$FicoF`[l-Fdo6#%FSomething~wrong~with~an~odd~interval!GC$@$4-F`uF_dq-Fdo6#%GSom
ething~wrong~with~an~even~interval!G@$43-F`u6$-F?6$7$,&FHFAFdalFAFIF`[lF`dq-F`u
6$-F?6$7$F`vFAF`[lFbdq-Fdo6#%7Intervals~do~not~mesh!G-FaoFLF$F\dlF$F$
