On 7/28/07, Tim Lahey <[EMAIL PROTECTED]> wrote:
> Looking through the documentation, I haven't seen any examples of
> using a function name without it being defined first. I've been using
> Maple for years and I have a lot of code that relies upon this. This
> also ties into a second question related to integration. Is there any
> way to delay the integration? Maple provides inert derivatives and
> integrals so you can display something as an derivative or integral
> and delay the evaluation until later.
>
> The reason I ask is that I often work with functions that are unknown
> (e.g., variations from the calculus of variations) or are approximated
> (and I want to investigate the effects of different approximations).
> In Maple I often have integrals that have terms that look like:
>
> Int(Int(Int(Int(u(x,y,z,t)*Diff(deltau(x,y,z,t),x),x),y),z),t)

SAGE does have some support for this sort of thing via the
function command.   Let me know if this
is at all what you're looking for.  Here's an example:

https://sage.math.washington.edu:8103/home/pub/1473/

or here is a log of the session in the above worksheet:

sage: deltau = function('deltau')
sage: u = function('u')
sage: Int = integrate
sage: Diff = diff
sage: x,y,z,t = var('x,y,z,t')
sage: Z = Int(Int(Int(Int(u(x,y,z,t)*Diff(deltau(x,y,z,t),x),x),y),z),t)
sage: Z
integrate(integrate(integrate(integrate(u(x, y, z, t)*diff(deltau(x,
y, z, t), x, 1), x), y), z), t)
sage: m(x,y,z,t) = x+y+z+t
sage: W = Z(u = m)
sage: W
integrate(integrate(integrate(integrate(diff(deltau(x, y, z, t), x,
1)*z + diff(deltau(x, y, z, t), x, 1)*y + x*diff(deltau(x, y, z, t),
x, 1), x) + t*deltau(x, y, z, t), y), z), t)
sage: W(deltau=m)
(t^2*(3*y*z^2 + (3*y^2 + 6*x*y)*z) + 4*t^3*y*z)/12 + t*x*y*z^2/2 +
t*x*y^2*z/2 + t*x^2*y*z/2


and here is a version you can paste into edit mode of a worksheet:


{{{id=0|
deltau = function('deltau')
}}}

{{{id=1|
u = function('u')
}}}

{{{id=2|
Int = integrate
Diff = diff
x,y,z,t = var('x,y,z,t')
Z = Int(Int(Int(Int(u(x,y,z,t)*Diff(deltau(x,y,z,t),x),x),y),z),t)
}}}

{{{id=3|
Z
///
integrate(integrate(integrate(integrate(u(x, y, z, t)*diff(deltau(x,
y, z, t), x, 1), x), y), z), t)
}}}

{{{id=4|
m(x,y,z,t) = x+y+z+t
}}}

{{{id=5|
W = Z(u = m)
W
///
integrate(integrate(integrate(integrate(diff(deltau(x, y, z, t), x,
1)*z + diff(deltau(x, y, z, t), x, 1)*y + x*diff(deltau(x, y, z, t),
x, 1), x) + t*deltau(x, y, z, t), y), z), t)
}}}

{{{id=6|
W(deltau=m)
///
(t^2*(3*y*z^2 + (3*y^2 + 6*x*y)*z) + 4*t^3*y*z)/12 + t*x*y*z^2/2 +
t*x*y^2*z/2 + t*x^2*y*z/2
}}}

>
> If the CAS is going to try to evaluate each integral at every
> computational step, it can get very expensive. The simplest work
> around is to work with the integrands until the last step, but it
> isn't ideal because this means you have to keep track of what terms
> correspond to each integral. For instance, in the example above, you
> need to integrate by parts to eliminate the derivative on the deltau
> term. So, without the integrals in place, so bookkeeping is necessary.
>
> Thanks,
>
> Tim Lahey
>
>
> >
>


-- 
William Stein
Associate Professor of Mathematics
University of Washington
http://www.williamstein.org

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-forum
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to