This is a theoretical question. Some elements described in the problem may be impossible/impractical, but I am just trying to understand the principles.
Suppose I have a powerful electromagnet with a C shaped core. In the gap of the C core is a permanent magnet, contained in a box where it may flip freely. When the electromagnet is turned on, it produces a field that is greater than the permanent magnet's coercive force, i.e. a magnetic field that could demagnetize the permanent magnet. In this case however, the magnet can flip in response to the electromagnet's field.
My first question is - if the permanent magnet can flip so that it is aligned to the field produced by the electromagnet, will it be demagnetized by the electromagnet's field, or will the act of flipping mean that it is not demagnetized even though the electromagnet's field is strong enough to demagnetize it?
My second question is - what if the electromagnet is powered by an alternating current, so that the field produced by the electromagnet changes direction each time the current in the electromagnet's coil changes direction? The permanent magnet takes some time to flip in response to the field produced by the electromagnet. If this flip time is longer than the change in direction of the electromagnet's field produced by alternating current, the permanent magnet will still be in mid-flip when the electromagnet's field direction is reversed. If the direction of the permanent magnet's field is opposed to the direction of the electromagnet's field at that point in time, will it be demagnetized? Will a progressive increase in the electromagnet's frequency at some point potentially demagnetize the permanent magnet?