Ibrahim Assignment 2
Ibrahim Assignment 2
Assignment 02
Date 14 April,2025
Question:Use 5 data sets with atleast each having 8 values perform its 1st and 2nd derivatives
and plot its graph using python the data must be according to field of Metallurgy and
Materials Engineering.
Ans
import numpy as np
stress = np.array([0, 50, 100, 150, 200, 250, 275, 285, 290, 292])
resistivity = np.array([1.5, 2.1, 2.9, 3.8, 4.9, 6.1, 7.5, 9.0, 10.6, 12.3]) # µΩ·cm
hardness = np.array([100, 120, 140, 160, 180, 185, 180, 160, 130, 100])
# Plotting
datasets = [
(grain_size, yield_strength, ys_d1, ys_d2, 'Grain Size (µm)', 'Yield Strength (MPa)', 'Grain Size
vs Strength'),
(time, hardness, hard_d1, hard_d2, 'Time (h)', 'Hardness (HV)', 'Time vs Hardness'),
(cool_rate, gr_size, gs_d1, gs_d2, 'Cooling Rate (°C/s)', 'Grain Size (µm)', 'Cooling Rate vs Grain
Size')
plt.figure(figsize=(18, 15))
plt.title(f'{title} - Original')
plt.xlabel(xlabel)
plt.ylabel(ylabel)
plt.grid(True)
plt.subplot(5, 3, i * 3 + 2)
plt.xlabel(xlabel)
plt.ylabel('First Derivative')
plt.grid(True)
plt.subplot(5, 3, i * 3 + 3)
plt.xlabel(xlabel)
plt.ylabel('Second Derivative')
plt.grid(True)
plt.tight_layout()
plt.show()