Algorithm Analysis
To solve the problem, it is necessary to calculate the value of the given expression.
Algorithm Implementation
Read the value of variable .
scanf("%lf", &x);
Calculate the value of variable .
y = (2 * x - 1) / (x * x) + sqrt(x * x + 1) / 2;
Output the result to thousandths.
printf("%.3lf\n", y);
Java Implementation
import java.util.*; class Main { public static void main(String[] args) { Scanner con = new Scanner(System.in); double x = con.nextDouble(); double y = (2 * x - 1) / (x * x) + Math.sqrt(x * x + 1) / 2; System.out.print(y); con.close(); } }
Python Implementation
import math x = float(input()) y = (2 * x - 1) / (x * x) + math.sqrt(x * x + 1) / 2 print(y)