I have this formula to solve.
enter image description here
And here is my code that outputs an error in the formula.
Private Sub CommandButton6_Click()
Dim Z As String
Dim X As Double, Y As Double
Z = InputBox("Input number X!", "Inputing number X"): X = Val(Z)
Y = Sqr(2 * ((X - 2) ^ 2) * ((8 - X) - 1)^1/3
MsgBox ("Y =" + Str(Y))
End Sub
>Solution :
Taking into account when we get negative result under the root
Y = (2 * ((X - 2) ^ 2) * (8 - X) - 1)
If Y >= 0 Then
Y = Y ^ (1 / 3)
Else
Y = -(Abs(Y) ^ (1 / 3))
End If