Minecraft wiki entry for Anvil_mechanics, associated text: For each enchantment on the sacrifice:
Ignore any enchantment that cannot be applied to the target (e.g. Protection on a sword).
Add one level for every incompatible enchantment on the target (In Java Edition).
If the enchantment is compatible with the existing enchantments on the target:
For Java Edition, add the final level of the enchantment on the resulting item multiplied by the multiplier from the table below.
For Bedrock Edition, add the difference between the final level and the initial level on the target item multiplied by the multiplier from the table below.