[Question]
  [
Consider a grid from \$(0,0)\$ in the bottom-left corner to \$(m,n)\$ in the top-right corner. You begin at \$(0,0)\$, and can only move in one of these three ways:
* Directly north \$(+0, +1)\$,
* Directly east \$(+1, +0)\$, or
* Directly north-east \$(+1, +1)\$
How many different paths are there from your start at \$(0,0)\$ to \$(m, n)\$?
For example, if you're trying to reach \$(3, 3)\$, there are 63 different paths:
[![enter image description here](https://i.stack.imgur.com/uFhat.png)](https://i.stack.imgur.com/uFhat.png)
This value is given by \$D(m,n)\$, the [Delannoy numbers](https://en.wikipedia.org/wiki/Delannoy_number). One formula for these numbers is
$$D(m,n) = \begin{cases}
1, & \text{if } m = 0 \text{ or } n = 0 \\
D(m-1, n) + D(m-1, n-1) + D(m, n-1), & \text{otherwise}
\end{cases}$$
Others can be found on the Wikipedia page
---
You are to take two non-negative integers \$n\$ and \$m\$ and output \$D(m,n)\$. This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest code in bytes wins
You may input and output in [any convenient manner](https://codegolf.meta.stackexchange.com/questions/2447/default-for-code-golf-input-output-methods), and you may assume that no part of the calculation exceeds your language's integer maximum.
## Test cases
```
[m, n] -> D(m, n)
[5, 8] -> 13073
[5, 7] -> 7183
[3, 9] -> 1159
[8, 6] -> 40081
[8, 8] -> 265729
[1, 7] -> 15
[7, 0] -> 1
[11, 6] -> 227305
[0, 4] -> 1
```
And all possible outputs for \$0 \le n, m \le 7\$:
```
[m, n] -> D(m, n)
[0, 0] -> 1
[0, 1] -> 1
[0, 2] -> 1
[0, 3] -> 1
[0, 4] -> 1
[0, 5] -> 1
[0, 6] -> 1
[0, 7] -> 1
[0, 8] -> 1
[1, 0] -> 1
[1, 1] -> 3
[1, 2] -> 5
[1, 3] -> 7
[1, 4] -> 9
[1, 5] -> 11
[1, 6] -> 13
[1, 7] -> 15
[1, 8] -> 17
[2, 0] -> 1
[2, 1] -> 5
[2, 2] -> 13
[2, 3] -> 25
[2, 4] -> 41
[2, 5] -> 61
[2, 6] -> 85
[2, 7] -> 113
[2, 8] -> 145
[3, 0] -> 1
[3, 1] -> 7
[3, 2] -> 25
[3, 3] -> 63
[3, 4] -> 129
[3, 5] -> 231
[3, 6] -> 377
[3, 7] -> 575
[3, 8] -> 833
[4, 0] -> 1
[4, 1] -> 9
[4, 2] -> 41
[4, 3] -> 129
[4, 4] -> 321
[4, 5] -> 681
[4, 6] -> 1289
[4, 7] -> 2241
[4, 8] -> 3649
[5, 0] -> 1
[5, 1] -> 11
[5, 2] -> 61
[5, 3] -> 231
[5, 4] -> 681
[5, 5] -> 1683
[5, 6] -> 3653
[5, 7] -> 7183
[5, 8] -> 13073
[6, 0] -> 1
[6, 1] -> 13
[6, 2] -> 85
[6, 3] -> 377
[6, 4] -> 1289
[6, 5] -> 3653
[6, 6] -> 8989
[6, 7] -> 19825
[6, 8] -> 40081
[7, 0] -> 1
[7, 1] -> 15
[7, 2] -> 113
[7, 3] -> 575
[7, 4] -> 2241
[7, 5] -> 7183
[7, 6] -> 19825
[7, 7] -> 48639
[7, 8] -> 108545
[8, 0] -> 1
[8, 1] -> 17
[8, 2] -> 145
[8, 3] -> 833
[8, 4] -> 3649
[8, 5] -> 13073
[8, 6] -> 40081
[8, 7] -> 108545
[8, 8] -> 265729
```
  
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 8 bytes
```
Żc@Ɱ,PṚḄ
```
[Try it online!](https://tio.run/##y0rNyan8///o7mSHRxvX6QQ83Dnr4Y4WIP/w8sP7Etz//zcFAA "Jelly – Try It Online")
Because I couldn't tolerate Jelly being tied with APL.
Again uses the formula
$$D(m,n) = \sum\_{k=0}^{\min(m,n)} \binom{m}{k} \binom{n}{k} 2^k$$
but takes `m` and `n` as two separate arguments. This is essentially a port of [my own Dyalog Extended answer](https://codegolf.stackexchange.com/a/225208/78410).
```
Żc@Ɱ,PṚḄ    Dyadic link. Left arg: m, Right arg: n
Ż           Inclusive range 0..m (if m > n, the extra nCk terms will be zero)
    ,       [m, n]
 c@Ɱ        A table containing [[mC0 .. mCk], [nC0 .. nCk]]
     P      Vectorized product; [mC0 * nC0 .. mCk * nCk]
      ṚḄ    Reverse and unbinary; effectively sum mCk * nCk * 2^k for k = 0..m
```
Alternative 8 bytes, taking a single argument `[m, n]`:
```
c€ṂŻ$PṚḄ
```
[Try it online!](https://tio.run/##y0rNyan8/z/5UdOahzubju5WCXi4c9bDHS3/j@7WObwv4XA7UAKI3P//NwUA "Jelly – Try It Online")
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 19 [bytes](https://github.com/abrudz/SBCS)
```
⊢/(1,2+/+\)⍣⎕⊢1,⎕⍴1
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT/@f9qhtQvX/R12L9DUMdYy09bVjNB/1Ln7UuwsoZKjzqHfro94thv9r/z/qmKGX9qh3hYIBUHCzBQA "APL (Dyalog Unicode) – Try It Online")
A full program that takes `n` and `m` on two separate lines. TIO link has an equivalent dfn for demonstration purposes.
### How it works
It goes through the table of Delannoy numbers row by row. Start with the zeroth row of `m + 1` ones, and calculate the next row n times:
```
Previous row: 1 a b c d e ...
Next row:     1 A B C D E ...
```
From the recurrence relation, we can observe the following:
```
A = 1 + 1 + a = 2 + a = (1) + (1 + a)
B = A + a + b = 2 + 2a + b = (1 + a) + (1 + a + b)
C = B + b + c = 2 + 2a + 2b + c = (1 + a + b) + (1 + a + b + c)
...
```
Therefore, we can compute the next row by taking the cumulative sum `+\`, then pairwise sum `2+/`, then prepending a 1. The desired value of `D(m,n)` is at the end of the row, so we apply `⊢/` at the end.
---
# [APL (Dyalog Extended)](https://github.com/abrudz/dyalog-apl-extended), 13 bytes
```
⊥⍤⌽(×/…⍤⌊!\,)
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNrShJzUtJTfn//1HX0ke9Sx717NU4PF3/UcMyMKdLMUZH83/ao7YJj3r7HnU1H1pv/Kht4qO@qcFBzkAyxMMz@P@jjhl6aY96VygY6Dzq3WwBAA "APL (Dyalog Extended) – Try It Online")
A straightforward implementation of the Wikipedia formula, also used by multiple other answers.
```
⊥⍤⌽(×/…⍤⌊!\,)  ⍝ Input: left arg = m, right arg = n
         !\    ⍝ Outer product by nCk function...
      …⍤⌊      ⍝ k = 0..min(n,m)
           ,   ⍝ [m, n]
    ×/         ⍝ Row-wise product; mCk * nCk for each k
⊥⍤⌽            ⍝ Reverse and evaluate in base 2; sum of mCk * nCk * 2^k
```
[Answer]
# [Haskell](https://www.haskell.org/), 37 bytes
```
m#n|m*n<1=1|i<-m-1,j<-n-1=i#n+m#j+i#j
```
[Try it online!](https://tio.run/##NY1BroIwEED3PcUkmAjfaewUsZjfegJvQFyQ0Gj5tBBkQ@Ld@RXibl7evJln/fqzXbcsPglv/xM0GXo7zT0nbDUPnIxLwsEn7cEl7eJrF0zTM0gd9pnmr6EO6dHs@T7Tu@vDTjcXLIPOTpXHcDejrRtwv/M67JqxH0BCzIfRhSmNP42ZMW7inDH4HF@qAqG8A78C5ULl7MNqZUVlxBzhsmkqLqwqEc4rnoQoaeWtludCybhA35wKVikEsUEU9E2lVLmIViCcNvsP "Haskell – Try It Online")
Straightforward recursive implementation.
# [Haskell](https://www.haskell.org/), 41 bytes
```
0#n=1
m#n|j<-m-1=2*sum(map(j#)[0..n])-j#n
```
[Try it online!](https://tio.run/##NY3BisMgFEX3fsUDC9VBO2qamtLYL5g/kCyEyIyZaEKSLgrz7xmb0M3jHc693B83//q@X1eBk5Eo4vTX1TxyadTH/IgkupF0mFpxOqWG8g6nNbqQTDsgIIENtObz6BL5NEd@pPXh/u2Xr5A8gt4vNrLUmMm7FsLtuT2HdhpGUJDr4xTSQvKiMU@WkyxfnCiC18BqSwZVA/wOshC6QC/WG2tZZSwYXHctyyuyFYPLhmchKrnx3laXUqsckO@6LJHVDMQOWch3VSldiGwFg/Nu/wE "Haskell – Try It Online")
Based on a curious formula I found, but not quite short enough.
$$
D(m,n)=2\sum\_{k=0}^{n-1}D(m-1,k)+D(m-1,n).
$$
[Answer]
# [J](http://jsoftware.com/), 24 21 19 bytes
```
2#.[:*/,!~/],i.@-@]
```
[Try it online!](https://tio.run/##TcyxCsIwEAbg3ac4dShKmt4lTS8JFAqCk5OrdBKLuvgGvno8TYodAvd//PmfaaOrCfoIFShAiPJqDYfz6ZjMVl/ivlHrdzOqhx7qYUy71e16f4GDCXw@ySJb6JfE5GfhUiIXRKxIyNIiehLyQl0m0zk2odi87iTTYkgiS8TyxbDFX4X@O98OSmzTBw "J – Try It Online")
-3 thanks to the base 2 trick from [Bubbler's APL answer](https://codegolf.stackexchange.com/a/225208/15469).
-2 thanks to Bubbler.
Just this formula translated into J:
$$
D(m,n) = \sum ^ {\min(m, n)} \_ {k=0} \binom m k \binom n k 2^k
$$
[Answer]
# [R](https://www.r-project.org/), 45 bytes
```
function(m,n,o=0:m,`$`=choose)m$o%*%(n$o*2^o)
```
[Try it online!](https://tio.run/##K/rvkpqTmJeXX2n7P600L7kkMz9PI1cnTyff1sAqVydBJcE2OSM/vzhVM1clX1VLVSNPJV/LKC5fE65Pw1THQlNBWUHXTsHQ2MDc@D8A "R – Try It Online")
Similar but independently-derived approach to pajonk's answer (version 2) - [check it out](https://codegolf.stackexchange.com/a/225223/95126) - but here maximizing [R](https://www.r-project.org/)'s vectorization & vector operators to avoid needing any loop.
[Answer]
# [Python 3](https://docs.python.org/3/), 49 bytes
```
D=lambda m,n:m*n<1or D(m-1,n)+D(m-1,n-1)+D(m,n-1)
```
[Try it online!](https://tio.run/##K6gsycjPM/7/38U2JzE3KSVRIVcnzypXK8/GML9IwUUjV9dQJ09TG8rQNQQzwYz/BUWZeSUaLhoGOgaamv8B "Python 3 – Try It Online")
Uses the formula specified in question, and looks like `m*n` works instead of `m and n`
-1 byte saved thanks to @CommandMaster forgot that we could use short-circuit evaluation
-4 again for @DingleDooper, genius one line short circuit
[Answer]
# [Factor](https://factorcode.org/) + `math.combinatorics math.unicode`, 65 bytes
```
[| m n | m n min [0,b] [| k | m k nCk n k nCk k 2^ * * ] map Σ ]
```
[Try it online!](https://tio.run/##PY@7DsIgGIV3n@LMxph6rZfExcG4uBgnUxNEVNICFehgap/G9/GVEEttCPDxncPwXwm1SrvDfrvbLCCIvfepEmcuidecGmSKkszUSYiVvjAdsJCcqgsLD03kjRkQY5T/lmtm7TPXXFoY9iiYpD5cdsoOUGKCGaqG4oZGmDc0w7Slf2/Q9mJEfzdoixHGnip3fEFAIpyCSxyj3jmB12ktU8i1382dYnhC16/Ej5Dj80biSlRhhtVPGUto2ndf "Factor – Try It Online")
Inputs are re-used so often it's one of the odd times local variables are the terse way to go. Since recursion is generally verbose in Factor, I've gone with the formula
$$D(m,n) = \sum\_{k=0}^{\min(m,n)} \binom{m}{k} \binom{n}{k} 2^k$$
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 38 bytes
```
m=>g=n=>m*n?g(n--,m--)+g(n)+g(n,m++):1
```
[Try it online!](https://tio.run/##HcbBCoAgDADQ39nSBdGpYHbxR8JECt0io9@36PJ4x/qsNVz7eZPoFpvnVtglFnalkyWBENlChObrjy3G4Dy0oFI1xz5rAg8jwoTYXg "JavaScript (Node.js) – Try It Online")
Uses the specified formula, so will reach recursion limit on larger testcases.
-1 byte thanks to @dingledooper
-3 bytes thanks to @Arnauld
[Answer]
# [R](https://www.r-project.org/), 52 bytes
```
D=function(x)"if"(all(x),D(x-1:0)+D(x-1)+D(x-0:1),1)
```
[Try it online!](https://tio.run/##RcxNCoNADIbhfU8R7GZCIyQzjhmFduVFiiAIYqG04O2nZX5wlfDw8r1jnO7Ld58/62s3Bzbr0pjntv1fmszRysh4S08@PAqSYJzMbDxBQLxC@wBxrO5SUAuqhGyOYKih@CFZIOiLdcxBKtZF23u1OZVzUnwSJeAqOZFzzlp1nDsm6GoXfw "R – Try It Online")
Using the recursive formula and taking input as a tuple (thanks to [@Dominic](https://codegolf.stackexchange.com/users/95126/dominic-van-essen)).
Taking input as two arguments:
### [R](https://www.r-project.org/), 55 bytes
```
D=function(m,n)"if"(m*n,D(m-1,n)+D(m-1,n-1)+D(m,n-1),1)
```
[Try it online!](https://tio.run/##PYw7CsMwEET7nGJxGilZwa5keeUiqXSTgMGFFQjJ@RX9cDfz5jGfnONj@6XXd38ndWDS075N6rgljOowXMB9BMMttoCsc1QeIegrmCewI3GXRqQT4VCBQ1iHwn4tICAsHcxEgTsZL3bxYqvE5w37UgWBRq0jnxfWiqNqEMI8jPwH "R – Try It Online")
Using the closed-form expression from [Wikipedia](https://en.wikipedia.org/wiki/Delannoy_number#Delannoy_numbers) results in 56 bytes with a loop, but take a look at [@Dominic's 45 byte approach](https://codegolf.stackexchange.com/a/225244/55372)!
### [R](https://www.r-project.org/), ~~68~~ ~~61~~ ~~58~~ 56 bytes
```
function(m,n,`$`=choose){for(k in 0:m)F=F+m$k*n$k*2^k;F}
```
[Try it online!](https://tio.run/##RYzBCoJAEIbvPcVAHrQmmNl13bWwk/gYIUiSiLtgdYqefXNT9DCH/5uPb/Rl4du3bV6ds/GAFuuoLpqHc8978mndGPfQWaDzkFRFdRyi/mCnE7f@Un19GSsEk@zhdAWWpOXuT/RMNJsAJEK@KKzyCRiEbAYpkeGZLBWRKS2CxGuG1TQ1Ai0zPHlNCKElBYMQ0s2gzfc/ "R – Try It Online")
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 31 bytes
```
Total//@DiamondMatrix@Table@##&
```
[Try it online!](https://tio.run/##TZJPa9tAEMXv@hRGCaUFmUizf0Vi40Jy6KFQiG@qDqrrNAuyZBQFDCGf3ZX27a729kajmd@bmT014@vx1Izm0FxfNtd9Pzbt3d3u0TSnvvv7sxkHc9ntmz/tcXdz8@X62FfJh8n6z01ruuN9YjbpS/qwNffJr8F0Y2XW233/dDkPx7c303eVqbN09TXN@iz9ltZJ9jGXZc9T1@7f02UcmsNY3T4fBnMef3Tn9xGZLP3dpevt97adqtfbFXT9WV@rPFvl9fytSGZdRJoizSLNIy0iLSOtIq29LiJW4VnMarCE1WApq8EqrXYsFDsYqh0N5Q431VPEI88TVlMoJw8kZEDkKAFSIgBS4zeHdB0ck085FkGZhyqrKXCYh0pmA7dSKm0EKjF0AJYp9ABXKDQBV7OpC4@43HNLqymMxMMlCSmAGSHnxtWI3IpJ41eQiVwfoJnkU1ZEbBEeEQIKKxRh0wwRX3AinFdqZkM3thQIQVeFy7qFs1xNsYzwMuCRoHA06fF2lXJZ@jyf9HwAZbh26bLu3qUmtIIBnuezexUZUMGAsAEtD0V5B/Z8yjvASpV3gBlV2D@QylvgWrLSxm4HuRbzu9ORBx08KBvQ8jy192AfjQ4vwN5RhytgsdqbcHPqsIcFChckhaLyPw "Wolfram Language (Mathematica) – Try It Online")
Returns `{1}` instead of `1` when the second argument is 0. To fix this, ~~+4~~ +3 bytes: [Try it online!](https://tio.run/##TZJPa9tAEMXv/hRGKaUFmUizf0Vqo4Jz6KFQiG@qDqrjpAuyZBQVDCGf3ZX27a729kajmd@bmT0349/TuRnNsbm9bG/7sjz0Y9Pe35d705z77vlnMw7mWh6aP@2pvLv7fNv31erdpP3HtjXd6WFltslL8m1nHla/BtONldnsDv3j9TKc3t5M31WmTpP1lyTt0@RrUq/S97ksfZq6dq@P13FojmP16ek4mMv4o7v8G5FJk99dstl9b9uperNbQ9cf9a3K0nVWz9/y1azzSFOkWaR5pEWkZaRVpLXXecTKPYtZDZawGixlNViF1Y6FYgdDtaOh3OGmeop45HnCagrl5IGEDIgcJUBKBEBq/OaQroNj8inHIijzUGU1BQ7zUMls4FZKhY1AJYYOwDKFHuAKhSbgajZ14RGXe25hNYWReLgkIQUwI@TcuBqRWzFp/AoykesDNJN8yoqILcIjQkBhhSJsmiHiC06E80rNbOjGlgIh6Cp3WbdwlqkplhFeBjwSFI4mPd6uUi5Ln@eTng@gDNcuXNbdu9CEVjDAs2x2ryIDKhgQNqDloSjvwJ5PeQdYqfIOMKMK@wdSeQtcS1bY2O0g02J@dzryoIMHZQNanqf2Huyj0eEF2DvqcAUsVnsTbk4d9rBA4YKkUFT8Bw "Wolfram Language (Mathematica) – Try It Online")
From Wikipedia:
> 
> The Delannoy number \$D(m,n)\$ also counts... the number of cells in an *m*-dimensional von Neumann neighborhood of radius *n*...
> 
> 
> 
Generates a matrix representing a radius-`m` dimension-`n` von Neumann neighborhood, and counts the number of cells.
---
Some other approaches:
**Multinomial formula, ~~38~~ 36 bytes**
```
Multinomial[k,#-k,#2-k]~Sum~{k,0,#}&
```
[Try it online!](https://tio.run/##bZRNi9swEIbv/hXGW0oLMtgj68NsEyh0Dz0UCtmb64MJ2VYksUPWgYWQ/euprVdSRNpD4J2MZp7RzMj7bvyz2XejWXfXl8X1x2k3mn7Ym27XbNlDPv0o37bvq9P@/bxlBXu4fLx@G5rkbNhwWexMv3lMzCJ7yb4szWPy82j6sTH58nl4ejscN6@vZugb07Is/ZSxgWWfszZh5zmMrcbp8O@nt/HYrcfmw2p9NIfxe384jfCw7Fef5cuvu90UnS9T6PbSXhvBUt3O/5W8UDyZbWVtVerJ5Cyt4S5FnTSapdKaVVHo0tqIJikUTQdKH16KpFEsLWBMjtKHEileTN6CpZX3FtHJSZeRpkjzSMexItIy0irSOlQSV@VZ3GqwhNVgKavBwvUcC8EOxu8uXgbcFE8RjzxPWE0hnDyQ4AGxQgiQEgaQGscc0mVwzErYuQUo91BlNQUO91CJSbuWznPknkocGYDlCjnAFQpJwNV8ylJF3Mpza6spXKkKkyS4AOYEn7uuhuVaTBpHldshlwdoLqvarm5gi7BEMCi0UIROc1jVDSfCeKXGW3DXluLfp3H/cmSElwEPB4WhSY@3rZS3ps/3k54PoAzTrp3XzbvWhFQ6fozxc1OhALxDui2K8hXY8SlfAVqqfAW4owr9B1L5EioteW1t14NCi3nvdFSDDjUoa9BtPbWvwS6NDhtg56jDFNDY/3x01D00/gr9BQ "Wolfram Language (Mathematica) – Try It Online")
**Direct recursion, 46 bytes**
```
f=If[1##>0,f[#-1,#2]+f[#-1,#2-1]+f[#,#2-1],1]&
```
[Try it online!](https://tio.run/##bZRNi9swEIbv/hXGKaWlMlijT7NNoNA97K2we3N9CCFpBVk7ZF1YWPa3p7ZeSRFpb@94NHrmS37eTr/3z9vJ7baXy2H9cOj4arVp2KFb1ZytqP8SVc29hmK8/3j5PnbFm2Pj@/rohv1d4dbVofq6cXfFj7Mbps7Vm6fx/vV03r@8uHHoXM@q8lPFRlZ9rvqCvS1h7HGaD/@6f53O293UfXjcnd1pehhOfyZ4WPVzqOrNt@Nxjq43JXT/3l86xUrbL9@4aIwoFtt423A7m4KVLdxctUVnWam9KZvGcm8jmrQyNB/gMZyrojOsbGDMDh5DiYxoZm/DShm9TXZy1jzTlGmR6TxWZVpn2mTapkzyrCJLeA2W8hos4zVYKC@wEBxg4qZwnnBzPGU8ijzlNaVwikCCB0SJECA1DCAtjgVkuCEwpfJzS1ARocZrShwRoRqTDi1d5igilQRuAFYY3AGuMrgEXCvmW2TGlZHbek2pJJkmSXABLAi@UK6FFVpMFkdN2KFwD9BCy9avbmKrtEQwKLVQpU4LWPKKU2m82uIthLK1@vdp3L4cneF1wsNBaWg64n0r9bXpS3068gHUadpt8IZ5t5Zwlc0fY/7cTEoA75Cui2JiBn58JmaAlpqYAWo0qf9AmpiCtFq03g49aKxa9s5mOdiUg/EGXdfTxhz80ti0AX6ONk0Bjf3PT8fcQvO/0F8 "Wolfram Language (Mathematica) – Try It Online")
**Generating function, 46 bytes**
```
SeriesCoefficient[1/(2-x y),{x,1,#},{y,1,#2}]&
```
[Try it online!](https://tio.run/##bZRNi9swEIbv/hXGW8ouKNQaWR9mm0Bp99BbIb25PoTgbAXZOCQuZAn57amtV1JE2lPeyWjmGc2M/LYafndvq8GuV9fN/LrsDrY7fu27zcaubbcbGv7pkWan/P2JnU@Ms4cLO79Pv3RpP16/9U12tqy/zLd21z1ndl5sis8L@5z9ONgx2M4WP/uX0/7QHY@23zW2ZUX@WLCeFU9Fm7HzFMaWw3j49eU0HFbrofmwXB/sfvi@2/8Z4GHFr10xW3zZbsfo2SKHbi/ttZEsN@30HxelFtlka2drbkZTsLyGm8s6awzLlTOrsjTc2YgmJTWNB3gI5zJrNMtLGKODh1AiLcrRW7K8Ct4yOTlqnmhKtEh0GisTrRKtE21iJWlVgSWcBks6DZZ2Gixcz7MQ7GHi7uI84sZ4SngUeNJpiuEUgAQPiBVCgFQwgDQ45pE@g2dW0s0tQkWAaqcpckSAKkzat3SaowhUEsgArNDIAa7USAKuEWOWKuFWgVs7TfFKVZwkwQWwIPj8dQ0s32IyOKr9Dvk8QAtV1W51I1vGJYJBsYUydlrAqm44GcerDN6Cv7aS/z6N@5ejEryKeDgoDk0FvGulujV9up8KfABVnHbtvX7etSGkMuljTJ@bjgXgHdJtUXSowI1PhwrQUh0qwB117D@QOpRQGSVqZ/selEZOe2eSGkysQTuDbutpQg1uaUzcADdHE6eAxv7no6PvoelX6C8 "Wolfram Language (Mathematica) – Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E),  ~~10~~ 8 bytes
```
WÝ€cPR2β
```
[Try it online!](https://tio.run/##yy9OTMpM/f8//PDcR01rkgOCjM5t@v8/2lTHPBYA "05AB1E – Try It Online")
-2 thanks to the base 2 trick from Bubbler's APL answer.
Uses the direct formula from wikipedia.
```
W     push the minimum of m,n
Ý     push the range [0,min(n,m)]
€     and map each number to
 c    the input choose that number, vectorizes
P     product
R     reverse
2β    convert from base 2
```
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 22 bytes
```
≔Ｅ⊕Ｎ¹θＦＮＵＭθ⁺κ⊗↨…θλ¹Ｉ⊟θ
```
[Try it online!](https://tio.run/##XUw5DsIwEOzzCpdryRSICqUC01CA/IWNY0jE@ogPJF5vbEpGGmk0l14wao9U6yml9enghgGuTkdjjctmbjqUfC92MhE4F2zfuPFxePjI/kLWttJbi26GTTBFJcFLsIsvE7WnMyYD8qPJyMWH3qDfX8M4qLi6DBJTBtXDbtZ6YMe6e9MX "Charcoal – Try It Online") Link is to verbose version of code. Explanation: Uses @Delfad0r's curious formula.
```
≔Ｅ⊕Ｎ¹θ
```
Input `n` and create an array of `1`s representing `D(0,k)` for `0<=k<=n`.
```
ＦＮ
```
Repeat `m` times.
```
ＵＭθ⁺κ⊗↨…θλ¹
```
Add twice the cumulative sum to each element. (I have to use base `1` conversion because `Sum` returns `None` for an empty list. It was still shorter than adding the inclusive and exclusive cumulative sums.)
```
Ｉ⊟θ
```
Output `D(m,n)`.
[Answer]
# [PowerShell Core](https://github.com/PowerShell/PowerShell), ~~79~~ 67 bytes
```
filter f($a){if($a*$_){(--$a|f $_)+(--$_|f $a)+($a+1|f $_)}else{1}}
```
[Try it online!](https://tio.run/##RY1bC4JAEIXf/RXzsIHmCol0AQmEnruQjxFhNpKxXnKVAt3fbjsaBbvsd86eOVMWL6zkHYVw4qLCvk9SUWMFickiq03pmbKL1ZqOw6IuAc028YU40swi2x19hUJi6yrVB6bBA9PjoM/Cs0jMOaw4uN5sqbVhQQcTaA0AlnFgub74LjGu8QZr3eXTT4WyETXpjBbk2jsdwk0j6yLbXx86fQ6oAiBs4hilpOh3yMHnv9IfQtuhaeQdcT7y8bdmnCVXGar/AA "PowerShell Core – Try It Online")
* Saved 1 byte by using a filter
* Saved 3 bytes replacing the `-and` by a `*`
* Saved a whopping 12 bytes thanks to [Zaelin Goodman](https://codegolf.stackexchange.com/users/99902/zaelin-goodman)
[Answer]
# [Julia 1.0](http://julialang.org/), ~~47~~ 30 bytes
```
m%n=m*n<1||~-m%n+~-m%~-n+m%~-n
```
[Try it online!](https://tio.run/##yyrNyUw0rPj/P1c1zzZXK8/GsKamThfI0QaRdbp52mDyf1p@kUKmQmaegoGVuY5CFpTFxVlQlJlXkpOnoaSSqaOgkmWloKKRqZqlqaTJlZqX8h8A "Julia 1.0 – Try It Online")
Boring port of the formula.
* -12 bytes thanks to @Sisyphus!
* -5 bytes thanks to @MarcMush!
[Answer]
# [K (ngn/k)](https://codeberg.org/ngn/k), 18 bytes
```
{0/x(+':+\)/1,y#1}
```
[Try it online!](https://ngn.codeberg.page/k#eJxVkEsOwjAMRPc5RRALQCA1juvYyVlYc4QKhLg7GRuQkJpP3eeZcW/jWZb78XwY5+tpoctjT6+UtpF3PW35tozryFtKlPN8fiu2v/13gOV5kbkUle7laONgJA4FK1GuqK1ONd9Nos9baBWwGlybNarQrQyW1Y1EvcWYwXaXc4wrqGaYopr3VbfitvbJItw0dbGgmjG+CsyV8EJcFLrIM6PBMrSCso47dUO+tRTDf5hzIj9yhaFLfSFr3DMVE5+NFEMivKcKv1D6QLk20drfXT9KOA==)
Port of [my APL answer](https://codegolf.stackexchange.com/a/225208/78410) that does not use the binomial coefficient built-in. See the linked answer for the explanation of how it computes Delannoy numbers using just cumulative sum `+\` and windowed sums `+':`.
```
{0/x(+':+\)/1,y#1}  x, y: two input integers
            1,y#1   (y+1) copies of 1; the 0th row of the grid of Delannoy numbers
   x(     )/        do x times:
     +':+\          calculate the next row
 0/                 base 0 = extract the last item
```
[Answer]
# Java, 62 bytes
```
int f(int m,int n){return n*m<1?1:f(m--,n-1)+f(m,n)+f(m,n-1);}
```
[Try it online!](https://tio.run/##dUzLDoIwEDzDV@yx1ZaEg9GIxi/wxNF4qLwC0oW0BWMI314XwtU5zO7O7EyjRiWb/O374dXWGWStshbuqkaYQiBsunXK0Ri7OgdNLkudqbF6PEGZyvIpDNaMhitg8VkLGE/WhgXp17pCR93gop5yrkWmo5IdxInTV/DXPvKtZPYkQ8kW1mJh5JMp3GAQcKcv8S0@l0xLKVDGfE@rwG3Qncx@9j8)
[Answer]
# [Pari/GP](http://pari.math.u-bordeaux.fr/), 45 bytes
```
d(m,n)=if(m*n,d(m-1,n)+d(m-1,n-1)+d(m,n-1),1)
```
[Try it online!](https://tio.run/##LYtBCsMwDATvfUncyqC148g5@DGF0pJDQuj/IdWK3mY02vP53fLnvK7XtMuRxvae9vshbhnujz9kBAYIEt@b9DQGqlq90czN0ClVVia01aXL4jKrdoRxVZZmhRExQ3M0USKPiEkpVpVFZWb5AQ "Pari/GP – Try It Online")
[Answer]
# [Ruby](https://www.ruby-lang.org/), 44 bytes
```
f=->m,n{m*n<1?1:f[m-1,n]+f[m-1,n-=1]+f[m,n]}
```
[Try it online!](https://tio.run/##KypNqvz/P81W1y5XJ686VyvPxtDe0CotOlfXUCcvVhvK0LU1BLOBQrX/CxTSoo11jGP/AwA "Ruby – Try It Online")
Using the formula in the question
[Answer]
# [Desmos](https://desmos.com/calculator), 38 bytes
```
D(m,n)=\sum_{k=0}^mnCr(m,k)nCr(n,k)2^k
```
[Try It On Desmos!](https://www.desmos.com/calculator/kxgyyd9zi2)
[Try It On Desmos! (Prettified)](https://www.desmos.com/calculator/6tppbob2vv)
Implements the formula$$D(m,n)=\sum\_{k=0}^{\min(m,n)}\binom mk\binom nk2^k$$with the observation that \$\min(m,n)\$ can be replaced with \$m\$(or \$n\$).
[Answer]
# [J](http://jsoftware.com/), 17 bytes
```
]{(2&+/\@[&0>:$#)
```
[Try it online!](https://tio.run/##y/qvpKegnqZga6Wuo2CgYAXEunoKzkE@bv9jqzWM1LT1Yxyi1QzsrFSUNf9rcqUmZ@QrpClp69cpZOpZ/gcA "J – Try It Online")
Uses the same algorithm as my [19-byte APL solution](https://codegolf.stackexchange.com/a/225208/78410). I randomly came across the problem again and realized J has multiple tricks to shorten the code, so it is actually shorter than APL. Also beats [Jonah's J solution](https://codegolf.stackexchange.com/a/225212/78410) which uses the direct formula.
Takes `m` and `n` as left and right argument respectively.
`2&+/` part comes from [here](https://codegolf.stackexchange.com/a/206979/78410).
```
]{(2&+/\@[&0>:$#)   NB. left arg = m; right arg = n
   xxxxxxxxxyyyy    NB. This part is a hook, so it evaluates as m x (y n)
            >:$#    NB. n+1 copies of 1
   xxxxx@[&0        NB. A trick idiom for "repeat x m times to (y n)"
   2&+/\   NB. Evaluate next row of Delannoy matrix:
       \   NB. For each prefix,
   2&+/    NB. Convert [a, b, ..., m, n] to 2a+2b+...+2m+n
]{         NB. Extract the last element, which is at index n (0-based)
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 13 bytes
```
ṂŻc@ⱮµPæ«J$SH
```
[Try it online!](https://tio.run/##ASUA2v9qZWxsef//4bmCxbtjQOKxrsK1UMOmwqtKJFNI////WzMsIDld "Jelly – Try It Online")
Using the direct formula from Wikipedia.
```
Ṃ              Minimum
 Ż             [0, 1, ..., min(m, n)]
    Ɱ          For each in the input
  c@           swapped args: input choose k
     P         product (vectorizes)
      æ«J$     bitshift by [1, 2, 3, ...]
          S    sum
           H   halve (since J starts at 1)
```
# [Jelly](https://github.com/DennisMitchell/jelly), 14 bytes
```
_45Bs2¤ß€Sµ1Ȧ?
```
[Try it online!](https://tio.run/##ASQA2/9qZWxsef//XzQ1QnMywqTDn@KCrFPCtTHIpj////9bMywgOV0 "Jelly – Try It Online")
Could use some work, probably.
```
             ? If
            Ȧ  all (m != 0, n != 0)
          S    take the sum of
       ß       this link
        €      applied to each of
_              (m, n) -
 45Bs2¤        [1, 0], [1, 1], [0, 1]
 45B           45 as binary: [1, 0, 1, 1, 0, 1]
    s2         sliced into size 2 chunks
           1   Otherwise, 1
```
[Answer]
# [Red](http://www.red-lang.org), 73 bytes
```
f: func[m n][either(m * n)= 0[1][(f m - 1 n)+(f m - 1 n - 1)+ f m n - 1]]
```
[Try it online!](https://tio.run/##RY7BCoMwDIbvPsWPJ53ILNvUDbaH2DX0IDZFwVYp@vxO7brlEL6Ej@R3rNY3K5KrfkAvtiUDK4n7uWOXGJxg0ycKEpISDYMcYttkf957mmGfD5bbpdFx03bwpyLsdUMdoPJwwd1DjTLA1xHBqVAcIERwClwjSZPr7QyaGnUeWM8w46DgWC0tH09RIs5fMX6Cj1dt4T4 "Red – Try It Online")
Uses the formula from the problem description.
[Answer]
# MMIX, 64 bytes (16 instrs)
Recursive, so takes forever.
```
00000000: dc020001 52020003 e3020001 f8030000  ṇ£¡¢R£¡¤ẉ£¡¢ẏ¤¡¡
00000010: fe020004 c1040000 27050101 f303fff9  “£¡¥Ḋ¥¡¡'¦¢¢ṙ¤”ż
00000020: 27060001 f304fff7 c1050100 22030304  '©¡¢ṙ¥”ẋḊ¦¢¡"¤¤¥
00000030: f304fff4 22030304 f6040002 f8040000  ṙ¥”ṡ"¤¤¥ẇ¥¡£ẏ¥¡¡
```
Disassembled:
```
delannoy    MOR   $2,$0,$1
            PBNZ  $2,0F
            SETL  $2,1
            POP   3,0           // if(!(m && n)) return(1,m,n)
0H          GET   $2,rJ
            SET   $4,$0
            SUBU  $5,$1,1
            PUSHJ $3,delannoy   // $3,$4,$5 = delannoy(m,n-1) = f(m,n-1),m,n-1
            SUBU  $6,$0,1       // $6 = m - 1
            PUSHJ $4,delannoy   // $4,$5,$6 = delannoy(n-1,m-1)
            SET   $5,$1
            ADDU  $3,$3,$4      // $3 += $4
            PUSHJ $4,delannoy   // $4,$5,$6 = delannoy(n-1,m)
            ADDU  $3,$3,$4
            PUT   rJ,$2
            POP   4,0           // return(f(m,n), m, n)
```
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~45~~ 43 bytes
```
D(m,n){m=m*n?D(m-1,n)+D(m-1,--n)+D(m,n):1;}
```
[Try it online!](https://tio.run/##bVFhT4MwEP2@X3EhIQFWYoExmIh@UH@FWwwpZRJtt1CixIW/Ll4LI5uRlOPdvXuv7cH8PWPD8OQIIt2TyIUnHzDxA0yXI/D9EWLlNsj6oZYtiKKWjgZFs2cE2FvReJ5OPt3FaQH4aLLlqn0VLzvI4RQTwBURSM0KCCQY8UP77FogR0FqOjYE1kaAmBq8uujn3ZGzlpejIohoghskQRpp6xi1K0pT3CNcx0mIaRCbncMwiaiGk5U5PkbO3nmDXqDdrG33HG67zSO@sUXgMo@sSVkdGjBzqGXJO5TRbIJ3oOpvfqic8xndm6ngzZUMlkvT7cI4tPO9BDpNwzP8Lrui5ZmW/9IK6fF/Xdc51ueJ/RUeG2ypHMsuCdgl@Pc62mor8eqCgCSgyDwiled8N7n3i374YdVHsVeD//UL "C (gcc) – Try It Online")
*Saved 2 bytes thanks to [mousetail](https://codegolf.stackexchange.com/users/91213/mousetail)!!!*
[Answer]
# [Pyt](https://github.com/mudkip201/pyt), 19 bytes
```
Đ↓0⇹ŘĐ1⇹«04Ș⇹ɐćÁ*·+
```
[Try it online!](https://tio.run/##K6gs@f//yIRHbZMNHrXvPDrjyARDIH1otYHJiRlAxskJR9oPN2od2q79/3@0kY5JLAA "Pyt – Try It Online")
Direct implementation of the formula on Wikipedia
```
Đ↓                     implicit input; Đuplicate on stack; get minimum of inputs (k)
  0⇹Ř                  create Řange [0,1,...,k]
     Đ1⇹«              2^k
         04Ș⇹          stack manipulation to have the range on top, then the input
             ɐć        for ɐll pairs of values in the two arrays, nćr 
               Á*      multiply the two nCr lists element-wise
                 ·     dot-product with the powers of 2
                  +    remove that pesky 0; implicit print
```
[Answer]
# [Arturo](https://arturo-lang.io), ~~50~~ ~~48~~ 47 bytes
```
f:$[m,n][(0=m*n)?->1[+ +f m-1n-1f m n-1f m-1n]]
```
[Try it](http://arturo-lang.io/playground?cRSQyZ)
]