COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### Undefined function or method 'atan2' for input arguments of type 'sym'

• Follow

```I like to run the following lines of code

syms theta alpha x y
alpha = atan2(y,x)
subs(theta, {x y}, {pi/4 pi/4})
theta = diff(alpha, x);

But I am getting an error on the second line:
??? Undefined function or method 'atan2' for input arguments of type 'sym'.
Any Ideas how to solve this problem?

Thanks
Markus

PS.: Substituing atan2 with 2*atan( (sqrt(x^2+y^2)-x)/y) will give me trubles on y == 0 so I dont want to do that.
```
 0

```On 5 Jan., 10:41, "Markus " <ba...@acin.tuwien.ac.at> wrote:
> I like to run the following lines of code
>
> syms theta alpha x y
> alpha = atan2(y,x)
> subs(theta, {x y}, {pi/4 pi/4})
> theta = diff(alpha, x);
>
> But I am getting an error on the second line:
> ??? Undefined function or method 'atan2' for input arguments of type 'sym'.
> Any Ideas how to solve this problem?
>
> Thanks
> Markus
>
> PS.: Substituing atan2 with 2*atan( (sqrt(x^2+y^2)-x)/y) will give me trubles on y == 0 so I dont want to do that.

Best wishes
Torsten.
```
 0
Reply Torsten.Hennig1 (1088) 1/5/2012 9:52:39 AM

```On 1/5/2012 3:41 AM, Markus wrote:
> I like to run the following lines of code
>
> syms theta alpha x y
> alpha = atan2(y,x)

> But I am getting an error on the second line:
> ??? Undefined function or method 'atan2' for input arguments of type 'sym'.
> Any Ideas how to solve this problem?
>

But x and y are just symbols at the point atan2 is called.

In other words, they have no numerical values. x and y are just _symbols_

So, I am just curious what do you expect atan2 (if it works for symbols)
to do with them in order to return the correct arctan?

--Nasser
```
 0

```"Nasser M. Abbasi" <nma@12000.org> wrote in message <je3t6r\$mct\$1@speranza.aioe.org>...
> On 1/5/2012 3:41 AM, Markus wrote:
> > I like to run the following lines of code
> >
> > syms theta alpha x y
> > alpha = atan2(y,x)
>
> > But I am getting an error on the second line:
> > ??? Undefined function or method 'atan2' for input arguments of type 'sym'.
> > Any Ideas how to solve this problem?
> >
>
> But x and y are just symbols at the point atan2 is called.
>
> In other words, they have no numerical values. x and y are just _symbols_
>
> So, I am just curious what do you expect atan2 (if it works for symbols)
> to do with them in order to return the correct arctan?
>
> --Nasser

Hi

I just want to evaluate a function later or to build the derivative like I did with:

syms theta alpha x y
alpha = atan(y/x)
subs(alpha, {x y}, {pi/4 pi/4})
theta = diff(alpha,x)
```
 0

```FWIW,

atan2(y,x) is

imag(log(x+1i*y))
imag(z) = 0.5*(exp(1i*z)-exp(-1i*z))

Bruno
```
 0
Reply b.luong5955 (6341) 1/5/2012 11:00:09 AM

```On 1/5/2012 4:55 AM, Markus wrote:
> "Nasser M. Abbasi"<nma@12000.org>  wrote in message<je3t6r\$mct\$1@speranza.aioe.org>...
>> On 1/5/2012 3:41 AM, Markus wrote:
>>> I like to run the following lines of code
>>>
>>> syms theta alpha x y
>>> alpha = atan2(y,x)
>>
>>> But I am getting an error on the second line:
>>> ??? Undefined function or method 'atan2' for input arguments of type 'sym'.
>>> Any Ideas how to solve this problem?
>>>
>>
>> But x and y are just symbols at the point atan2 is called.
>>
>> In other words, they have no numerical values. x and y are just _symbols_
>>
>> So, I am just curious what do you expect atan2 (if it works for symbols)
>> to do with them in order to return the correct arctan?
>>
>> --Nasser
>

> Hi
>
> I just want to evaluate a function later or to build the derivative like I did with:
>
> syms theta alpha x y
> alpha = atan(y/x)
> subs(alpha, {x y}, {pi/4 pi/4})
> theta = diff(alpha,x)

But the above, if it works, can't be really right.

Once you plug in values for x,y in your alpha (after the subs),
then you would no longer be able to differentiate the resulting expression
because it would not long have an 'x' or a 'y' symbols in it. So what would
the diff do then? there is no 'x' any where to be seen.

may be you want this:

------------------------------
syms theta alpha x y
alpha = diff(atan(y/x),x)
------------------------------
alpha =
-y/(x^2*(y^2/x^2 + 1))

No do
----------------------------------
subs(alpha, {x y}, {pi/4 pi/4})
------------------------------

ans =
-0.6366

--Nasser
```
 0

```"Markus " <bader@acin.tuwien.ac.at> wrote in message <je3r7k\$if3\$1@newscl01ah.mathworks.com>...
> PS.: Substituing atan2 with 2*atan( (sqrt(x^2+y^2)-x)/y) will give me trubles on y == 0 so I dont want to do that.
- - - - - - - - -
It is mathematically equivalent to use 2*atan(y/(sqrt(x^2+y^2)+x)) instead of 2*atan((sqrt(x^2+y^2)-x)/y), which you can see by rationalizing the numerator of this latter expression.  In this form there will be no trouble with y equal to zero unless x is negative at the same time, and this occurs along the half-line on which atan2(y,x) itself encounters its discontinuous jump across the negative real axis and therefore gives possible trouble.  Across the positive real-axis the expression is well-behaved.

Roger Stafford
```
 0
Reply ellieandrogerxyzzy (4732) 1/6/2012 3:29:08 AM

6 Replies
534 Views

Similiar Articles:

7/22/2012 10:55:50 PM