Skip to main content
correctly defined my function, solving the problem.
Source Link
In[224]:= Clear[x]
Clear[y]
Clear[a]
Clear[k1]
Clear[k2]
Clear[U]

In[299]:= Attributes[a] = {Constant}
Attributes[k1] = {Constant}
Attributes[k2] = {Constant}

In[275]:= values = {x_ -> 0, y_ -> 0}

In[276]:= 
U[x_, y_] := 
 k1/2 (Sqrt[(a - x)^2 + (a/Sqrt[3] - y)^2] - (2*a)/Sqrt[3])^2 + 
  k1/2*(Sqrt[(-a - x)^2 + (-(a/Sqrt[3]) - y)^2] - (2*a)/Sqrt[3])^2 + 
  k2/2*(Sqrt[(-(a/Sqrt[3]) - x)^2 + (a - y)^2] - (2*a)/Sqrt[3])^2 + 
  k2/2*(Sqrt[(a/Sqrt[3] - x)^2 + (-a - y)^2] - (2*a)/Sqrt[3])^2



In[199]:= Simplify[U[0, 0], Reals]

Out[199]= 2 ((k1/2)[(2 (-a + Sqrt[a^2]))/Sqrt[3]]^2 + (k2/2)[(
    2 (-a + Sqrt[a^2]))/Sqrt[3]]^2)

(**The above output is the correct form that I should be seeing**)

D[U[x, y], x] /. values

Out[258]= 0

In[303]:= D[U[x, y], x, y] /. values

Out[303]= 0

(**The above are correct outputs according to the problem statement**)

In[304]:= Simplify[D[U[x, y], x, y] /. values, Reals]

Out[304]= 0

(**The above derivative should give:(Sqrt[3]/2k1-Sqrt[3]/2k2) \
according to the problem statement 
But for some reason the D[] function is also taking derivates of k1 \
and k2 - which are set as constants
**)

Here'sI know this problem has something to do with my notation or the constants k1 and k2. I am new to mathematica, so this may just be a syntax error.

Thanks in advance.

Update: here is the result of my computationchanges, which did giveoutput the correct values for my taylor expansion

I know this problem has something to do with my notation or the constants k1 and k2. I am new to mathematica, so this may just be a syntax error.

Thanks in advance.

In[224]:= Clear[x]
Clear[y]
Clear[a]
Clear[k1]
Clear[k2]
Clear[U]

In[299]:= Attributes[a] = {Constant}
Attributes[k1] = {Constant}
Attributes[k2] = {Constant}

In[275]:= values = {x_ -> 0, y_ -> 0}

In[276]:= 
U[x_, y_] := 
 k1/2 (Sqrt[(a - x)^2 + (a/Sqrt[3] - y)^2] - (2*a)/Sqrt[3])^2 + 
  k1/2*(Sqrt[(-a - x)^2 + (-(a/Sqrt[3]) - y)^2] - (2*a)/Sqrt[3])^2 + 
  k2/2*(Sqrt[(-(a/Sqrt[3]) - x)^2 + (a - y)^2] - (2*a)/Sqrt[3])^2 + 
  k2/2*(Sqrt[(a/Sqrt[3] - x)^2 + (-a - y)^2] - (2*a)/Sqrt[3])^2



In[199]:= Simplify[U[0, 0], Reals]

Out[199]= 2 ((k1/2)[(2 (-a + Sqrt[a^2]))/Sqrt[3]]^2 + (k2/2)[(
    2 (-a + Sqrt[a^2]))/Sqrt[3]]^2)

(**The above output is the correct form that I should be seeing**)

D[U[x, y], x] /. values

Out[258]= 0

In[303]:= D[U[x, y], x, y] /. values

Out[303]= 0

(**The above are correct outputs according to the problem statement**)

In[304]:= Simplify[D[U[x, y], x, y] /. values, Reals]

Out[304]= 0

(**The above derivative should give:(Sqrt[3]/2k1-Sqrt[3]/2k2) \
according to the problem statement 
But for some reason the D[] function is also taking derivates of k1 \
and k2 - which are set as constants
**)

Here's the result of my computation, which did give the correct values for my taylor expansion

I know this problem has something to do with my notation or the constants k1 and k2. I am new to mathematica, so this may just be a syntax error.

Thanks in advance.

In[224]:= Clear[x]
Clear[y]
Clear[a]
Clear[k1]
Clear[k2]
Clear[U]

In[299]:= Attributes[a] = {Constant}
Attributes[k1] = {Constant}
Attributes[k2] = {Constant}

In[275]:= values = {x_ -> 0, y_ -> 0}

In[276]:= 
U[x_, y_] := 
 k1/2 (Sqrt[(a - x)^2 + (a/Sqrt[3] - y)^2] - (2*a)/Sqrt[3])^2 + 
  k1/2*(Sqrt[(-a - x)^2 + (-(a/Sqrt[3]) - y)^2] - (2*a)/Sqrt[3])^2 + 
  k2/2*(Sqrt[(-(a/Sqrt[3]) - x)^2 + (a - y)^2] - (2*a)/Sqrt[3])^2 + 
  k2/2*(Sqrt[(a/Sqrt[3] - x)^2 + (-a - y)^2] - (2*a)/Sqrt[3])^2



In[199]:= Simplify[U[0, 0], Reals]

Out[199]= 2 ((k1/2)[(2 (-a + Sqrt[a^2]))/Sqrt[3]]^2 + (k2/2)[(
    2 (-a + Sqrt[a^2]))/Sqrt[3]]^2)

(**The above output is the correct form that I should be seeing**)

D[U[x, y], x] /. values

Out[258]= 0

In[303]:= D[U[x, y], y] /. values

Out[303]= 0

(**The above are correct outputs according to the problem statement**)

In[304]:= Simplify[D[U[x, y], x, y] /. values, Reals]

Out[304]= 0

(**The above derivative should give:(Sqrt[3]/2k1-Sqrt[3]/2k2) \
according to the problem statement 
But for some reason the D[] function is also taking derivates of k1 \
and k2 - which are set as constants
**)

I know this problem has something to do with my notation or the constants k1 and k2. I am new to mathematica, so this may just be a syntax error.

Thanks in advance.

Update: here is the result of my changes, which did output the correct values for my taylor expansion

correctly defined my function, solving the problem.
Source Link
In[224]:= Clear[x]
Clear[y]
Clear[a]
Clear[k1]
Clear[k2]
Clear[U]

In[299]:= Attributes[a] = {Constant}
Attributes[k1] = {Constant}
Attributes[k2] = {Constant}

In[275]:= values = {x_ -> 0, y_ -> 0}

In[276]:= 
U[x_, y_] := (
 k1/2)[
    (Sqrt[(a - x)^2 + (a/Sqrt[3] - y)^2] - (2*a)/Sqrt[3]]^2Sqrt[3])^2 + (k1/2)[
    k1/2*(Sqrt[(-a - x)^2 + (-(a/Sqrt[3]) - y)^2] - (2*a)/Sqrt[3]]^2Sqrt[3])^2 + (k2/
    2)[Sqrt[k2/2*(Sqrt[(-(a/Sqrt[3]) - x)^2 + (a - y)^2] - (2*a)/Sqrt[3]]^2Sqrt[3])^2 + (
    k2/2)[Sqrt[2*(Sqrt[(a/Sqrt[3] - x)^2 + (-a - y)^2] - (2*a)/Sqrt[3]]^2Sqrt[3])^2



In[199]:= Simplify[U[0, 0], Reals]

Out[199]= 2 ((k1/2)[(2 (-a + Sqrt[a^2]))/Sqrt[3]]^2 + (k2/2)[(
    2 (-a + Sqrt[a^2]))/Sqrt[3]]^2)

(**The above output is the correct form that I should be seeing**)

D[U[x, y], x] /. values

Out[258]= 0

In[303]:= D[U[x, y], x, y] /. values

Out[303]= 0

(**The above are correct outputs according to the problem statement**)

In[304]:= Simplify[D[U[x, y], x, y] /. values, Reals]

Out[304]= 0

(**The above derivative should give:(Sqrt[3]/2k1-Sqrt[3]/2k2) \
according to the problem statement 
But for some reason the D[] function is also taking derivates of k1 \
and k2 - which are set as constants
**)

Here's the result of my computation, which did give the correct values for my taylor expansion

In[352]:= D[U[x, y], y, x] /. values

Out[352]= (Sqrt[3] k1)/2 - (
 3 (-((2 a)/Sqrt[3]) + (2 Sqrt[a^2])/Sqrt[3]) k1)/(4 Sqrt[a^2]) - (
 Sqrt[3] k2)/2 + (3 (-((2 a)/Sqrt[3]) + (2 Sqrt[a^2])/Sqrt[3]) k2)/(
 4 Sqrt[a^2])

In[354]:= Simplify[D[U[x, y], x, y] /. values, Reals]

Out[354]= (Sqrt[3] a (k1 - k2))/(2 Sqrt[a^2])
In[224]:= Clear[x]
Clear[y]
Clear[a]
Clear[k1]
Clear[k2]
Clear[U]

In[299]:= Attributes[a] = {Constant}
Attributes[k1] = {Constant}
Attributes[k2] = {Constant}

In[275]:= values = {x_ -> 0, y_ -> 0}

In[276]:= 
U[x_, y_] := (k1/2)[
    Sqrt[(a - x)^2 + (a/Sqrt[3] - y)^2] - (2*a)/Sqrt[3]]^2 + (k1/2)[
    Sqrt[(-a - x)^2 + (-(a/Sqrt[3]) - y)^2] - (2*a)/Sqrt[3]]^2 + (k2/
    2)[Sqrt[(-(a/Sqrt[3]) - x)^2 + (a - y)^2] - (2*a)/Sqrt[3]]^2 + (
    k2/2)[Sqrt[(a/Sqrt[3] - x)^2 + (-a - y)^2] - (2*a)/Sqrt[3]]^2



In[199]:= Simplify[U[0, 0], Reals]

Out[199]= 2 ((k1/2)[(2 (-a + Sqrt[a^2]))/Sqrt[3]]^2 + (k2/2)[(
    2 (-a + Sqrt[a^2]))/Sqrt[3]]^2)

(**The above output is the correct form that I should be seeing**)

D[U[x, y], x] /. values

Out[258]= 0

In[303]:= D[U[x, y], x, y] /. values

Out[303]= 0

(**The above are correct outputs according to the problem statement**)

In[304]:= Simplify[D[U[x, y], x, y] /. values, Reals]

Out[304]= 0

(**The above derivative should give:(Sqrt[3]/2k1-Sqrt[3]/2k2) \
according to the problem statement 
But for some reason the D[] function is also taking derivates of k1 \
and k2 - which are set as constants
**)
In[224]:= Clear[x]
Clear[y]
Clear[a]
Clear[k1]
Clear[k2]
Clear[U]

In[299]:= Attributes[a] = {Constant}
Attributes[k1] = {Constant}
Attributes[k2] = {Constant}

In[275]:= values = {x_ -> 0, y_ -> 0}

In[276]:= 
U[x_, y_] := 
 k1/2 (Sqrt[(a - x)^2 + (a/Sqrt[3] - y)^2] - (2*a)/Sqrt[3])^2 + 
  k1/2*(Sqrt[(-a - x)^2 + (-(a/Sqrt[3]) - y)^2] - (2*a)/Sqrt[3])^2 + 
  k2/2*(Sqrt[(-(a/Sqrt[3]) - x)^2 + (a - y)^2] - (2*a)/Sqrt[3])^2 + 
  k2/2*(Sqrt[(a/Sqrt[3] - x)^2 + (-a - y)^2] - (2*a)/Sqrt[3])^2



In[199]:= Simplify[U[0, 0], Reals]

Out[199]= 2 ((k1/2)[(2 (-a + Sqrt[a^2]))/Sqrt[3]]^2 + (k2/2)[(
    2 (-a + Sqrt[a^2]))/Sqrt[3]]^2)

(**The above output is the correct form that I should be seeing**)

D[U[x, y], x] /. values

Out[258]= 0

In[303]:= D[U[x, y], x, y] /. values

Out[303]= 0

(**The above are correct outputs according to the problem statement**)

In[304]:= Simplify[D[U[x, y], x, y] /. values, Reals]

Out[304]= 0

(**The above derivative should give:(Sqrt[3]/2k1-Sqrt[3]/2k2) \
according to the problem statement 
But for some reason the D[] function is also taking derivates of k1 \
and k2 - which are set as constants
**)

Here's the result of my computation, which did give the correct values for my taylor expansion

In[352]:= D[U[x, y], y, x] /. values

Out[352]= (Sqrt[3] k1)/2 - (
 3 (-((2 a)/Sqrt[3]) + (2 Sqrt[a^2])/Sqrt[3]) k1)/(4 Sqrt[a^2]) - (
 Sqrt[3] k2)/2 + (3 (-((2 a)/Sqrt[3]) + (2 Sqrt[a^2])/Sqrt[3]) k2)/(
 4 Sqrt[a^2])

In[354]:= Simplify[D[U[x, y], x, y] /. values, Reals]

Out[354]= (Sqrt[3] a (k1 - k2))/(2 Sqrt[a^2])
edited body
Source Link
RunnyKine
  • 33.3k
  • 3
  • 110
  • 176

This question is not enlightening nor is it difficult. But some part of my notation or how I have defined my functions is messing up the D[f,x] function.

In[224]:= Clear[x]
Clear[y]
Clear[a]
Clear[k1]
Clear[k2]
Clear[U]

In[299]:= Attributes[a] = {Constant}
Attributes[k1] = {Constant}
Attributes[k2] = {Constant}

In[275]:= values = {x_ -> 0, y_ -> 0}

In[276]:= 
U[x_, y_] := (k1/2)[
    Sqrt[(a - x)^2 + (a/Sqrt[3] - y)^2] - (2*a)/Sqrt[3]]^2 + (k1/2)[
    Sqrt[(-a - x)^2 + (-(a/Sqrt[3]) - y)^2] - (2*a)/Sqrt[3]]^2 + (k2/
    2)[Sqrt[(-(a/Sqrt[3]) - x)^2 + (a - y)^2] - (2*a)/Sqrt[3]]^2 + (
    k2/2)[Sqrt[(a/Sqrt[3] - x)^2 + (-a - y)^2] - (2*a)/Sqrt[3]]^2



In[199]:= Simplify[U[0, 0], Reals]

Out[199]= 2 ((k1/2)[(2 (-a + Sqrt[a^2]))/Sqrt[3]]^2 + (k2/2)[(
    2 (-a + Sqrt[a^2]))/Sqrt[3]]^2)

(**The above output is the correct form that I should be seeing**)

D[U[x, y], x] /. values

Out[258]= 0

In[303]:= D[U[x, y], x, y] /. values

Out[303]= 0

(**The above are correct outputs according to the problem statement**)

In[304]:= Simplify[D[U[x, y], x, y] /. values, Reals]

Out[304]= 0

(**The above derivative should give:(Sqrt[3]/2k1-Sqrt[3]/2k2) \
according to the problem statement 
But for some reason the D[] function is also taking derivates of k1 \
and k2 - which are set as constants
**)

I know this problem has something to do with my notation or the constants k1 and k2. I am new to mathematica, so this may just be a syntax error.

Thanks isin advance.

This question is not enlightening nor is it difficult. But some part of my notation or how I have defined my functions is messing up the D[f,x] function.

In[224]:= Clear[x]
Clear[y]
Clear[a]
Clear[k1]
Clear[k2]
Clear[U]

In[299]:= Attributes[a] = {Constant}
Attributes[k1] = {Constant}
Attributes[k2] = {Constant}

In[275]:= values = {x_ -> 0, y_ -> 0}

In[276]:= 
U[x_, y_] := (k1/2)[
    Sqrt[(a - x)^2 + (a/Sqrt[3] - y)^2] - (2*a)/Sqrt[3]]^2 + (k1/2)[
    Sqrt[(-a - x)^2 + (-(a/Sqrt[3]) - y)^2] - (2*a)/Sqrt[3]]^2 + (k2/
    2)[Sqrt[(-(a/Sqrt[3]) - x)^2 + (a - y)^2] - (2*a)/Sqrt[3]]^2 + (
    k2/2)[Sqrt[(a/Sqrt[3] - x)^2 + (-a - y)^2] - (2*a)/Sqrt[3]]^2



In[199]:= Simplify[U[0, 0], Reals]

Out[199]= 2 ((k1/2)[(2 (-a + Sqrt[a^2]))/Sqrt[3]]^2 + (k2/2)[(
    2 (-a + Sqrt[a^2]))/Sqrt[3]]^2)

(**The above output is the correct form that I should be seeing**)

D[U[x, y], x] /. values

Out[258]= 0

In[303]:= D[U[x, y], x, y] /. values

Out[303]= 0

(**The above are correct outputs according to the problem statement**)

In[304]:= Simplify[D[U[x, y], x, y] /. values, Reals]

Out[304]= 0

(**The above derivative should give:(Sqrt[3]/2k1-Sqrt[3]/2k2) \
according to the problem statement 
But for some reason the D[] function is also taking derivates of k1 \
and k2 - which are set as constants
**)

I know this problem has something to do with my notation or the constants k1 and k2. I am new to mathematica, so this may just be a syntax error.

Thanks is advance.

This question is not enlightening nor is it difficult. But some part of my notation or how I have defined my functions is messing up the D[f,x] function.

In[224]:= Clear[x]
Clear[y]
Clear[a]
Clear[k1]
Clear[k2]
Clear[U]

In[299]:= Attributes[a] = {Constant}
Attributes[k1] = {Constant}
Attributes[k2] = {Constant}

In[275]:= values = {x_ -> 0, y_ -> 0}

In[276]:= 
U[x_, y_] := (k1/2)[
    Sqrt[(a - x)^2 + (a/Sqrt[3] - y)^2] - (2*a)/Sqrt[3]]^2 + (k1/2)[
    Sqrt[(-a - x)^2 + (-(a/Sqrt[3]) - y)^2] - (2*a)/Sqrt[3]]^2 + (k2/
    2)[Sqrt[(-(a/Sqrt[3]) - x)^2 + (a - y)^2] - (2*a)/Sqrt[3]]^2 + (
    k2/2)[Sqrt[(a/Sqrt[3] - x)^2 + (-a - y)^2] - (2*a)/Sqrt[3]]^2



In[199]:= Simplify[U[0, 0], Reals]

Out[199]= 2 ((k1/2)[(2 (-a + Sqrt[a^2]))/Sqrt[3]]^2 + (k2/2)[(
    2 (-a + Sqrt[a^2]))/Sqrt[3]]^2)

(**The above output is the correct form that I should be seeing**)

D[U[x, y], x] /. values

Out[258]= 0

In[303]:= D[U[x, y], x, y] /. values

Out[303]= 0

(**The above are correct outputs according to the problem statement**)

In[304]:= Simplify[D[U[x, y], x, y] /. values, Reals]

Out[304]= 0

(**The above derivative should give:(Sqrt[3]/2k1-Sqrt[3]/2k2) \
according to the problem statement 
But for some reason the D[] function is also taking derivates of k1 \
and k2 - which are set as constants
**)

I know this problem has something to do with my notation or the constants k1 and k2. I am new to mathematica, so this may just be a syntax error.

Thanks in advance.

Source Link
Loading