Calculate derivative of erfcx(x) function

10 visualizaciones (últimos 30 días)
Kevin Frey
Kevin Frey el 8 de Feb. de 2019
Comentada: Bjorn Gustavsson el 8 de Feb. de 2019
I want to know how i can calculater the derivative of an erfcx(x) function with the symbolic math toolbox. The following is what i tried so far:
>> syms x real
>> y = erfcx(x)
Undefined function 'erfcx' for input arguments of type 'sym'.
I also tried doing this with an anonymous function:
>> testing = @(x) erfcx(x)
testing =
function_handle with value:
@(x)erfcx(x)
but then i don't know how to use the diff() function, as i don't know what variable i should give: diff(testing(x)) <- instead of this x.
  6 comentarios
Kevin Frey
Kevin Frey el 8 de Feb. de 2019
Editada: Kevin Frey el 8 de Feb. de 2019
so the base problem with inserting "erfcx(x) = exp(x^2) * erfc(x)" before calculating the derivative (which i already did via wolfram alpha) is that i get overflow errors and i wanted to circumvent that issue with the erfcx(x) function.
So if that is what you two are suggesting i am afraid that won't work for me.
But i really appreciate all your input.
Bjorn Gustavsson
Bjorn Gustavsson el 8 de Feb. de 2019
Why cant you do that and plug it into the symbolic differentiation? (It took me ~5 minutes to get an analytical derivative...)

Iniciar sesión para comentar.

Respuesta aceptada

Torsten
Torsten el 8 de Feb. de 2019
Editada: Torsten el 8 de Feb. de 2019
Try
x = 0:0.1:5;
analytical_derivative = -2/sqrt(pi) + 2.*x.*erfcx(x);
numerical_derivative = (erfcx(x+1.0e-6)-erfcx(x))*1e6;
plot(x,analytical_derivative,x,numerical_derivative)
So my guess is that the derivative of erfcx is erfcx'(x) = -2/sqrt(pi) + 2*x*erfcx(x) (and you can easily deduce this result by differentiating exp(x^2)*erfcx(x) using the product rule).

Más respuestas (1)

Bjorn Gustavsson
Bjorn Gustavsson el 8 de Feb. de 2019
Just plug in the definitions of the erfcx function into your symbolic calculations? Or do the differentiation by hand?
HTH
  5 comentarios
Kevin Frey
Kevin Frey el 8 de Feb. de 2019
Editada: Kevin Frey el 8 de Feb. de 2019
I am sorry, i have problems understanding what exactly you mean by numerical or analytical. From what i found "analytic" and "symbolic" are supposed to be the same and they are meant to be exact and "numerical" are approximations.
So what i need in the end, is a working function for a exponentially modified gauss calculcation i am currently working on, and if i use the approximation of "erfcx(x) = exp(x^2) * erfc(x)" i get overflow results, if my number gets too big and i wanted to circumvent that.
Bjorn Gustavsson
Bjorn Gustavsson el 8 de Feb. de 2019
If I got the definitions right you should just simply have expressed erfcx in terms of exp(x^2) and erf:
syms x
diff(exp(x^2)*(1-erf(x)),x)
ans =
- 2/pi^(1/2) - 2*x*exp(x^2)*(erf(x) - 1)
HTH

Iniciar sesión para comentar.

Categorías

Más información sobre Symbolic Math Toolbox en Help Center y File Exchange.

Productos


Versión

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by