Unity creating curved path

Hey I started coding in C# with Unity and I want to make a GameObject to follow a curved path defined by the function y=sqrt(x)-3  I looked online and I didn't see any tutorial or guide showing how to do this.

 

if (position_z <= 4 && position_z >= -4) {

float z = Mathf.Sqrt(position_x)-3;

transform.position = new Vector3 (position_x, 0, z);

}

 

The x and y position works but the z value is NaN.

Any idea how to fix this?

The problem might be that position_x can have a negative value. Make sure position_x is always positive or try to use

float z = Mathf.Sqrt(Mathf.Abs(position_x))-3;

and see what happens.