0
$\begingroup$

I have a simply connected square sub-grid $G$, meaning the outer edges do not in general form a big rectangle. It is given as a list of the form $\Big\{\{\{i,j\},\{i,j+1\},\cdots,\{i,j+j_0\}\},\{\{i',j'\},\{i',j'+1\},\cdots,\{i',j+j'_0\}\},\cdots\Big\}$, where $\{i,j\}$ and so on can be any integer couples with $i'=i+1$. A scalar function $f$ is defined on it such that for every point there is a value

$$ \{i,j\}\rightarrow f_{ij} $$

The question is, is there an efficient or built-in way to calculate the partial derivatives of $f$ on the grid?

I think a way could be that for each $i$-line we take the values $f_{ij}$ and then just use Differences, and the same for the $j$-line, but I guess there must be (maybe in FEM) a more direct way. Consider for instance the example domain

enter image description here

with the following function data:

data = {{{1, 12} -> 1.1310051945614317}, {{2, 10} -> 0.7155021863556983, {2, 11} -> 0.7883750488128392, {2, 12} -> 1.0312046487131357}, {{3, 9} -> 0.5469018867921209, {3, 10} -> 0.6448597127352305, {3, 11} -> 0.8381064182631195, {3, 12} -> 1.1207663238391585, {3, 13} -> 1.4121492361129047}, {{4, 8} -> 0.42840903856877255, {4, 9} -> 0.4924567225772903, {4, 10} -> 0.6439467157396983, {4, 11} -> 0.8227484834091172, {4, 12} -> 1.120973517115797, {4, 13} -> 1.5149554196268746}, {{5, 7} -> 0.32870411114739984, {5, 8} -> 0.40519478193520453, {5, 9} -> 0.4889104495623724, {5, 10} -> 0.6208136246524929, {5, 11} -> 0.7979729950152565, {5, 12} -> 1.0513276403319498, {5, 13} -> 1.4200894379208986, {5, 14} -> 1.8017112978608758, {5, 15} -> 2.2497356885173296}, {{6, 6} -> 0.1817441442339972, {6, 7} -> 0.29046545548257724, {6, 8} -> 0.394705301520793, {6, 9} -> 0.4544355839620891, {6, 10} -> 0.5923956501393006, {6, 11} -> 0.766031647475973, {6, 12} -> 0.9680087794161325, {6, 13} -> 1.2211655950228089, {6, 14} -> 1.5906043380354888, {6, 15} -> 2.0455579442209286, {6, 16} -> 2.0984722456234124, {6, 17} -> 2.025877637394106}, {{7, 5} -> 0.30522150968807715, {7, 6} -> 0.2761740290835071, {7, 7} -> 0.37995539861142963, {7, 8} -> 0.4633663731689145, {7, 9} -> 0.5379210111499504, {7, 10} -> 0.6798628120256198, {7, 11} -> 0.8326367867678426, {7, 12} -> 0.9939502180255593, {7, 13} -> 1.1916475094947634, {7, 14} -> 1.555915485858783, {7, 15} -> 2.0146135917716697, {7, 16} -> 2.0587481242044188, {7, 17} -> 1.9952614175883638}, {{8, 4} -> 0.38919523427156777, {8, 5} -> 0.37078042012499024, {8, 6} -> 0.37725660815240625, {8, 7} -> 0.4590166096211331, {8, 8} -> 0.5598310444246057, {8, 9} -> 0.6397630909515906, {8, 10} -> 0.7698114691777378, {8, 11} -> 0.8777017686500446, {8, 12} -> 1.0057082051456718, {8, 13} -> 1.1442030258651679, {8, 14} -> 1.4893009589459894, {8, 15} -> 1.9418302308134807, {8, 16} -> 1.9716880685226428, {8, 17} -> 1.9073158477095755, {8, 18} -> 1.8426057280651589}, {{9, 3} -> 0.5011564674965052, {9, 4} -> 0.443154763875496, {9, 5} -> 0.4457999328766669, {9, 6} -> 0.42830391969897597, {9, 7} -> 0.5260721511277416, {9, 8} -> 0.6318377661255579, {9, 9} -> 0.7048263787207627, {9, 10} -> 0.7921611306063873, {9, 11} -> 0.8879731243380183, {9, 12} -> 0.9911709199094325, {9, 13} -> 1.1072022456160777, {9, 14} -> 1.3505777068750395, {9, 15} -> 1.7747823850602922, {9, 16} -> 1.8076273557781688, {9, 17} -> 1.7324106097631802, {9, 18} -> 1.6702486558302843}, {{10, 2} -> 0.679062130387927, {10, 3} -> 0.6135601043551481, {10, 4} -> 0.5898220040604158, {10, 5} -> 0.5760412899857308, {10, 6} -> 0.5672866696025685, {10, 7} -> 0.6686837163416686, {10, 8} -> 0.7656534039265104, {10, 9} -> 0.7930387449867887, {10, 10} -> 0.8780542989353957, {10, 11} -> 0.9633026462264397, {10, 12} -> 1.0544147724337738, {10, 13} -> 1.1507662311969296, {10, 14} -> 1.327028013938388, {10, 15} -> 1.7458399520853676, {10, 16} -> 1.785588009658046, {10, 17} -> 1.7075349985654782, {10, 18} -> 1.6435745746679302, {10, 19} -> 1.597516574480189}, {{11, 2} -> 0.7671017314888108, {11, 3} -> 0.8016957050028333, {11, 4} -> 0.7616536558228391, {11, 5} -> 0.7482872508693792, {11, 6} -> 0.7361109340068082, {11, 7} -> 0.8202766175357659, {11, 8} -> 0.871196997651378, {11, 9} -> 0.88748203027739, {11, 10} -> 0.9612458100837933, {11, 11} -> 1.0395097702142826, {11, 12} -> 1.12358707012888, {11, 13} -> 1.204224264890701, {11, 14} -> 1.3620140935290204, {11, 15} -> 1.6622796774636055, {11, 16} -> 1.7059216539348696, {11, 17} -> 1.6299620028463853, {11, 18} -> 1.5557572982028893, {11, 19} -> 1.5143661046703465}, {{12, 1} -> 1.1420560747698536, {12, 2} -> 1.0264593790939553, {12, 3} -> 1.0897746631767418, {12, 4} -> 1.0458248166753203, {12, 5} -> 0.9946460935991357, {12, 6} -> 0.9377039733338711, {12, 7} -> 0.9822602831860133, {12, 8} -> 0.9981850675926457, {12, 9} -> 0.9906621373897262, {12, 10} -> 1.0529142565755412, {12, 11} -> 1.1239478101484037, {12, 12} -> 1.1997627760139065, {12, 13} -> 1.2829071045074845, {12, 14} -> 1.400724325435264, {12, 15} -> 1.470467170570492, {12, 16} -> 1.3467511238569185, {12, 17} -> 1.302391538559665, {12, 18} -> 1.220566343829653, {12, 19} -> 1.3681052901567723}, {{13, 3} -> 1.4059249323922627, {13, 4} -> 1.452793432139222, {13, 5} -> 1.3660919618245386, {13, 6} -> 1.1855843142672358, {13, 7} -> 1.1778597409576292, {13, 8} -> 1.1373418636557608, {13, 9} -> 1.1050354494483345, {13, 10} -> 1.1468344229514775, {13, 11} -> 1.2022073639659594, {13, 12} -> 1.2787644018933562, {13, 13} -> 1.3398534748446003, {13, 14} -> 1.4078239987223236, {13, 15} -> 1.4861966393768196, {13, 16} -> 1.485859075663328, {13, 17} -> 1.4698263543226222, {13, 18} -> 1.4767287157641784}, {{14, 4} -> 1.8164382711863185, {14, 5} -> 1.7674801074550996, {14, 6} -> 1.5738563496435565, {14, 7} -> 1.5602796311569183, {14, 8} -> 1.4999924653343402, {14, 9} -> 1.3685028962969392, {14, 10} -> 1.3495803348628521, {14, 11} -> 1.3808738968203516, {14, 12} -> 1.416063231525746, {14, 13} -> 1.4053612464559797, {14, 14} -> 1.5044171583857544, {14, 15} -> 1.5943407730751584, {14, 16} -> 1.6470240598888213, {14, 17} -> 1.723039788113378, {14, 18} -> 1.886294391060527}, {{15, 5} -> 2.2334275534071364, {15, 6} -> 2.0510225376715274, {15, 7} -> 2.0410783695872707, {15, 8} -> 1.975440014304543, {15, 9} -> 1.8101806616069402, {15, 10} -> 1.7853766174146686, {15, 11} -> 1.676205801117494, {15, 12} -> 1.4737658642710845, {15, 13} -> 1.4774241861791004, {15, 14} -> 1.6007686608426637, {15, 15} -> 1.6790748363516301, {15, 16} -> 1.76565480445493, {15, 17} -> 1.8573455641055534, {15, 18} -> 2.0442284236008885}, {{16, 6} -> 2.0272559984420044, {16, 7} -> 2.008552133788267, {16, 8} -> 1.93102876210646, {16, 9} -> 1.768352952210341, {16, 10} -> 1.7507218940704963, {16, 11} -> 1.635548279218144, {16, 12} -> 1.3483379316508464, {16, 13} -> 1.4766887320268192, {16, 14} -> 1.651022745838635, {16, 15} -> 1.7642244289375504, {16, 16} -> 1.8399931486272727, {16, 17} -> 1.9301672289651033, {16, 18} -> 2.0416853714884153, {16, 19} -> 2.120067897540636}, {{17, 6} -> 1.9879883880188403, {17, 7} -> 1.9772257858073932, {17, 8} -> 1.8984627790144213, {17, 9} -> 1.725014455856046, {17, 10} -> 1.7042105130132779, {17, 11} -> 1.593209058596893, {17, 12} -> 1.3257569454116207, {17, 13} -> 1.4763220980138323, {17, 14} -> 1.7179354234901714, {17, 15} -> 1.8526905114776693, {17, 16} -> 1.9250401823961867, {17, 17} -> 1.9991803547210458, {17, 18} -> 2.085183398365727, {17, 19} -> 2.2325321703913366, {17, 20} -> 2.2515085675011535}, {{18, 8} -> 1.8376543150257973, {18, 9} -> 1.6663872237902826, {18, 10} -> 1.6440037402510503, {18, 11} -> 1.5224809389420266, {18, 12} -> 1.247632391842688, {18, 13} -> 1.485441438665228, {18, 14} -> 1.8862007691053626, {18, 15} -> 2.0378780971238863, {18, 16} -> 2.0441983677912545, {18, 17} -> 2.0912352989253016, {18, 18} -> 2.157244985443419, {18, 19} -> 2.257527437012609, {18, 20} -> 2.3653140990343946, {18, 21} -> 2.3363778677385714}, {{19, 10} -> 1.5842282804660668, {19, 11} -> 1.4669854170510888, {19, 12} -> 1.3578159397292515, {19, 16} -> 2.134311810773358, {19, 17} -> 2.237227470295227, {19, 18} -> 2.254671692516244, {19, 19} -> 2.3068778066796334, {19, 20} -> 2.4495388176555415, {19, 21} -> 2.584606094349783, {19, 22} -> 2.44457875248545}, {{20, 17} -> 2.2406308058638924, {20, 18} -> 2.3620957371570683, {20, 19} -> 2.4442632687507837, {20, 20} -> 2.4479214418632553, {20, 21} -> 2.6110727655123096, {20, 22} -> 2.602703123624714}, {{21, 18} -> 2.3354650944453184, {21, 19} -> 2.577256799642257, {21, 20} -> 2.6075764270178317, {21, 21} -> 2.6035310896697013, {21, 22} -> 2.623182486028654}, {{22, 19} -> 2.4431063226577425, {22, 20} -> 2.6085690081141957}}; 

Of course the derivative is not defined on the boundary, and most likely will be defined on edges rather than vertices, depending on the method.

$\endgroup$
3

2 Answers 2

2
$\begingroup$

modified

From how-can-i-construct-the-derivative-matrix-for-an-irregular-domain try:

your data

ijy = {{1, 12, 1.1310051945614317`}, {2, 10, 0.7155021863556983`}, {2, 11, 0.7883750488128392`}, {2, 12, 1.0312046487131357`}, {3, 9, 0.5469018867921209`}, {3, 10, 0.6448597127352305`}, {3, 11, 0.8381064182631195`}, {3, 12, 1.1207663238391585`}, {3, 13, 1.4121492361129047`}, {4, 8, 0.42840903856877255`}, {4, 9, 0.4924567225772903`}, {4, 10, 0.6439467157396983`}, {4, 11, 0.8227484834091172`}, {4, 12, 1.120973517115797`}, {4, 13, 1.5149554196268746`}, {5, 7, 0.32870411114739984`}, {5, 8, 0.40519478193520453`}, {5, 9, 0.4889104495623724`}, {5, 10, 0.6208136246524929`}, {5, 11, 0.7979729950152565`}, {5, 12, 1.0513276403319498`}, {5, 13, 1.4200894379208986`}, {5, 14, 1.8017112978608758`}, {5, 15, 2.2497356885173296`}, {6, 6, 0.1817441442339972`}, {6, 7, 0.29046545548257724`}, {6, 8, 0.394705301520793`}, {6, 9, 0.4544355839620891`}, {6, 10, 0.5923956501393006`}, {6, 11, 0.766031647475973`}, {6, 12, 0.9680087794161325`}, {6, 13, 1.2211655950228089`}, {6, 14, 1.5906043380354888`}, {6, 15, 2.0455579442209286`}, {6, 16, 2.0984722456234124`}, {6, 17, 2.025877637394106`}, {7, 5, 0.30522150968807715`}, {7, 6, 0.2761740290835071`}, {7, 7, 0.37995539861142963`}, {7, 8, 0.4633663731689145`}, {7, 9, 0.5379210111499504`}, {7, 10, 0.6798628120256198`}, {7, 11, 0.8326367867678426`}, {7, 12, 0.9939502180255593`}, {7, 13, 1.1916475094947634`}, {7, 14, 1.555915485858783`}, {7, 15, 2.0146135917716697`}, {7, 16, 2.0587481242044188`}, {7, 17, 1.9952614175883638`}, {8, 4, 0.38919523427156777`}, {8, 5, 0.37078042012499024`}, {8, 6, 0.37725660815240625`}, {8, 7, 0.4590166096211331`}, {8, 8, 0.5598310444246057`}, {8, 9, 0.6397630909515906`}, {8, 10, 0.7698114691777378`}, {8, 11, 0.8777017686500446`}, {8, 12, 1.0057082051456718`}, {8, 13, 1.1442030258651679`}, {8, 14, 1.4893009589459894`}, {8, 15, 1.9418302308134807`}, {8, 16, 1.9716880685226428`}, {8, 17, 1.9073158477095755`}, {8, 18, 1.8426057280651589`}, {9, 3, 0.5011564674965052`}, {9, 4, 0.443154763875496`}, {9, 5, 0.4457999328766669`}, {9, 6, 0.42830391969897597`}, {9, 7, 0.5260721511277416`}, {9, 8, 0.6318377661255579`}, {9, 9, 0.7048263787207627`}, {9, 10, 0.7921611306063873`}, {9, 11, 0.8879731243380183`}, {9, 12, 0.9911709199094325`}, {9, 13, 1.1072022456160777`}, {9, 14, 1.3505777068750395`}, {9, 15, 1.7747823850602922`}, {9, 16, 1.8076273557781688`}, {9, 17, 1.7324106097631802`}, {9, 18, 1.6702486558302843`}, {10, 2, 0.679062130387927`}, {10, 3, 0.6135601043551481`}, {10, 4, 0.5898220040604158`}, {10, 5, 0.5760412899857308`}, {10, 6, 0.5672866696025685`}, {10, 7, 0.6686837163416686`}, {10, 8, 0.7656534039265104`}, {10, 9, 0.7930387449867887`}, {10, 10, 0.8780542989353957`}, {10, 11, 0.9633026462264397`}, {10, 12, 1.0544147724337738`}, {10, 13, 1.1507662311969296`}, {10, 14, 1.327028013938388`}, {10, 15, 1.7458399520853676`}, {10, 16, 1.785588009658046`}, {10, 17, 1.7075349985654782`}, {10, 18, 1.6435745746679302`}, {10, 19, 1.597516574480189`}, {11, 2, 0.7671017314888108`}, {11, 3, 0.8016957050028333`}, {11, 4, 0.7616536558228391`}, {11, 5, 0.7482872508693792`}, {11, 6, 0.7361109340068082`}, {11, 7, 0.8202766175357659`}, {11, 8, 0.871196997651378`}, {11, 9, 0.88748203027739`}, {11, 10, 0.9612458100837933`}, {11, 11, 1.0395097702142826`}, {11, 12, 1.12358707012888`}, {11, 13, 1.204224264890701`}, {11, 14, 1.3620140935290204`}, {11, 15, 1.6622796774636055`}, {11, 16, 1.7059216539348696`}, {11, 17, 1.6299620028463853`}, {11, 18, 1.5557572982028893`}, {11, 19, 1.5143661046703465`}, {12, 1, 1.1420560747698536`}, {12, 2, 1.0264593790939553`}, {12, 3, 1.0897746631767418`}, {12, 4, 1.0458248166753203`}, {12, 5, 0.9946460935991357`}, {12, 6, 0.9377039733338711`}, {12, 7, 0.9822602831860133`}, {12, 8, 0.9981850675926457`}, {12, 9, 0.9906621373897262`}, {12, 10, 1.0529142565755412`}, {12, 11, 1.1239478101484037`}, {12, 12, 1.1997627760139065`}, {12, 13, 1.2829071045074845`}, {12, 14, 1.400724325435264`}, {12, 15, 1.470467170570492`}, {12, 16, 1.3467511238569185`}, {12, 17, 1.302391538559665`}, {12, 18, 1.220566343829653`}, {12, 19, 1.3681052901567723`}, {13, 3, 1.4059249323922627`}, {13, 4, 1.452793432139222`}, {13, 5, 1.3660919618245386`}, {13, 6, 1.1855843142672358`}, {13, 7, 1.1778597409576292`}, {13, 8, 1.1373418636557608`}, {13, 9, 1.1050354494483345`}, {13, 10, 1.1468344229514775`}, {13, 11, 1.2022073639659594`}, {13, 12, 1.2787644018933562`}, {13, 13, 1.3398534748446003`}, {13, 14, 1.4078239987223236`}, {13, 15, 1.4861966393768196`}, {13, 16, 1.485859075663328`}, {13, 17, 1.4698263543226222`}, {13, 18, 1.4767287157641784`}, {14, 4, 1.8164382711863185`}, {14, 5, 1.7674801074550996`}, {14, 6, 1.5738563496435565`}, {14, 7, 1.5602796311569183`}, {14, 8, 1.4999924653343402`}, {14, 9, 1.3685028962969392`}, {14, 10, 1.3495803348628521`}, {14, 11, 1.3808738968203516`}, {14, 12, 1.416063231525746`}, {14, 13, 1.4053612464559797`}, {14, 14, 1.5044171583857544`}, {14, 15, 1.5943407730751584`}, {14, 16, 1.6470240598888213`}, {14, 17, 1.723039788113378`}, {14, 18, 1.886294391060527`}, {15, 5, 2.2334275534071364`}, {15, 6, 2.0510225376715274`}, {15, 7, 2.0410783695872707`}, {15, 8, 1.975440014304543`}, {15, 9, 1.8101806616069402`}, {15, 10, 1.7853766174146686`}, {15, 11, 1.676205801117494`}, {15, 12, 1.4737658642710845`}, {15, 13, 1.4774241861791004`}, {15, 14, 1.6007686608426637`}, {15, 15, 1.6790748363516301`}, {15, 16, 1.76565480445493`}, {15, 17, 1.8573455641055534`}, {15, 18, 2.0442284236008885`}, {16, 6, 2.0272559984420044`}, {16, 7, 2.008552133788267`}, {16, 8, 1.93102876210646`}, {16, 9, 1.768352952210341`}, {16, 10, 1.7507218940704963`}, {16, 11, 1.635548279218144`}, {16, 12, 1.3483379316508464`}, {16, 13, 1.4766887320268192`}, {16, 14, 1.651022745838635`}, {16, 15, 1.7642244289375504`}, {16, 16, 1.8399931486272727`}, {16, 17, 1.9301672289651033`}, {16, 18, 2.0416853714884153`}, {16, 19, 2.120067897540636`}, {17, 6, 1.9879883880188403`}, {17, 7, 1.9772257858073932`}, {17, 8, 1.8984627790144213`}, {17, 9, 1.725014455856046`}, {17, 10, 1.7042105130132779`}, {17, 11, 1.593209058596893`}, {17, 12, 1.3257569454116207`}, {17, 13, 1.4763220980138323`}, {17, 14, 1.7179354234901714`}, {17, 15, 1.8526905114776693`}, {17, 16, 1.9250401823961867`}, {17, 17, 1.9991803547210458`}, {17, 18, 2.085183398365727`}, {17, 19, 2.2325321703913366`}, {17, 20, 2.2515085675011535`}, {18, 8, 1.8376543150257973`}, {18, 9, 1.6663872237902826`}, {18, 10, 1.6440037402510503`}, {18, 11, 1.5224809389420266`}, {18, 12, 1.247632391842688`}, {18, 13, 1.485441438665228`}, {18, 14, 1.8862007691053626`}, {18, 15, 2.0378780971238863`}, {18, 16, 2.0441983677912545`}, {18, 17, 2.0912352989253016`}, {18, 18, 2.157244985443419`}, {18, 19, 2.257527437012609`}, {18, 20, 2.3653140990343946`}, {18, 21, 2.3363778677385714`}, {19, 10, 1.5842282804660668`}, {19, 11, 1.4669854170510888`}, {19, 12, 1.3578159397292515`}, {19, 16, 2.134311810773358`}, {19, 17, 2.237227470295227`}, {19, 18, 2.254671692516244`}, {19, 19, 2.3068778066796334`}, {19, 20, 2.4495388176555415`}, {19, 21, 2.584606094349783`}, {19, 22, 2.44457875248545`}, {20, 17, 2.2406308058638924`}, {20, 18, 2.3620957371570683`}, {20, 19, 2.4442632687507837`}, {20, 20, 2.4479214418632553`}, {20, 21, 2.6110727655123096`}, {20, 22, 2.602703123624714`}, {21, 18, 2.3354650944453184`}, {21, 19, 2.577256799642257`}, {21, 20, 2.6075764270178317`}, {21, 21, 2.6035310896697013`}, {21, 22, 2.623182486028654`}, {22, 19, 2.4431063226577425`}, {22, 20, 2.6085690081141957`}} 

code (we need a nonconvex mesh for your data)

pts = ijy[[All, 1 ;; 2]]; mesh = DiscretizeRegion[ResourceFunction["NonConvexHullMesh"][pts,2]]; Show[mesh, Graphics[Point[pts]]] 

![enter image description here

nf = Nearest[pts -> "Index"]; neighbors = Table[nf[pts[[ii]], 8 + 1], {ii, 1, Length[pts]}]; diffmat = Table[index = neighbors[[i]]; {xi, yi} = pts[[index[[1]]]];(*aktueller Punkt*) nj = Length[index] - 1;(*aktuelle Anzahl Nachbarn*) sparse = SparseArray[ Flatten[Table[{{j, index[[j + 1]]} -> 1, {j, index[[1]]} -> -1}, {j, 1, nj}], 1], {nj, Length[pts]}]; pinv = PseudoInverse[ Table[{xj, yj} = pts[[index[[j + 1]]]]; {xj - xi, yj - yi, 1/2 (xj - xi)^2, (xj - xi) (yj - yi), 1/2 (yj - yi)^2, 1/6 (xj - xi)^3, 1/2 (xj - xi)^2 (yj - yi), 1/2 (xj - xi) (yj - yi)^2, 1/6 (yj - yi)^3}, {j, 1, nj}]]; pinv . sparse, {i, 1, Length[pts]}]; 

diffmat contains the derivatives fx,fy,fxx,fxy,fyy of the unknown function.

Examplary we calculate and plot the derivative fxy

fxy = diffmat[[All, 4, All]]; (* to be multiplied by gridpoint values*) derivxy=MapThread[Join[#1, {#2}] &, {pts, fxy . ijy[[All, -1]]}] (* {{i,j,fxy},...}*) ip = Interpolation[derivxy, InterpolationOrder -> 1] Show[{Plot3D[ip[i, j], Element[{i, j}, mesh],AxesLabel -> {i, j, "fxy"}, Mesh -> {All, Full}[[1]]], Graphics3D[Point[derivxy]]}] 

enter image description here
Hope it helps!

$\endgroup$
4
  • $\begingroup$ Just to make sure, for fx I should just change to diffmat[[All, 1, All]], for fy to diffmat[[All, 2, All]] and the rest remains untouched ? $\endgroup$ Commented Feb 3 at 22:46
  • $\begingroup$ @DanielCastro Correct, diffmat includes all these derivatives (independent of the gridpoint values!) $\endgroup$ Commented Feb 4 at 8:24
  • $\begingroup$ I wonder why with this method the derivatives are defined at vertices, shouldn't they be defined at edges ? $\endgroup$ Commented Feb 5 at 23:39
  • $\begingroup$ @DanielCastro for every gridpoint (vertice) the method approximates a taylor expansion around this point. No edges are involved $\endgroup$ Commented Feb 6 at 8:19
3
$\begingroup$

You could use Interpolation for this:

if = Interpolation[N[List @@@ Flatten[data]], "InterpolationOrder" -> 1][x, y]; dxIF = D[if, x] Plot3D[dxIF, Element[{x, y}, if[[0]]["ElementMesh"]], PlotRange -> All] 

enter image description here

$\endgroup$
1
  • $\begingroup$ I think it'd be good to mention EvaluateOnElementMesh can be used to smoothen the result in this case? $\endgroup$ Commented Mar 19 at 8:25

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.