Value of variable 5#8829

Value of variable 5 (Editorial)

Algorithm Analysis

To solve the problem, it is necessary to calculate the value of the given expression.

Algorithm Implementation

Read the value of the variable x.

scanf("%lf", &x);

Calculate the value of the variable y.

y = (2 * x) / sqrt(x * x + 1) - sqrt(x * x + 1) / (x * x * x);

Print the result to the 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) / Math.sqrt(x * x + 1) - Math.sqrt(x * x + 1) / (x * x * x);
        System.out.print(y);
        con.close();
    }
}

Python Implementation

import math

x = float(input())
y = (2 * x) / math.sqrt(x * x + 1) - math.sqrt(x * x + 1) / (x * x * x)
print(y)