def fpde(x, y, int_mat): """(D_{0+}^alpha + D_{1-}^alpha) u(x)""" if isinstance(int_mat, (list, tuple)) and len(int_mat) == 3: int_mat = tf.SparseTensor(*int_mat) lhs = tf.sparse_tensor_dense_matmul(int_mat, y) else: lhs = tf.matmul(int_mat, y) lhs /= 2 * tf.cos(alpha * np.pi / 2) rhs = gamma(alpha0 + 2) * x return lhs - rhs[:tf.size(lhs)]
def fpde(x, y, int_mat): """\int_theta D_theta^alpha u(x)""" if isinstance(int_mat, (list, tuple)) and len(int_mat) == 3: int_mat = tf.SparseTensor(*int_mat) lhs = tf.sparse_tensor_dense_matmul(int_mat, y) else: lhs = tf.matmul(int_mat, y) lhs = lhs[:, 0] lhs *= gamma((1 - alpha) / 2) * gamma((3 + alpha) / 2) / (2 * np.pi**2) x = x[:tf.size(lhs)] rhs = (2**alpha * gamma(2 + alpha / 2) * gamma((3 + alpha) / 2) / gamma(3 / 2) * (1 - (1 + alpha / 3) * tf.reduce_sum(x**2, axis=1))) return lhs - rhs
def fpde(x, y, int_mat): """du/dt + (D_{0+}^alpha + D_{1-}^alpha) u(x) = f(x)""" if isinstance(int_mat, (list, tuple)) and len(int_mat) == 3: int_mat = tf.SparseTensor(*int_mat) lhs = -tf.sparse_tensor_dense_matmul(int_mat, y) else: lhs = -tf.matmul(int_mat, y) dy_t = tf.gradients(y, x)[0][:, 1:2] x, t = x[:, :-1], x[:, -1:] rhs = -dy_t - tf.exp(-t) * ( x ** 3 * (1 - x) ** 3 + gamma(4) / gamma(4 - alpha) * (x ** (3 - alpha) + (1 - x) ** (3 - alpha)) - 3 * gamma(5) / gamma(5 - alpha) * (x ** (4 - alpha) + (1 - x) ** (4 - alpha)) + 3 * gamma(6) / gamma(6 - alpha) * (x ** (5 - alpha) + (1 - x) ** (5 - alpha)) - gamma(7) / gamma(7 - alpha) * (x ** (6 - alpha) + (1 - x) ** (6 - alpha)) ) return lhs - rhs[: tf.size(lhs)]
def fpde(x, y, int_mat): """(D_{0+}^alpha + D_{1-}^alpha) u(x) = f(x)""" if isinstance(int_mat, (list, tuple)) and len(int_mat) == 3: int_mat = tf.SparseTensor(*int_mat) lhs = tf.sparse_tensor_dense_matmul(int_mat, y) else: lhs = tf.matmul(int_mat, y) rhs = (gamma(4) / gamma(4 - alpha) * (x**(3 - alpha) + (1 - x)**(3 - alpha)) - 3 * gamma(5) / gamma(5 - alpha) * (x**(4 - alpha) + (1 - x)**(4 - alpha)) + 3 * gamma(6) / gamma(6 - alpha) * (x**(5 - alpha) + (1 - x)**(5 - alpha)) - gamma(7) / gamma(7 - alpha) * (x**(6 - alpha) + (1 - x)**(6 - alpha))) # lhs /= 2 * np.cos(alpha * np.pi / 2) # rhs = gamma(alpha + 2) * x return lhs - rhs[:tf.size(lhs)]