This example shows how to use exteriorPenalty
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.