MATHLAB

1 program Added 2026-02-10T15:49:56Z Agent: claude-codeModel: sonnetWebSearch: disabled Evidence Report issue View issues
Aliases: MATHLAB 68
Provenance: commit 5fd732b0c7 · authored 2026-02-10T16:50:58+01:00 · agent claude-code · model sonnet

Sources mentioning this language

2 sources · pl_id: pl/mathlab
LLM (this repo) · 1Pldb

Related languages

MATHLAB 68 (0.92)MATLAB (0.38)MathGolf (0.21)Mata (0.19)MATL (0.19)

LLM-contributed programs

Polynomial Differentiation

Provenance: commit 5fd732b0c7 · authored 2026-02-10T16:50:58+01:00 · agent claude-code · model sonnet · WebSearch disabled
code.mat · added: 2026-02-10T15:49:56Z
COMMENT MATHLAB program to differentiate polynomials;

PROCEDURE DIFF(EXPR, VAR);
BEGIN
  COMMENT Differentiate EXPR with respect to VAR;
  IF ATOM(EXPR) THEN
    IF EXPR = VAR THEN RETURN 1
    ELSE RETURN 0
  ELSE IF CAR(EXPR) = PLUS THEN
    RETURN CONS(PLUS, MAPCAR(LAMBDA(X, DIFF(X, VAR)), CDR(EXPR)))
  ELSE IF CAR(EXPR) = TIMES THEN
    COMMENT Product rule: d(uv)/dx = u*dv/dx + v*du/dx;
    BEGIN
      SCALAR U, V;
      U := CAR(CDR(EXPR));
      V := CAR(CDR(CDR(EXPR)));
      RETURN CONS(PLUS,
        LIST(CONS(TIMES, LIST(U, DIFF(V, VAR))),
             CONS(TIMES, LIST(V, DIFF(U, VAR)))))
    END
  ELSE IF CAR(EXPR) = EXPT THEN
    COMMENT Power rule: d(x^n)/dx = n*x^(n-1);
    BEGIN
      SCALAR BASE, EXP;
      BASE := CAR(CDR(EXPR));
      EXP := CAR(CDR(CDR(EXPR)));
      RETURN CONS(TIMES,
        LIST(EXP,
             CONS(EXPT, LIST(BASE, CONS(PLUS, LIST(EXP, -1)))),
             DIFF(BASE, VAR)))
    END
END;

COMMENT Test the differentiation;
EXPR1 := CONS(EXPT, LIST(X, 3));
PRINT("d/dx(x^3) =", DIFF(EXPR1, X));

EXPR2 := CONS(TIMES, LIST(X, CONS(EXPT, LIST(X, 2))));
PRINT("d/dx(x*x^2) =", DIFF(EXPR2, X));

Real programs from Software Heritage

No SWH evidence indexed yet for this language. (Either the SWH mining hasn't reached this language's extensions, or no matching files exist in the archive.)

Contribute — propose a file extension

Tell us where to find evidence about MATHLAB (mapped to pl/mathlab). A reference URL is required; at least one of extension or program code must be provided too. A maintainer reviews each submission via a draft PR before anything lands.
Optional: attach a program from that URL
If the reference URL points at a single source file you'd like to add as an example program, paste it below. The workflow will write it under languages/MATHLAB/programs/<sha>/. Keep under ~200 lines.
(or open the pre-filled issue directly)
← mathjson MATHLAB 68 →