Skip to content

Commit

Permalink
Update deriv.v
Browse files Browse the repository at this point in the history
  • Loading branch information
suleyman-kaya authored Jul 27, 2024
1 parent d2cb39f commit caa28df
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions deriv/deriv.v
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module deriv

import vsl.func
import vsl.errors
import vsl.internal.prec
import math

Expand Down Expand Up @@ -114,20 +115,21 @@ pub fn backward(f func.Fn, x f64, h f64) (f64, f64) {
return forward(f, x, -h)
}

/**
* partial is a function that computes the partial derivative of a multivariable function with respect to a specified variable.
*
* @param f The multivariable function for which the partial derivative is to be computed.
* @param x The point at which the partial derivative is to be computed, represented as an array of coordinates.
* @param variable The index of the variable with respect to which the partial derivative is to be computed.
* @param h The step size to be used in the central difference method.
*
* @return A tuple containing the value of the partial derivative and the estimated error.
*/
pub fn partial(f fn ([]f64) f64, x []f64, variable int, h f64) (f64, f64) {
/**
* partial is a function that computes the partial derivative of a multivariable function with respect to a specified variable.
*
* @param f The multivariable function for which the partial derivative is to be computed.
* @param x The point at which the partial derivative is to be computed, represented as an array of coordinates.
* @param variable The index of the variable with respect to which the partial derivative is to be computed.
* @param h The step size to be used in the central difference method.
*
* @return A tuple containing the value of the partial derivative and the estimated error.
*/


if variable < 0 || variable >= x.len {
panic('Invalid variable index')
errors.vsl_panic('Invalid variable index', .efailed)
}

// Define a helper function that converts the multivariate function
Expand Down

0 comments on commit caa28df

Please sign in to comment.