1
$\begingroup$

A minimal example is below. I'm trying to reverse function y1d.

ClearAll["Global`*"] (* clear all symbols *)
f0d = 3.5*10^9;
f1d = 500*10^6;
T = 0.1*10^-6;
kd = (f1d - f0d)/T;
phi0 = 0;
chplusd[t_] := E^(I*2*\[Pi]*((kd*t^2)/2 + f0d*t + phi0))
fsig1 = 3*10^9;
x[t_] := Cos[2*Pi*fsig1*t]
s1d[t_] := x[t]*chplusd[t]
snd[t_] := E^(-I*2*\[Pi]*(f0d*t + phi0))
y2d[t_] := s1d[t]*snd[t]
Grid[{{Plot[{Re[y2d[t]]}, {t, 0, T}, PlotRange -> All, Exclusions -> None, GridLines -> Automatic, ImageSize -> Full]}, {Plot[{Re[y2d[T - t]]}, {t, 0, T}, PlotRange -> All, Exclusions -> None, GridLines -> Automatic, ImageSize -> Full]}}]
chmoinsd[t_] := E^(-I*2*\[Pi]*((kd*t^2)/2 + f0d*t + phi0))
y1dtemp = Convolve[y2d[to]*UnitStep[to], chmoinsd[to]*UnitStep[to], to, t, Assumptions -> t >= 0]
y1d[t_] := y1dtemp
Grid[{{Plot[{Re[y1d[t]]}, {t, 0, T}, PlotRange -> All, Exclusions -> None, GridLines -> Automatic, ImageSize -> Full]}, {Plot[{Re[y1d[T - t]]}, {t, 0, T}, PlotRange -> All, Exclusions -> None, GridLines -> Automatic, ImageSize -> Full]}}]

The problem starts in the line with the Convolve function, because I can reverse function y2d.

Before, I tried the below two lines in place of the last three lines of the above code, but it does not work and I don't understand why.

y1d[t_] := Convolve[y2d[to]*UnitStep[to], chmoinsd[to]*UnitStep[to], to, t, Assumptions -> t >= 0]
Grid[{{Plot[{Re[y1d[t]]}, {t, 0, T}, PlotRange -> All, Exclusions -> None, GridLines -> Automatic, ImageSize -> Full]}, {Plot[{Re[y1d[T - t]]}, {t, 0, T}, PlotRange -> All, Exclusions -> None, GridLines -> Automatic, ImageSize -> Full]}}]
$\endgroup$
3
  • $\begingroup$ The code runs without any error messages and there is no obvious indication of what problem you are referring to. Could you please be more explicit about what is "the problem" and what you mean by "reverse a function"? Do you mean to find the inverse function? $\endgroup$ Commented Jul 23, 2017 at 11:55
  • $\begingroup$ The code block runs without problems, but if you change the last three lines of the code block by the two lines I've given below the code block, Mathematica is unable to plot y1d, processing never ends. By "reversing a function", I mean create a function g[t] of the form: g[0]=f[T], f[0+dt]=f[T-dt], ... , g[T]=f[0], like what was made by Bill S, in mathematica.stackexchange.com/questions/112696/… $\endgroup$ Commented Jul 23, 2017 at 12:51
  • $\begingroup$ In the example given, I reversed y2d. You can see in the plot. But y1d is not reversed, the plots are equal. $\endgroup$ Commented Jul 23, 2017 at 12:54

1 Answer 1

1
$\begingroup$

In the second example you asking Mathematica to evaluate the expression at every point.

This is a lot of extra work (it will eventually complete I think).

Instead wrap the expression in Evaluate so the closed form (i.e., equivalent to y1dtemp is used to make the plot.

Note: not part of the question but you don't need the curly brackets around the expression.

Grid[{
    {Plot[Evaluate[Re[y1d[t]]], {t, 0, T}, PlotRange -> All, 
    Exclusions -> None, GridLines -> Automatic, 
    ImageSize -> Full]},
     {Plot[Evaluate[Re[y1d[T - t]]], {t, 0, T}, PlotRange -> All,
     Exclusions -> None, GridLines -> Automatic, 
    ImageSize -> Full]}
    }]

Mathematica graphics

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.