**Math Expression**

Learn how to use a math expression with different variables and tracing targets for optimization.

### Transcription:

In this video tutorial, I will show you how to use math expressions for the optimization.

To use a math expression for the optimization, we need first to add the math expression.

And for that, we go here to our system setup, into the optimization preview, And down here on the ray trace, we click with the right mouse button, go to add aberration goals, for example, and down here we see this math expression.

When we click on it, the math expression has been added here to our trace goals tree view.

In the math expression field, we can enter the math expression.

And if we want to use parameters in our math expression as for example, the variables we have defined or here our tracing goals, we need to specify the IDs for all these parameters.

And for that, we give each parameter and specific ID. For example, here, radius one.

For this here’s radius two.

Position one, for example, and this parameter has the name position two.

And in the math expression, we are now able to perform a computation with these parameters.

An example would be the distance between the two positions, position two and position one. So for example, position two minus position one would be here an easy expression for the distance between these two parameters. And here we see also the value.

The same we could do here with this radii.

So for example, radius two minus radius one, And also here we can see the distance between those two radii. Of course, also other math operands can be used. For example, the sine of radius one times the cosine of radius two.

Let’s duplicate this ray trace here. We for that, we just go here with the right mouse button and click on duplicate.

Now we can see that here the ray trace has been duplicated.

And when we open this, we see here the same parameters as here in the first ray trace. And what I would like to show you is that if we have this additional ray trace, it is also possible to operate here in the second ray trace with these variables, which we have defined here.

So these variables could be used for the math expression for each individual ray trace.

But if we have inside this ray trace here different tracing goals as these two positions. For example, here is position one and position two. And if we type here inside the math expression position one, it always refers to this position or to this parameter, which is here defined in the same, ray ray trace. So this position one is not that position here in this first ray trace, but it refers to the position one in the second ray trace. So it refers always to the ID in the same ray trace.

Thank you for watching.