Re: Re: Re: Condition/constraint problem
- To: mathgroup at smc.vnet.net
- Subject: [mg41016] Re: [mg40976] Re: [mg40938] Re: Condition/constraint problem
- From: Bobby Treat <drmajorbob+MathGroup3528 at mailblocks.com>
- Date: Tue, 29 Apr 2003 05:22:40 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Trying to understand the issues better, I tried a simpleton numerical
method:
f = 0.0015 + 0.0012 Sin[70 #] &;
myDv[step_] := If[#1 + step < 5, (
f[#1 + step] - f[#1 - step])/(2*step), undefined] &
maxError[delta_] := Block[{$DisplayFunction},
plot = Plot[{f'[t] - myDv[delta][t]}, {t, 0, 2}, PlotPoints ->
100, ImageSize -> 500];
Max@Abs@Cases[plot, Line[a_] :> a, Infinity][[1, All, 2]]
]
ListPlot[Table[{delta,
maxError[delta]}, {delta, .1, 1.1, .1}], AxesOrigin -> {0,
Automatic}];
Even with relatively huge step-sizes, this error is smaller than the
one Derivative is making:
vx1[t_] := 0.0015 + 0.0012 Sin[70 t] /; t < 5
fin1 = Dt[vx1[t], t];
plot = Plot[fin1 - f'[t], {t, 0, 2}, PlotPoints -> 100, ImageSize ->
500, PlotRange -> All];
Max@Abs@Cases[plot, Line[a_] :> a, Infinity][[1, All, 2]]
0.12411
There's also this behavior, as Peltio already pointed out:
Table[fin1, {t, 4.4, 5, 0.1}]
Table[myDv[0.01][t], {t, 4.4, 5, 0.1}]
Table[f'[t], {t, 4.4, 5, 0.1}]
{-0.0398025806772852, -0.02675008852536776,
Derivative[1][vx1][4.6000000000000005],
Derivative[1][vx1][4.7], Derivative[1][vx1][
4.800000000000001], Derivative[1][vx1][
4.9], Derivative[1][vx1][5.]}
{0.0767133, 0.0515567, 0.00102404, -0.0500126, -0.0764333,
-0.0652338, undefined}
{0.0833559, 0.0560209, 0.00111271, -0.0543432, -0.0830516,
-0.0708824, -0.0238252}
There may not be a bug, but it sure ain't impressive!
Bobby
-----Original Message-----
From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
To: mathgroup at smc.vnet.net
<kuska at informatik.uni-leipzig.de>; u8514501 at cc.nctu.edu.tw
Subject: [mg41016] Re: [mg40976] Re: [mg40938] Re: Condition/constraint problem
I forgot to say one (rather obvious) thing so just for the sake of
completeness: the reason for the difference is, of course, that the
first derivative is computed numerically while the second symbolically
and the value specified for t is substituted into the symbolic
expression. As Jens correctly pointed out, Mathematica can't compute
the derivative of the first function symbolically and won't return any
value if specify an exact number (like 2) for the value where the you
want the derivative to be computed.
Anyway, my point was that there is no bug here.
Andrzej Kozlowski
Yokohama, Japan
http://www.mimuw.edu.pl/~akoz/
http://platon.c.u-tokyo.ac.jp/andrzej/
On Saturday, April 26, 2003, at 07:47 pm, Andrzej Kozlowski wrote:
> This seems to be just an accuracy problem due to the very rapidly >
oscillating nature of the function. You need much more accurate input,
> and even then the answers won't be exactly the same:
>
> In[1]:=
> vx1[t_] := 3/2000 + (3*Sin[70*t])/2500 /; t < 5
>
> In[2]:=
> vx2[t_] := 3/2000 + (3*Sin[70*t])/2500
>
> In[3]:=
> Derivative[1][vx1][2.`50]
>
> Out[3]=
> -0.016616340216276107118073957504289560620917139256026603482\
> 40545`46.5497
>
> In[4]:=
> Derivative[1][vx2][2.`50]
>
> Out[4]=
> -0.016616340216358530300150292495099072037728048646002646485\
> 71143`47.1588
>
>
> Andrzej Kozlowski
> Yokohama, Japan
> http://www.mimuw.edu.pl/~akoz/
> http://platon.c.u-tokyo.ac.jp/andrzej/
>
>
> On Saturday, April 26, 2003, at 04:26 pm, Bobby Treat wrote:
>
>> Your explanation implies there IS no value for vx1'[t], but >>
Mathematica
>> does compute one, when t is numeric. It's simply wrong.
>>
>> vx1[t_] := 0.0015 + 0.0012 Sin[70 t] /; t < 5
>> vx2[t_] := 0.0015 + 0.0012 Sin[70 t]
>> vx1'[2.]
>> vx2'[2.]
>>
>> 0.00793433
>> -0.0166163
>>
>> Bobby
>>
>> -----Original Message-----
>> From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
To: mathgroup at smc.vnet.net
>> To: mathgroup at smc.vnet.net
>> Subject: [mg41016] [mg40976] [mg40938] Re: Condition/constraint problem
>>
>> Hi,
>>
>> der derivative is complete right, since
>> Condition[] has no derivative
>>
>> Dt[vx1[t]] evaluates to vx1'[t]
>>
>> until you can tell Mathematica how to
>> find out
>> a) what the function value of vx1[t] for t>5 may be
>> b) to compute the derivative for t==5
>> c) determine when the symbol t in vx1[t] may be >5
>>
>>
>> Regards
>> Jens
>> Bamboo wrote:
>>>
>>> Dear all,
>>>
>>> I find a problem and don't know why. The input is as following.
>>> If a condiction(constraint) is set to the function, vx1[t],
>>> the derivative of vx1[t] is worng (fin1 is not equal to fin2).
>>> Any help welcome.
>>>
>>> vx1[t_] : = 0.0015 + 0.0012 Sin[70 t] /; t < 5
>>> vx2[t_] : = 0.0015 + 0.0012 Sin[70 t]
>>> fin1 = Dt[vx1[t], t]
>>> fin2 = Dt[vx2[t], t]
>>> Plot[fin1, {t, 0, 2}]
>>> Plot[fin2, {t, 0, 2}]
>>>
>>> Thanks,
>>> Bamboo
>>
>>
>>
>
>