3

In case I want to know whether a given function $f(t)$ have some property, I tried to write something like this:

IsSuppFun[f_[t_]] := Resolve[
ForAll[t, 0 <=t <= 2&&t\[Element] Reals,
 f[t] + D[f[t], {t, 2}] >= 0]]

Which means, if the given function satisfies the condition: $f(t)+f''(t)\geq 0$ for all $0\leq t\leq 2$, then return TRUE, else return False.

The problem is that it is not work as I supposed, for example, if I define

F[t_]:=t^2-3

then the output is:

IsSuppFun[-3 + t^2]

If I separate the code as

Resolve[ForAll[t, 0 <= t <= 2 Pi && t \[Element] Reals, F[t] + F''[t] >= 0]]

Which will get the Right Answer!

Where did I go wrong?

Solution is use the HoldAll attribute for the function IsSuppFun, Please see below for the answer!


there is my another problem in the same line: If I have tried to add another condition as:

SetAttributes[IsSuppFun, HoldAll]
IsSuppFun[f_[t_]] := 
Resolve[ForAll[t, 0 <= t <= 2 && t \[Element] Reals, (f[t] + D[f[t], {t, 2}] >= 0)&&(f[0]==f[2])]]

then with the same test function:

F[t_] := t^2 - 3

the output is not as desired True or False, but as:

\!\(\*SubscriptBox[\(\[ForAll]\), \(t\)]\(! \((0 <= t <= 2 &&  t \[Element] Reals)\)\)\)

May be I should change the last question as (to make things clear and simple):

SetAttributes[{IsSuppFun}, HoldAll]
IsSuppFun[f_[t_]] := Resolve[
ForAll[t,
0<= t <= 2 && t \[Element] Reals,
f[1] >= 0]
]

with the test function as:

F[t_] := Sin[t]

then the output of

IsSuppFun[F[t]]

is True; But if I have change it as

SetAttributes[{IsSuppFun}, HoldAll]
IsSuppFun[f_[t_]] := Resolve[
ForAll[t,
0<= t <= 2 && t \[Element] Reals,
f[1] <= 0]
]

Then the same test function gives neither True nor False. (I Suppose it False!) Why?

van abel
  • 1,235
  • 1
  • 11
  • 27
  • I think the problem is specifying the function's argument in IsSuppFun. Try : bigF[t_] = t^2 - 3; IsSuppFun[bigF]. – b.gates.you.know.what Oct 19 '12 at 10:38
  • van abel, I think you are still confusing the second and third arguments of ForAll perhaps? In your added example you are essentially doing: Resolve[ForAll[t, 0 <= t <= 2 && t \[Element] Reals, False]] because F[0]==F[2] is False. – Mr.Wizard Oct 19 '12 at 11:21

3 Answers3

6

This answer intends to answer both parts of the question. Originally it answered only the first part. Below is the original answer. Scroll down for the second part.


I interchanged the third and second argument of ForAll and gave the function IsSuppFun attribute HoldAll, and it worked!

So I wrote

SetAttributes[IsSuppFun, HoldAll]
IsSuppFun[f_[t_]] := 
 Resolve[
  ForAll[
   t,
   0 <= t <= 2 ,
   f[t] + D[f[t], {t, 2}] >= 0
   ]
  ]

(*testcase*)

f[t_] := t^4

Then

IsSuppFun[f[x]]

Evaluates to True.


Second part

I removed the t \[Element] Reals, because it seemed redundant, or possibly wrong syntax. As it turned out, the new function worked.

SetAttributes[IsSuppFunGE, HoldAll]
IsSuppFunGE[f_[t_]] :=
  Resolve[ForAll[t, 0 <= t <= 2, f[1] >= 0]];

(* testcases*)
f[t_] := Sin[t];
g[t_] := Sin[t] - 2;
h[t_] := Cos[t] + 1;

Given these definitions,

{IsSuppFunGE[f[x]] , IsSuppFunGE[g[x]], IsSuppFunGE[h[x]]}

evaluates to

{True, False, True}

The question may arise if Mathematica is still using real numbers, as this is now not specified. The fact that the expression

Resolve[ForAll[t, 0 <= t <= 4, t != Pi]]

evaluates to False, may add confidence that it does indeed use real numbers (already).

Jacob Akkerboom
  • 12,215
  • 45
  • 79
4

You may be able to get what you want by setting a Hold attribute on your function:

SetAttributes[IsSuppFun, HoldAll]

IsSuppFun[f_[t_]] := 
 Resolve[ForAll[t, 0 <= t <= 2 && t \[Element] Reals, f[t] + D[f[t], {t, 2}] >= 0]]

f[t_] := t^2 - 3

IsSuppFun[f[t]]

False

Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371
0

I would use this Convert an expression to a Function as follows

 IsSuppFun[F_] := Module[{t,f= extractPureFunction[F]}, Resolve[
      ForAll[t, 0 <=t <= 2&&t\[Element] Reals,
      f[t] + D[f[t], {t, 2}] >= 0]]]

so that I don't have to worry about which variable is used.

The credit for the extractPureFunction that I use goes to Daniel Lichtblau

chris
  • 22,860
  • 5
  • 60
  • 149