# Question:How do I find the minimum of a function calculated from a differential equation in an efficient way?

## Question:How do I find the minimum of a function calculated from a differential equation in an efficient way?

Maple

I would like to know how I can calculate the minimum of a function that  is the solution of a differential equation in a (time)-efficient way

Parameters:L := 0.5e-2; Zs := (2/3*180)*10^(-6); Za := (4/3*180)*10^(-6); ss := (2/3*14)*10^4; sa := (4/3*14)*10^4; a := 1.35; N1 := 600; N2 := 300;

Solution of the differential equation:

Nf := unapply(rhs(simplify(dsolve({a*(diff(N(x), `\$`(x, 2)))-k*(Zs-Za)*N(x)/L = -k^2/(sa+(ss-sa)*x/L), N(0) = N1, N(L) = N2}, N(x)))), x, k);
# derivitative of N
dNf := unapply(diff(Nf(x, k), x), x, k);
# calculation
evalf(simplify(int(k^2/(sa+(ss-sa)*x/L)+k*(Za+(Zs-Za)*x/L)*dNf(x, k), x = 0 .. L)));
P := unapply(%, k)
;

Plotting of the function works fine and one finds a minimum which I want to calculate numerically for different parameter sets.

So I need a time efficient way of doing it. May be:

A) evalf(minimize(P(k), k));
B) fsolve(diff(P(k), k) = 0, k = 0 .. 2*10^6);
C) NLPSolve?

﻿