From: Walter Roberson on
Erwin Kuipers wrote:
> If 'I' is a representation of
> the imaginary unit sqrt(-1) why does the toolbox not use the commonly
> used symbol 'i'?

I don't know, but I think it was a naming convention issue. The symbolic
toolbox naming convention starts all constants with capital letters.

> The symbol 'I' starts to appear in the expression for alfax2, this is
> where I substitute the (real) expression r1 = sqrt((x-d)^2+(y-h)^2)) for
> the variable r1. As I defined x,d,y and h to be real, r1 will always be
> real. In fact, I only need the positive root.

I do not see a reason at the moment for that to occur, and I do not have
the symbolic toolbox to experiment with.

If I were to encounter this sort of situation in Maple, then I would try
transforming the expression using Maple's expand() (possibly map()'d
over the expression), and after that if necessary I would try using
Maple's evalc() . If that didn't work I would probably hack around the
problem by isolating the subexpression and forcing the "I" out, possibly
by using Maple's evalindets().

I do not know the MuPad equivalents to the above Maple operators: that's
an area where MuPad starts to use different routine names and strategies
than Maple does.
From: us on
"Erwin Kuipers"
> The symbol 'I' starts to appear in the expression for alfax2, this is where I substitute the (real) expression r1 = sqrt((x-d)^2+(y-h)^2)) for the variable r1. As I defined x,d,y and h to be real, r1 will always be real. In fact, I only need the positive root.
>
> Taking the real value of alfaxf does not remove the 'I' present in the expressions, so it seems that the toolbox has indeed trouble in evaluating the (rather large) expressions.
>
> I have changed the code (putting the expressions for r1 and r1 directly at the top of the code) but that did not help. The 'I' then appeared in the expression for Iinx, so this is not much of use.
>
> For a simpler case, that of an acoustic monopole source without reflective boundary, everything runs fine.
>
> The key question is if there is some way to circumvent this issue.
>
> Erwin

here: ML r2010a/sym tbx 5.4 (mupad) the ...I..., which i've seen before as well in an older ML ver (maple based sym tbx), does NOT show up when running your code...
eg,

alfax2 =
((((A*(1/exp(k*((d - x)^2 + (h - y)^2)^(1/2)*i))*(d - x)*(1 + k*((d - x)^2 + (h - y)^2)^(1/2)*i)*i)/(c0*k*rho0*((d - x)^2 + (h - y)^2)^(3/2)) + (A*(1/exp(k*r2*i))*(d - x)*(1 + k*r2*i)*i)/(c0*k*r2^3*rho0))*((exp(k*r2*i)*conj(A))/r2 + (exp(k*((d - x)^2 + (h - y)^2)^(1/2)*i)*conj(A))/((d - x)^2 + (h - y)^2)^(1/2)))/4 + (((A*(1/exp(k*r2*i)))/r2 + (A*(1/exp(k*((d - x)^2 + (h - y)^2)^(1/2)*i)))/((d - x)^2 + (h - y)^2)^(1/2))*((exp(k*r2*i)*conj(A)*(d - x)*(- 1 + k*r2*i)*i)/(c0*k*r2^3*rho0) + (exp(k*((d - x)^2 + (h - y)^2)^(1/2)*i)*conj(A)*(d - x)*(- 1 + k*((d - x)^2 + (h - y)^2)^(1/2)*i)*i)/(c0*k*rho0*((d - x)^2 + (h - y)^2)^(3/2))))/4)/((((A*(1/exp(k*((d - x)^2 + (h - y)^2)^(1/2)*i))*(d - x)*(1 + k*((d - x)^2 + (h - y)^2)^(1/2)*i)*i)/(c0*k*rho0*((d - x)^2 + (h - y)^2)^(3/2)) + (A*(1/exp(k*r2*i))*(d - x)*(1 + k*r2*i)*i)/(c0*k*r2^3*rho0))*((exp(k*r2*i)*conj(A))/r2 + (exp(k*((d - x)^2 + (h -
y)^2)^(1/2)*i)*conj(A))/((d - x)^2 + (h - y)^2)^(1/2)))/8 + (((A*(1/exp(k*r2*i)))/r2 + (A*(1/exp(k*((d - x)^2 + (h - y)^2)^(1/2)*i)))/((d - x)^2 + (h - y)^2)^(1/2))*((exp(k*r2*i)*conj(A)*(d - x)*(- 1 + k*r2*i)*i)/(c0*k*r2^3*rho0) + (exp(k*((d - x)^2 + (h - y)^2)^(1/2)*i)*conj(A)*(d - x)*(- 1 + k*((d - x)^2 + (h - y)^2)^(1/2)*i)*i)/(c0*k*rho0*((d - x)^2 + (h - y)^2)^(3/2))))/8 + (c0*((rho0*((A*(1/exp(k*((d - x)^2 + (h - y)^2)^(1/2)*i))*(d - x)*(1 + k*((d - x)^2 + (h - y)^2)^(1/2)*i)*i)/(c0*k*rho0*((d - x)^2 + (h - y)^2)^(3/2)) + (A*(1/exp(k*r2*i))*(d - x)*(1 + k*r2*i)*i)/(c0*k*r2^3*rho0))*((exp(k*r2*i)*conj(A)*(d - x)*(- 1 + k*r2*i)*i)/(c0*k*r2^3*rho0) + (exp(k*((d - x)^2 + (h - y)^2)^(1/2)*i)*conj(A)*(d - x)*(- 1 + k*((d - x)^2 + (h - y)^2)^(1/2)*i)*i)/(c0*k*rho0*((d - x)^2 + (h - y)^2)^(3/2))))/4 + (((exp(k*r2*i)*conj(A))/r2 + (exp(k*((d - x)^2 + (h - y)^2)^(1/2)*i)*conj(A))/((d - x)^2
+ (h - y)^2)^(1/2))*((A*(1/exp(k*r2*i)))/r2 + (A*(1/exp(k*((d - x)^2 + (h - y)^2)^(1/2)*i)))/((d - x)^2 + (h - y)^2)^(1/2)))/(4*c0^2*rho0)))/2)

Iinx =
(((exp(k*r1*i)*conj(A))/r1 + (exp(k*r2*i)*conj(A))/r2)*((A*(1/exp(k*r1*i))*(d - x)*(1 + k*r1*i)*i)/(c0*k*r1^3*rho0) + (A*(1/exp(k*r2*i))*(d - x)*(1 + k*r2*i)*i)/(c0*k*r2^3*rho0)))/8 + (((exp(k*r1*i)*conj(A)*(d - x)*(- 1 + k*r1*i)*i)/(c0*k*r1^3*rho0) + (exp(k*r2*i)*conj(A)*(d - x)*(- 1 + k*r2*i)*i)/(c0*k*r2^3*rho0))*((A*(1/exp(k*r1*i)))/r1 + (A*(1/exp(k*r2*i)))/r2))/8 + (c0*((rho0*((exp(k*r1*i)*conj(A)*(d - x)*(- 1 + k*r1*i)*i)/(c0*k*r1^3*rho0) + (exp(k*r2*i)*conj(A)*(d - x)*(- 1 + k*r2*i)*i)/(c0*k*r2^3*rho0))*((A*(1/exp(k*r1*i))*(d - x)*(1 + k*r1*i)*i)/(c0*k*r1^3*rho0) + (A*(1/exp(k*r2*i))*(d - x)*(1 + k*r2*i)*i)/(c0*k*r2^3*rho0)))/4 + (((exp(k*r1*i)*conj(A))/r1 + (exp(k*r2*i)*conj(A))/r2)*((A*(1/exp(k*r1*i)))/r1 + (A*(1/exp(k*r2*i)))/r2))/(4*c0^2*rho0)))/2

which versions do you use(?)...

us
From: Erwin Kuipers on
"us " <us(a)neurol.unizh.ch> wrote in message <i2ci24$rdu$1(a)fred.mathworks.com>...
> "Erwin Kuipers"
> > The symbol 'I' starts to appear in the expression for alfax2, this is where I substitute the (real) expression r1 = sqrt((x-d)^2+(y-h)^2)) for the variable r1. As I defined x,d,y and h to be real, r1 will always be real. In fact, I only need the positive root.
> >
> > Taking the real value of alfaxf does not remove the 'I' present in the expressions, so it seems that the toolbox has indeed trouble in evaluating the (rather large) expressions.
> >
> > I have changed the code (putting the expressions for r1 and r1 directly at the top of the code) but that did not help. The 'I' then appeared in the expression for Iinx, so this is not much of use.
> >
> > For a simpler case, that of an acoustic monopole source without reflective boundary, everything runs fine.
> >
> > The key question is if there is some way to circumvent this issue.
> >
> > Erwin
>
> here: ML r2010a/sym tbx 5.4 (mupad) the ...I..., which i've seen before as well in an older ML ver (maple based sym tbx), does NOT show up when running your code...
> eg,
>
> alfax2 =
> ((((A*(1/exp(k*((d - x)^2 + (h - y)^2)^(1/2)*i))*(d - x)*(1 + k*((d - x)^2 + (h - y)^2)^(1/2)*i)*i)/(c0*k*rho0*((d - x)^2 + (h - y)^2)^(3/2)) + (A*(1/exp(k*r2*i))*(d - x)*(1 + k*r2*i)*i)/(c0*k*r2^3*rho0))*((exp(k*r2*i)*conj(A))/r2 + (exp(k*((d - x)^2 + (h - y)^2)^(1/2)*i)*conj(A))/((d - x)^2 + (h - y)^2)^(1/2)))/4 + (((A*(1/exp(k*r2*i)))/r2 + (A*(1/exp(k*((d - x)^2 + (h - y)^2)^(1/2)*i)))/((d - x)^2 + (h - y)^2)^(1/2))*((exp(k*r2*i)*conj(A)*(d - x)*(- 1 + k*r2*i)*i)/(c0*k*r2^3*rho0) + (exp(k*((d - x)^2 + (h - y)^2)^(1/2)*i)*conj(A)*(d - x)*(- 1 + k*((d - x)^2 + (h - y)^2)^(1/2)*i)*i)/(c0*k*rho0*((d - x)^2 + (h - y)^2)^(3/2))))/4)/((((A*(1/exp(k*((d - x)^2 + (h - y)^2)^(1/2)*i))*(d - x)*(1 + k*((d - x)^2 + (h - y)^2)^(1/2)*i)*i)/(c0*k*rho0*((d - x)^2 + (h - y)^2)^(3/2)) + (A*(1/exp(k*r2*i))*(d - x)*(1 + k*r2*i)*i)/(c0*k*r2^3*rho0))*((exp(k*r2*i)*conj(A))/r2 + (exp(k*((d - x)^2 + (h -
> y)^2)^(1/2)*i)*conj(A))/((d - x)^2 + (h - y)^2)^(1/2)))/8 + (((A*(1/exp(k*r2*i)))/r2 + (A*(1/exp(k*((d - x)^2 + (h - y)^2)^(1/2)*i)))/((d - x)^2 + (h - y)^2)^(1/2))*((exp(k*r2*i)*conj(A)*(d - x)*(- 1 + k*r2*i)*i)/(c0*k*r2^3*rho0) + (exp(k*((d - x)^2 + (h - y)^2)^(1/2)*i)*conj(A)*(d - x)*(- 1 + k*((d - x)^2 + (h - y)^2)^(1/2)*i)*i)/(c0*k*rho0*((d - x)^2 + (h - y)^2)^(3/2))))/8 + (c0*((rho0*((A*(1/exp(k*((d - x)^2 + (h - y)^2)^(1/2)*i))*(d - x)*(1 + k*((d - x)^2 + (h - y)^2)^(1/2)*i)*i)/(c0*k*rho0*((d - x)^2 + (h - y)^2)^(3/2)) + (A*(1/exp(k*r2*i))*(d - x)*(1 + k*r2*i)*i)/(c0*k*r2^3*rho0))*((exp(k*r2*i)*conj(A)*(d - x)*(- 1 + k*r2*i)*i)/(c0*k*r2^3*rho0) + (exp(k*((d - x)^2 + (h - y)^2)^(1/2)*i)*conj(A)*(d - x)*(- 1 + k*((d - x)^2 + (h - y)^2)^(1/2)*i)*i)/(c0*k*rho0*((d - x)^2 + (h - y)^2)^(3/2))))/4 + (((exp(k*r2*i)*conj(A))/r2 + (exp(k*((d - x)^2 + (h - y)^2)^(1/2)*i)*conj(A))/((d -
x)^2
> + (h - y)^2)^(1/2))*((A*(1/exp(k*r2*i)))/r2 + (A*(1/exp(k*((d - x)^2 + (h - y)^2)^(1/2)*i)))/((d - x)^2 + (h - y)^2)^(1/2)))/(4*c0^2*rho0)))/2)
>
> Iinx =
> (((exp(k*r1*i)*conj(A))/r1 + (exp(k*r2*i)*conj(A))/r2)*((A*(1/exp(k*r1*i))*(d - x)*(1 + k*r1*i)*i)/(c0*k*r1^3*rho0) + (A*(1/exp(k*r2*i))*(d - x)*(1 + k*r2*i)*i)/(c0*k*r2^3*rho0)))/8 + (((exp(k*r1*i)*conj(A)*(d - x)*(- 1 + k*r1*i)*i)/(c0*k*r1^3*rho0) + (exp(k*r2*i)*conj(A)*(d - x)*(- 1 + k*r2*i)*i)/(c0*k*r2^3*rho0))*((A*(1/exp(k*r1*i)))/r1 + (A*(1/exp(k*r2*i)))/r2))/8 + (c0*((rho0*((exp(k*r1*i)*conj(A)*(d - x)*(- 1 + k*r1*i)*i)/(c0*k*r1^3*rho0) + (exp(k*r2*i)*conj(A)*(d - x)*(- 1 + k*r2*i)*i)/(c0*k*r2^3*rho0))*((A*(1/exp(k*r1*i))*(d - x)*(1 + k*r1*i)*i)/(c0*k*r1^3*rho0) + (A*(1/exp(k*r2*i))*(d - x)*(1 + k*r2*i)*i)/(c0*k*r2^3*rho0)))/4 + (((exp(k*r1*i)*conj(A))/r1 + (exp(k*r2*i)*conj(A))/r2)*((A*(1/exp(k*r1*i)))/r1 + (A*(1/exp(k*r2*i)))/r2))/(4*c0^2*rho0)))/2
>
> which versions do you use(?)...
>
> us

I am using ML R2009B with symbolic toolbox 5.3.

US, thanks for evaluating the expressions with the newer versions. This means I possibly only need to update my installation in order to become usable results.

Erwin
From: us on
"Erwin Kuipers"
> I am using ML R2009B with symbolic toolbox 5.3.
>
> US, thanks for evaluating the expressions with the newer versions. This means I possibly only need to update my installation in order to become usable results.
>
> Erwin

let's HOPE...

:-)
us