1. Implement a function f1(x) that computes the derivative of sin(x) using dual numbers. Verify that the result obtained using dual numbers is consistent with the analytical derivative of sin(x);
2. Implement a function f2(x, y) that computes the partial derivatives of x^2 + y^2 with respect to x and y using dual numbers. Verify that the results obtained using dual numbers are consistent with the analytical partial derivatives of the function;
3. Implement a function f3(x) that computes the derivative of a polynomial function a[1]*x^n + a[2]*x^(n-1) + … + a[n-1]*x + a[n] using Dual numbers. Verify that the results obtained using Dual numbers are consistent with the analytical derivative of the polynomial function;
4. Implement a function f4(x) that computes the derivative of the logistic function 1 / (1 + exp(-x)) using Dual numbers. Verify that the results obtained using Dual numbers are consistent with the analytical derivative of the logistic function.
For each of these tasks, you should use dual numbers to perform forward differentiation of the given function and compare the results with the analytical derivative of the function to verify that their implementation is correct.
You should also experiment with different input values to see how the derivative changes as the input values change, and plot the results to visualise the behaviour of the function and its derivative.