Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2003
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: use of SetDelayed functions in Plot and Solve

  • To: mathgroup at smc.vnet.net
  • Subject: [mg44601] Re: [mg44585] use of SetDelayed functions in Plot and Solve
  • From: Anton Antonov <antonov at wolfram.com>
  • Date: Mon, 17 Nov 2003 03:38:36 -0500 (EST)
  • References: <200311150705.CAA11421@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

(1)
In the first, SetDelayed input you use NIntegrate, in the second, Set 
input you use Integrate. If you use Integrate in the SetDelayed input 
you will get the plot.

NIntegrate is a numerical function, so at the time it is invoked all of 
its arguments should be numbers or evaluate to numbers. When you use the 
definitions

Clear[s, i, k];
s[t_] := NIntegrate[t^2 - z*Log[t], {z, 0, k[t]}];
i[t_] := D[s[t], t] /. {k[t] -> 2t, k'[t] -> Sin[t]};

the command D[s[t],t] in i[t_] trys to evaluate NIntegrate with a 
symbolic variable range. With Integrate, of course, symbolic ranges are 
fine.

(2)
As for the Solve part, you can try FindRoot, instead of Solve.

In[1]:=
Clear[s, i];
s[t_] := Integrate[t^2 - z*Log[t], {z, 0, k[t]}];
i[t_] := D[s[t], t] /. {k[t] -> 2t, k'[t] -> Sin[t]};


In[6]:=FindRoot[i[t]==300,{t,1}]
Out[6]={t->8.48795}

Anton Antonov
Wolfram Research, Inc.


Mukhtar Bekkali wrote:

>Why can't I plot the function and find the solution to the equation below
>using SetDelayed functions?  Below is just an example, the real functions
>are symbolically non-integrable.
>
>s[t_] :=NIntegrate[t^2 - z*Log[t] , {z, 0, k[t]}]
>i[t_] := D[s[t],t] /. {k[t] ->2t,k'[t]->Sin[t]}
>Plot[i[t], {t, 1, 10}]
>Solve[i[t]==300, t]]
>  
>
>All I get is an empty graph because I have "not machine real size numbers"
>and my equation "appears to be solved essentially in non-algebraic way".
>If I rewrite the code using simple Set I get my graph and solutions.
>
>s=Integrate[t^2 - z*Log[t] , {z, 0, k[t]}]
>i=D[s,t] /. {k[t]->2t,k'[t]->Sin[t]}
>Plot[i, {t, 1, 10}]
>Solve[i==300, t]]
>
>Very confused. Thanks, Mukhtar Bekkali
>
>
>  
>



  • Prev by Date: Re: Automatic comment coloring
  • Next by Date: Re: Readability confuses mathematica?
  • Previous by thread: use of SetDelayed functions in Plot and Solve
  • Next by thread: Re: use of SetDelayed functions in Plot and Solve