# Question:How do you define and use derivatives of a function you define yourself?

## Question:How do you define and use derivatives of a function you define yourself?

Maple

Maple people:

The title is the question.  I defined a function in Maple, which works.  I am trying to get Maple to compute its derivatives.  I want to save the derivatives as functions.  Here is a code snippet.  The function itself works.  I have uploaded the worksheet.  Mapleprimes seems to have copied the entire worksheet into this question when I uploaded the worksheet.

[begin code snippet]

d:=proc(B)
M:=Matrix(3):
for i from 1 to 3 do
for j from 1 to 3 do
M(i,j):=m(B,i,j):
end do:
end do:
Determinant(M):
end proc:
Warning, `M` is implicitly declared local to procedure `d`
Warning, `i` is implicitly declared local to procedure `d`
Warning, `j` is implicitly declared local to procedure `d`
d(B);
1
------ exp(-3 B) exp(-5 B) exp(-6 B)
823200

11
- ----- exp(-3 B) exp(-5 B) exp(6 B)
19600

33
+ ----- exp(-3 B) exp(5 B) exp(-6 B)
19600

9
- ---- exp(-3 B) exp(5 B) exp(6 B)
1400

1
+ --- exp(3 B) exp(-5 B) exp(-6 B)
980

11
- --- exp(3 B) exp(-5 B) exp(6 B)
210

99
+ ---- exp(3 B) exp(5 B) exp(-6 B)
1120

3
- -- exp(3 B) exp(5 B) exp(6 B)
80

d1:=D(d);
D(d)
d1(B);
D(d)(B)
d1(0); #doesn't work
D(d)(0)
d12dtry:=x->diff(M(x),x);
d
x -> --- M(x)
dx
d12try(1); #doesn't work
d12try(1)

[end code snippet]

 restart:
 > with(LinearAlgebra):
 > n:=3:
 > mu[1]:=1: mu[2] := 2: mu[3]:=4:
 > g[1]:=3: g[2]:=5;g[3]:=6;
 (1)
 > m:=(B,i,j)-> exp(-B*g[j])/(g[j]+mu[i])-exp(B*g[j])/(g[j]-mu[i]):
 >
 > d:=proc(B)   M:=Matrix(3):   for i from 1 to 3 do      for j from 1 to 3 do       M(i,j):=m(B,i,j):      end do:   end do:  Determinant(M): end proc:
 >
 (2)
 > d1:=D(d);
 (3)
 > d1(B);
 (4)
 > d1(0); #doesn't work
 (5)
 > d12dtry:=x->diff(M(x),x);
 (6)
 > d12try(1); #doesn't work
 (7)
 > value(%);
 (8)
 >

:

﻿