kill(all)$

Maxima : intro computation ,base and acid, 'appendix 7a,version 1.0'
peter.vlasschaert@gmail.com, 03/01/2019

function representation for f ' and f ''
==============================

load packages
=============

load(lrats)$
load(facexp)$

Menu : Numeric :Set displayed  Precision
===================================

fpprintprec : 6;

data
====

vol:[20.5,21.00,21.50,22.00,22.50];

ph:[11.59,11.60,11.62,11.68,11.72];

find : f ' ,f ''
=========

average ( = mean value)  , fm1
====================

fm1(vol,v1) := block ([v1:[]],
ll : length(vol),
for i:1  thru ll -1 step 1
      do(l1:(vol[i+1]+vol[i])/2,
      v1:endcons(l1,v1)),
return(v1))$

w1:fm1(vol,v1);

f ' = Δph/Δv
==========

fderv1(vol,ph,fd1):= block([fd1:[] ],
 ll:length(vol) ,
  for i:1  thru ll -1 step 1
      do(l2:(ph[i+1]-ph[i])/(vol[i+1]-vol[i]),
     fd1:endcons(l2,fd1)),
return(fd1))$     

fd1:fderv1(vol,ph,fd1);

average ( = mean value)  , fm2
====================

fm2(vol,v2) := block ([v2:[]],
ll : length(vol),
for i:1  thru ll -1 step 1
      do(l1:(vol[i+1]+vol[i])/2,
      v2:endcons(l1,v2)),
return(v2))$

w2:fm2(w1,v2);

rem: 'w1' already one less than 'vol' 
==============================
reason : ll -1

f '' = Δ(Δph/Δv)/Δv
===============

fderv2(vol,fd1,fd2):= block([fd2:[] ],
 ll:length(vol) ,
  for i:1  thru ll-1 step 1
      do(l2:(fd1[i+1]-fd1[i])/(vol[i+1]-vol[i]),
     fd2:endcons(l2,fd2)),
return(fd2))$     

fd2:fderv2(w1,fd1,fd2);

'-------------------------------------------------------------------------------'