Re: force variable to be real
- To: mathgroup at smc.vnet.net
- Subject: [mg91790] Re: [mg91736] force variable to be real
- From: Benjamin Reedlunn <breedlun at umich.edu>
- Date: Sun, 7 Sep 2008 22:55:24 -0400 (EDT)
- References: <200809070933.FAA25407@smc.vnet.net>
Hi Paul, I think the most simple way to fix your problem is to just take the derivative wrt to Re[x]: In[20]:= w = x + I 2 x z Out[20]= 2 i z x + x In[21]:= y = Re[w] Out[21]= Re(x) - 2 Im(x z) In[26]:= D[y, Re[x]] Out[26]= 1 One important distinction is Re[] does not actually permanently force a variable to be real. I'm not sure that there is a way to do this. Re[] only gives the real part of that variable for the expression it is used in. Also, I've often found assumptions useful. For example: In[29]:= Simplify[Sqrt[x^2]] Out[29]= Sqrt[x^2] clearly giving no simplification. But if you assume that x is real then: In[31]:= Simplify[Sqrt[x^2], Element[x, Reals]] Out[31]= |x| There may be a way to make assumptions global, but I'm not sure how. -Ben Reedlunn On Sep 7, 2008, at 5:33 AM, phillman5 wrote: > How do you force variables to be real? > > I have > w:=x + I 2 x z, > and > y:=Re[w] > > and want the derivative of y wrt x, x and z are Real > D[y, x] > gives > Re'[x] - 2 z Im'[x z] > > where I'd expect just 1. Or I need to evaluate Re[w] forcing x and z > to be real, then take the derivative. > > Thank you for any help > Paul > > > >
- References:
- force variable to be real
- From: phillman5 <PHILLMAN5@gmail.com>
- force variable to be real