Re: real valued function from complex
- To: mathgroup at smc.vnet.net
- Subject: [mg37401] Re: [mg37354] real valued function from complex
- From: Daniel Lichtblau <danl at wolfram.com>
- Date: Sat, 26 Oct 2002 02:04:12 -0400 (EDT)
- References: <200210250646.CAA18072@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
strgh at mimosa.csv.warwick.ac.uk wrote:
>
> I want to define a real-valued function f[t_] from the
> values of a complex-valued function on a line parametrised
> by t, and then be able to handle f like any other real
> function (differentiate it etc.)
>
> A cute example is:
>
> Clear[rz, drz];
> rz[t_] := Re[Zeta[1/2 + I*t]];
> drz[t_] := D[rz[t], t] (* the sort of thing I want to do *)
>
> so that
>
> Plot[{drz[t], Im[Zeta[1/2 + I*t]]}, {t, 0, 40},
> PlotStyle -> {RGBColor[1, 0, 0], RGBColor[0, 0, 1]}]
>
> will work (it doesn't).
> I can get a quick & dirty numerical approximation in this case
> (including, as a reality check, the original function I'm
> differentiating) using something like
>
> Clear[rz, iz, rztable, plotzeta];
> rz[t_] := Re[Zeta[1/2 + I*t]];
> iz[t_] := Im[Zeta[1/2 + I*t]];
> rztable[tmin_, tmax_] :=
> Table[{t, rz[t]}, {t, tmin, tmax, (tmax - tmin)/50}];
> plotzeta[tmin_, tmax_] := Module[{rzapprox},
> rzapprox = Interpolation[rztable[tmin, tmax]];
> Plot[{rzapprox'[t], rz[t], iz[t]}, {t, 0, 40},
> PlotStyle -> {RGBColor[1, 0, 0], RGBColor[0, 1, 0],
> RGBColor[0, 0, 1]}]
> ]
>
> plotzeta[0, 40]
>
> However I'd prefer to leave the numerical approximations
> till the last minute (i.e. plotting), and the interpolation
> table would need tweaking on a case-by-case basis.
> Any other suggestions? (sorry if there is an "obvious" answer).
> -- Ewart Shaw
> --
> J.E.H.Shaw [Ewart Shaw] strgh at uk.ac.warwick TEL: +44 2476 523069
> Department of Statistics, University of Warwick, Coventry CV4 7AL, U.K.
> http://www.warwick.ac.uk/statsdept/Staff/JEHS/
> 3 ((4&({*.(=+/))++/=3:)@([:,/0&,^:(i.3)@|:"2^:2))&.>@]^:(i.@[) <#:3 6 2
You can "commute" Re with D. To make use of this we'll unprotect Re and
place an UpValue for D on it.
rz[t_] := Re[Zeta[1/2 + I*t]];
Unprotect[Re];
D[Re[a_],x_] ^:= Re[D[a,x]]
We also want to work with a dummy variable even when we pass in a number
so we do a temporary substitution.
drz[t_] := D[rz[x],x] /. x->t
Now your plot should work fine.
Daniel Lichtblau
Wolfram Research
- References:
- real valued function from complex
- From: strgh@mimosa.csv.warwick.ac.uk ()
- real valued function from complex