Skip to main content
67 votes

The Pedant's Cosine

Operation Flashpoint scripting language, 165 157 bytes ...
Steadybox's user avatar
  • 16.5k
26 votes

Derivative of a product

Pip, 15 bytes aRL#aJ'+<>#aJ'' Attempt This Online! Explanation ...
DLosc's user avatar
  • 38.8k
23 votes
Accepted

Find the rate of change at a point on a polynomial

Mathematica, 6 bytes #'@#2& (Beat THAT, MATL and 05AB1E) The first argument must be a polynomial, with # as its variable ...
JungHwan Min's user avatar
  • 13.8k
14 votes

​P​i​ =​= ​3​.​2​

Python + scipy, 92 bytes from scipy.integrate import* lambda p:2/p*quad(lambda x:(x/x**p+(1-x)**(1-p))**(1/p),0,1)[0] Formula is from this math.SE question.
orlp's user avatar
  • 39.1k
13 votes

The Pedant's Cosine

05AB1E, 14 11 bytes FIn(NmN·!/O Try it online! Explanation ...
Emigna's user avatar
  • 53k
13 votes

The Lehmer-Comtet sequence

Haskell, 77 75 bytes, no differentiation builtins x@(a:b)&y@(c:d)=a*c:zipWith(+)(b&y)(x&d) s=1:s&(1:scanl(*)1[-1,-2..]) (s!!) Try it online! How ...
Anders Kaseorg's user avatar
12 votes

Derivative of a product

Python, 54 bytes lambda s:((l:=len(s))*(l*"'"+-~l*(s+"+")))[-~l*~l::-l] Attempt This Online! Python, 56 bytes lambda s:((l:=-~len(s))*(l*(s+"+")+-~l*"'")...
loopy walt's user avatar
  • 16.7k
11 votes

​P​i​ =​= ​3​.​2​

MATL, 31 bytes 0:1e-3:1lyG^-lG/^v!d|G^!slG/^sE Try it online! Or verify all test cases. Explanation This generates the x,y coordinates of one quarter of the ...
Luis Mendo's user avatar
  • 105k
11 votes

Compute Dickman

Python, 141 bytes g=lambda x,p=[1]+[0]*99,I=2,z=0,i=0:x<1and sum(a*(1-x)**~-(i:=i+1)for a in p)or g(x-1,[p[0]-sum(A:=[(z:=(z+w)/I)/(i:=i+1)for w in p])]+A,I+1) ...
Bubbler's user avatar
  • 78.2k
10 votes

Write a Sine-Deriving Machine

Python, 42 bytes from math import* lambda x,n:sin(x+pi/2*n) Uses the fact that differentiating shifts the function by pi/2 ...
xnor's user avatar
  • 146k
10 votes

​P​i​ =​= ​3​.​2​

Wolfram Language (Mathematica), 49 46 45 bytes 3 bytes saved thanks to alephalpha. 1 byte saved thanks to att. \!\(2N@∫\_0\%1\@+++(a^-#-1)^(1-#)\%#a\)& Try it ...
LegionMammal978's user avatar
10 votes

The Pedant's Cosine

Mathematica, 49 41 39 31 bytes Sum[(-#^2)^k/(2k)!,{k,0,#2-1}]& Old, more "fun" version: (39 bytes) ...
GamrCorps's user avatar
  • 7,592
10 votes

The Pedant's Cosine

MATL, 14 bytes U_iqE:2ep/YpsQ Try it online! Or verify all test cases. Explanation with example All numbers have double precision (this is the default). Consider ...
Luis Mendo's user avatar
  • 105k
10 votes

Approximate definite integrals using Riemann sums

R, 69 65 63 57 bytes function(a,b,n,k,f,w=(b-a)/n)sum(sapply(a+w*(1:n-k),f))*w Try it online! Takes k=FALSE for right-hand ...
Giuseppe's user avatar
  • 28.8k
10 votes

Derivative of a product

C (clang), 69 64 59 bytes -10 thanks to @Noodle9 and @ceilingcat l;f(char*a){for(l=0;a[l];)printf("+%.*s'%s"+!l,++l,a,a+l);} Try it online!
a stone arachnid's user avatar
9 votes

The Pedant's Cosine

Jelly, 12 11 bytes ḶḤµ⁹*÷!_2/S Try it online! How? ...
Jonathan Allan's user avatar
9 votes
Accepted

Definite integral of polynomial functions

Jelly, \$\frac {30} 7 = 4.29\$ ÷J$ŻUḅI Try it online! Takes the polynomial as a list of coefficients in little-endian format (i.e. the example is ...
caird coinheringaahin g's user avatar
8 votes

Find the rate of change at a point on a polynomial

MATL, 8 6 bytes yq^**s Input is: array of exponents, number, array of coefficients. Try it online! Or verify all test cases: 1, 2 3, 4, 5. Explanation Consider ...
Luis Mendo's user avatar
  • 105k
8 votes

The Pedant's Cosine

Jelly, 22 bytes -*ð×ø⁹*⁸²ð÷ø⁸Ḥ! ⁸R’Ç€S This is a full program which takes n as the first argument and x as the second. Explanation: ...
fireflame241's user avatar
  • 16.3k
8 votes

Solve a separable differential equation

Python 2, 123 122 bytes def f(p,P):R=[[[a/-~b,b+1]for a,b in F]for F in P];a,b=map(lambda F,x:sum(a*x**b for a,b in F),R,p);R[1]+=[a-b,0],;print R Try it online! ...
Surculose Sputum's user avatar
8 votes

Derivative of a product

Brainfuck, 87 84 bytes ...
Jiří's user avatar
  • 1,885
8 votes

Derivative of a product

Python, 47 bytes lambda s:"+".join(s.replace(c,c+"'")for c in s) Attempt This Online! How it works: ...
Samathingamajig's user avatar
7 votes

Find the rate of change at a point on a polynomial

Julia, 45 42 40 37 bytes f(p,x)=sum(i->prod(i)x^abs(i[2]-1),p) This is a function that acceps a vector of tuples and a number and returns a number. The ...
Alex A.'s user avatar
  • 24.7k
7 votes

The Pedant's Cosine

Python, 54 bytes f=lambda x,n,t=1,p=1:n and t+f(x,n-1,-t*x*x/p/-~p,p+2) If using Python 2, be sure to pass x as a float, not an integer, but I my understanding ...
Neil's user avatar
  • 174k
7 votes

The Lehmer-Comtet sequence

Mathematica, 19 bytes D[x^x,{x,#-1}]/.x->1& -18 bytes from @Not a tree
ZaMoC's user avatar
  • 24.9k
7 votes

Polynomial Laplace transform

Haskell, 25 bytes zipWith(*)$scanl(*)1[1..] Try it online! Pretty straightforward: Generates the list of factorials ...
xnor's user avatar
  • 146k
6 votes

Solve the Laplace equation

Matlab, 84, 81.2 79.1 bytes = 113 - 30% function u=l(f,N,a,b);A=toeplitz([2,-1,(3:N)*0]);A([1,2,end-[1,0]])=eye(2);u=[a,f((1:N-2)/N)*(N-1)^2,b]/A;plot(u) Note ...
flawr's user avatar
  • 43.9k
6 votes

Write a Sine-Deriving Machine

C (gcc), 30 bytes #define f(x,n)sin(x+n*acos(0))
orlp's user avatar
  • 39.1k
6 votes

​P​i​ =​= ​3​.​2​

PARI/GP, 48 43 bytes It's easy after @orlp has found the formula, and @alephalpha's version saves 5 bytes: p->2*intnum(u=0,1,(1+(u^-p-1)^(1-p))^(1/p)) To add ...
Christian Sievers's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible