How do I turn a "broken" plot into a smooth curve

334 Views Asked by At

I developed and solved a differential equation that predicts fluid temperature along the length of a long pipe with time.

Analytical solution is such that it is causing a "discontinuity" in the temperature profile along the depth at fixed time. (This discontinuity travels down the pipe as time progresses. So the picture shown here is just a snapshot frozen at a fixed time at the start of flow.

In actual physical world, this break/discontinuity does not exist.

I want to make it smooth as shown in red in bottom right plot (like red line).

Would you please suggest any method that can fix this problem. **

Suggested method should be reproducible, repeatable and programmable. (I am using VBA)

**

enter image description here

1

There are 1 best solutions below

5
On

A standard technique is indeed to use a piece of a cubic polynomial for connecting broken curve parts. The cubic polynomial is uniquely determined by the function values and derivatives at the end points. This function is well behaved, as proved in lemma 1.1 of the following German text, which I wrote a long time ago.

To turn this technique into a "reproducible, repeatable and programmable" method applicable for scenarios like the one in the plot, one can vary the connecting point on the smooth curve, such that $\max(|m_a-m|,|m_b-m|)$ is minimized. Here $m_a$ is the derivative at end point of the discontinuous curve, $m_b$ is the derivative at the connecting point on the smooth curve, and $m$ is the slope of the straight line connecting the two points.


A drawback of cubic curves is that they are not well suited for nearly vertical slopes. The plots suggest that this might be the case here. In this case, it is better to work with exponential functions.

In the plot, it looks like only one curve is broken, and the other curve is smooth. In this case, we can add $a \exp(bx)$ to the smooth curve, where $a$ and $b$ are uniquely determined by the conditions that the new smooth curve meets the broken curve at the end point, and that the derivative is continuous at that point. This automatically satisfies the requirement to be a "reproducible, repeatable and programmable" method.