変数が増えると、一見連続そうに見えても、不連続な場合がある。
例1:
import numpy as np from matplotlib import pyplot as plt def arbitrary_function( x, y ): return ( x - y ) / ( x + y + 1e-7 ) N = 1000 x_min, x_max = -1, 1 y_min, y_max = -1, 1 x1 = np.linspace( x_min, x_max, N ) y1 = np.linspace( y_min, y_max, N ) X, Y = np.meshgrid( x1, y1 ) Z = np.zeros( ( N, N ) ) for ix, x_ in enumerate( x1 ): for iy, y_ in enumerate( y1 ): Z[ iy ][ ix ] = arbitrary_function( x_, y_ ) # Caution: not Z[ ix ][ iy ] fig = plt.figure( figsize = ( 5, 4 ) ) ax = fig.add_subplot( 1, 1, 1 ) c = ax.pcolor( X, Y, Z, cmap = 'viridis', vmin = -1, vmax = 1) # or "pcolormesh" fig.colorbar( c ) plt.savefig("discontiniuation1.png") plt.show()
上で不連続であることがわかる。
例2:
def arbitrary_function( x, y ): return 2 x y / ( x**2 + y**2 + 1e-7 )
で不連続になっている。
これは、軸上および軸上で値ゼロだが、対角線方向では-1 or 1の定数となるため、原点付近の微小量が方向に強く依存してしまっているためである。