Implement a function that calculates the y-value of a power law function based on two known points and a given x-value. The function should adhere to the following specifications:
Functionality
Create a function named calculate_power_law_y that takes three parameters:
p1: A tuple containing two values (x1, y1) representing the first known point.
p2: A tuple containing two values (x2, y2) representing the second known point.
x3: A float representing the x-value for which the y-value needs to be calculated.
The function should calculate the y-value (y3) using the formula:
[
y3 = y1 \times \left(\frac{y2}{y1}\right)^{\log\left(\frac{x3}{x1}\right) / \log\left(\frac{x2}{x1}\right)}
]
where log is the logarithm function.
Ensure that x1 and y1 are incremented by a small value (1e-09) to avoid division by zero.
Return the calculated y3 value rounded to the nearest integer.
Input/Output Requirements
Input:
p1: Tuple of two floats, e.g., (x1, y1)
p2: Tuple of two floats, e.g., (x2, y2)
x3: Float (the x-coordinate for calculation)
Output:
Returns an integer, which is the rounded value of y3 calculated from the input parameters.
Implementation
Write the implementation in a file called /app/solution.py with the specified function.