H
Han
What I am trying to do: increment for loop or do while loop by 0.001
----------------------
My for loop (I don't know how to increment by 0.001, this code just
increments by 1):
----------------------
For X = 0 To 10 'For X between 0 and 10 incremented by 0.001
For Y = 0 To 10 'For X between 0 and 10 incremented by 0.001
Fnew = X * Y * Exp(1 - 2 * X) * Sin(Y - X) * (1 - Y ^ 2) 'Given
function
If Fold <= Fnew Then 'If previous value of function is less
than current value of f then...
xmax = X 'Store value of X for max value of F
ymax = Y 'Store value of y for max value of F
Fold = Fnew 'Update the function
End If 'End if statement
Next 'End inner for loop (Y loop)
Next 'End outer for loop (X loop)
----------------------
My do while loop (I tried incrementing by 0.001, but the answer is not
what I want):
----------------------
Do While X <= 10
Do While Y <= 10
Fnew = X * Y * Exp(1 - 2 * X) * Sin(Y - X) * (1 - Y ^ 2) 'Given
function with new X and Y value
If Fold <= Fnew Then 'If previous value of function is less
than current value of f then...
xmax = X 'Store value of X for max value of F
ymax = Y 'Store value of y for max value of F
Fold = Fnew 'Update the function
End If 'End if statement
Y = Y + 0.001
If Y > 10 Then Exit Do
Loop
X = X + 0.001
If X > 10 Then Exit Do
Loop
----------------------
My for loop (I don't know how to increment by 0.001, this code just
increments by 1):
----------------------
For X = 0 To 10 'For X between 0 and 10 incremented by 0.001
For Y = 0 To 10 'For X between 0 and 10 incremented by 0.001
Fnew = X * Y * Exp(1 - 2 * X) * Sin(Y - X) * (1 - Y ^ 2) 'Given
function
If Fold <= Fnew Then 'If previous value of function is less
than current value of f then...
xmax = X 'Store value of X for max value of F
ymax = Y 'Store value of y for max value of F
Fold = Fnew 'Update the function
End If 'End if statement
Next 'End inner for loop (Y loop)
Next 'End outer for loop (X loop)
----------------------
My do while loop (I tried incrementing by 0.001, but the answer is not
what I want):
----------------------
Do While X <= 10
Do While Y <= 10
Fnew = X * Y * Exp(1 - 2 * X) * Sin(Y - X) * (1 - Y ^ 2) 'Given
function with new X and Y value
If Fold <= Fnew Then 'If previous value of function is less
than current value of f then...
xmax = X 'Store value of X for max value of F
ymax = Y 'Store value of y for max value of F
Fold = Fnew 'Update the function
End If 'End if statement
Y = Y + 0.001
If Y > 10 Then Exit Do
Loop
X = X + 0.001
If X > 10 Then Exit Do
Loop