this example shows how to use the exteriorpenalty
function to calculate the exterior penalty for a given point, with respect to a bounded region.
calculate the penalty value for the point 0.1
within the interval [-2
,2
], using the step
method.
calculate the penalty value for the point 4
outside the interval [-2
,2
], using the step
method.
calculate the penalty value for the point 4
outside the interval [-2
,2
], using the quadratic
method.
calculate the penalty value for the point [-2
,0
,4
] with respect to the box defined by the intervals [0
,1
], [-1
,1
], and [-2
,2
] along the x, y, and z dimensions, respectively, using the quadratic
method.
visualize penalty values for an interval
create a vector of 1001 equidistant points distributed between -5
and 5
.
calculate penalties for all the points in the vector, using the quadratic
method.
plot the points and add grid, labels, and title.