1
$\begingroup$

A problem is presented when the substitution of the numerical values for this function

Uz = (-(1/4) - I/4) (2 Sqrt[\[Pi]])/k  1/Sqrt[k R]      E^(-((2 I a n \[Pi])/\[CapitalLambda])   - (n^2 \[Pi]^2)/( b^2 \[CapitalLambda]^2) - (I (k^2 R^2 + (n \[Pi] + k z)^2))/(2  k R)) (Erfi[((1/2 + I/2) (n \[Pi] + k (-R + z)))/Sqrt[k R]] - Erfi[((1/2 + I/2) (n \[Pi] + k (R + z)))/Sqrt[k R]] + 
    Erfi[((1/2 + I/2) (k R - Sqrt[D^2 k^2 + (n \[Pi] + k z)^2]))/Sqrt[k R]] + Erfi[((1/2 + I/2) (k R + Sqrt[D^2 k^2 + (n \[Pi] + k z)^2]))/Sqrt[k R]])

I used

valplot = { k R -> 1, z -> 1,  b -> 1, z -> 0, \[CapitalLambda] -> 1 }

Ux1 = Uz /. valplot 

Please, observe that I have a variable kR and sqrt of kR. It is possible to evaluate with a unique value? It is possible to do the parameter independently. Another detail is when a product of parameters is presented. How can it is possible to fix it, this point is important for future plot analysis.

$\endgroup$
1
$\begingroup$

It would certainly be easier to specify the values of the variables independently. They appear together in the expression in several different ways.

Uz // FullForm reveals the underlying expression. Looking for the products of k and R, we find

Times[Complex[0, Rational[-1, 2]], Power[k, -1], Power[R, -1], 
 Plus[Times[Power[k, 2], Power[R, 2]]

and

Power[Times[k, R], Rational[-1, 2]]

The underlying expression of your replacement rule k R -> 1 is FullForm[k R -> 1] which gives Rule[Times[k,R],1]. This works on Power[Times[k, R], Rational[-1, 2]] because there the product between k and R is the same as on the LHS of the rule, but it doesn't work for the other ones, such as Times[Power[k, 2], Power[R, 2]], because the LHS of the rule does not match this expression.

One solution is the following:

valplot = {k R -> 1, k^-1 R^-1 -> 1, k^2 R^2 -> 1, z -> 1, b -> 1, 
   z -> 0, \[CapitalLambda] -> 1};
Ux1 = Uz //. valplot

//. must be used instead of /. because /. will only do one replacement per expression, and your expression has two products of k and R in the same which need to be replaced. //. will do that by applying the rules repeatedly until nothing changes.

You can also write the rules as

valplot = {k R -> 1, Power[k, x_] Power[R, x_] -> 1, z -> 1, b -> 1, 
   z -> 0, \[CapitalLambda] -> 1};

This will replace the both k^-1 R^-1 and k^2 R^2 using a single rule.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.