How to adjust the Regression with ANN for last part of function The Blue dots represent the required function and the Black ones represent the predicted function

I am using keras with the following code:-

# Set callback functions to early stop training and save the best model so far
from keras.callbacks import EarlyStopping, ModelCheckpoint
callbacks = [EarlyStopping(monitor='val_loss',verbose=1, patience=5,min_delta=0.002,mode='auto',restore_best_weights=False),
             ModelCheckpoint(filepath='best_model.hdf5', monitor='val_loss', save_best_only=True)]

##The Architecture
np.random.seed(0)
model = Sequential()
model.add(Dense(500,kernel_initializer='normal',activation='tanh',input_dim=1))

model.add(Dense(300, kernel_initializer='normal',activation='relu'))

model.add(Dense(500, kernel_initializer='normal',activation='relu'))

model.add(Dense(1, kernel_initializer='normal',activation='linear'))

model.compile(optimizer='adam',loss='mean_absolute_error',  metrics=['mae','accuracy'])

his = model.fit(X_train,y_train,epochs=150,batch_size=10,validation_data=
(X_val,y_val), verbose=1,callbacks=callbacks)


I tried various architecture but still not getting the result please guide
I see you use are sequential model. Could be a task for an LSTM architecture.
https://machinelearningmastery.com/time-series-prediction-lstm-recurrent-neural-networks-python-keras/

Maybe you are overengineering the thing. Judging from the dataplot, a simple OLS regression splines model may also fit well. 
https://www.analyticsvidhya.com/blog/2018/03/introduction-regression-splines-python-codes/