Logo : Matlab Use Symbolic Math

Matlab Use Symbolic Math

OrganisationPopulaire
matlab
matlab-use-symbolic-math

Generate correct MATLAB code using the Symbolic Math Toolbox. Use when the user asks for symbolic computations, analytical solutions, symbolic differentiation/integration, equation solving, or converting symbolic results to numeric MATLAB functions. Also use when converting differential equations to transfer functions or state-space form, extracting PDE coefficients (pdeCoefficients), symbolic-to-C code generation (matlabFunction + codegen), symbolic matrix variables (symmatrix), physical units and constants (symunit, newUnit), or rewriting/combining algebraic expressions (rewrite, combine).

Présentation

Éditeurmatlab
Dépôtmatlab-agentic-toolkit
Nom de la compétencematlab-use-symbolic-math
Étoiles
1.2K
Forks
138
Fichiers inclus
11
Liens
  • Instructions en Markdown

    Un fichier SKILL.md que le modèle charge à la demande : il ne consomme donc des tokens que lorsqu’une demande correspond réellement à la compétence.

  • Compatible avec tous les LLM

    Les compétences IA sont rédigées en Markdown et non sous forme de code propre à un fournisseur. Elles fonctionnent donc avec GPT, Claude, Gemini, Grok ou un modèle local.

  • Fichiers inclus : 11

    Des scripts, des gabarits et des références que le modèle peut consulter pendant son travail. Les fichiers sont en lecture seule et ne sont jamais exécutés.

  • Open source

    Publiée par matlab sur GitHub. Consultez les sources avant de l’installer.

Installation

Installez la compétence IA Matlab Use Symbolic Math dans TypingMind pour l’utiliser avec n’importe quel LLM, ou ajoutez-la à un autre agent capable de lire SKILL.md.

1

Installer dans TypingMind

TypingMind installe une compétence directement depuis son dossier GitHub : l’application lit SKILL.md, regroupe les fichiers de ressources et enregistre le tout localement.

  1. Ouvrez l’application et accédez à Plugins → Compétences.
  2. Choisissez « Installer depuis GitHub ».
  3. Copiez l’URL ci-dessous, qui pointe vers le dossier de la compétence, puis collez-la et confirmez.
    https://github.com/matlab/matlab-agentic-toolkit/tree/main/skills-catalog/math-and-optimization/matlab-use-symbolic-math
  4. Activez la compétence dans chaque discussion où vous souhaitez pouvoir l’utiliser.
Plugins → Compétences → Ajouter une compétence → Via une URL GitHub, puis collez l’URL du dossier et appuyez sur Continuer.
2

Installer dans un autre agent

Tout agent capable de lire le format Agent Skills peut utiliser cette compétence : copiez le dossier dans le répertoire des compétences de cet agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/matlab/matlab-agentic-toolkit.git /tmp/matlab-agentic-toolkit
mkdir -p .claude/skills
cp -r /tmp/matlab-agentic-toolkit/skills-catalog/math-and-optimization/matlab-use-symbolic-math .claude/skills/matlab-use-symbolic-math
Redémarrez Claude Code après la copie pour que la nouvelle compétence soit prise en compte.

Utilisez cette compétence dans TypingMind

Activez Matlab Use Symbolic Math dans n’importe quelle discussion TypingMind et le modèle s’occupe du reste. Le nom et la description de la compétence figurent dans le prompt système. Dès qu’une demande correspond, le modèle charge lui-même l’intégralité des instructions : vous n’avez jamais à l’invoquer manuellement, et elle ne consomme aucun token tant qu’elle n’est pas utilisée.

Le modèle charge automatiquement Matlab Use Symbolic Math dès qu’une demande correspond à cette compétence.

Compatible avec tous les modèles IA

Les compétences IA sont de simples instructions Markdown, et non du code propre à un fournisseur. Ainsi, la compétence Matlab Use Symbolic Math n’est pas liée au modèle pour lequel elle a été conçue. Installez-la une seule fois dans TypingMind et utilisez-la avec GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama ou un modèle local que vous exécutez vous-même, le tout avec vos propres clés API.

  • Chargée uniquement en cas de besoin

    Le prompt système ne contient que le nom et la description. Les instructions sont récupérées à la première demande correspondante : une compétence inutilisée ne coûte donc rien.

  • Changez de modèle en cours de discussion

    La compétence étant constituée d’instructions et non de code, elle reste fonctionnelle lorsque vous changez de modèle : le nouveau modèle lit le même fichier SKILL.md.

Instructions de la compétence

Voici le contenu de SKILL.md que le modèle charge. Lisez-le avant l’installation : une compétence contient des instructions que votre modèle suivra.

MATLAB Symbolic Math Toolbox

This skill provides guidelines, correct syntax, and common patterns for generating MATLAB® code that uses Symbolic Math Toolbox.

When to Use This Skill

  • Creating or manipulating symbolic variables, expressions, and functions
  • Performing symbolic differentiation, integration, limits, or summation
  • Simplifying, factoring, expanding, or collecting symbolic expressions
  • Computing Laplace, Fourier, or Z-transforms and their inverses
  • Deriving transfer functions or state-space equations from differential equations
  • Displaying or plotting symbolic expressions
  • Using variable precision arithmetic (VPA)
  • Generating MATLAB functions, Simulink function blocks, Simscape equations, and C code from symbolic expressions
  • Extracting PDE coefficients for use with PDE Toolbox
  • Converting symbolic expressions to C code or standalone executables
  • Matrix-level (atomic, textbook-style) symbolic linear algebra with symmatrix
  • Using physical units or constants in symbolic computations with symunit
  • Rewriting or combining algebraic expressions into specific forms

When NOT to Use This Skill

  • Purely numeric computation with no symbolic variables (use standard MATLAB numeric functions)
  • Statistics, machine learning, or data analysis on numeric datasets
  • Image processing, signal processing, or other toolbox-specific workflows that don't involve symbolic math
  • String manipulation or file I/O operations
  • When the user explicitly asks for numeric approximations only (use double or numeric solvers directly)
  • PDE Toolbox mesh generation, boundary conditions, or solving (downstream of coefficient extraction)
  • Numeric linear algebra (use standard MATLAB matrix operations)

Critical Rules

1. NEVER Pass Strings or Character Vectors to Symbolic Functions

WRONG (deprecated — warns today, errors in a future release; the single = in solve errors now):

matlab
solve('x^2 + 2*x - 3 = 0')
dsolve('Dy = -a*y')

CORRECT:

matlab
syms x
solve(x^2 + 2*x - 3 == 0, x)

syms y(t) a
dsolve(diff(y,t) == -a*y)

2. Use syms for Interactive Work, sym for Functions and Constants

  • syms x y z — Creates fresh symbolic variables and clears any prior assumptions. Use for interactive scripts and Live Scripts.
  • x = sym('x') — Refers to a symbolic variable. Inherits existing assumptions. Required inside MATLAB functions (not scripts) because syms dynamically creates workspace variables.
  • sym(pi) — Converts numeric to exact symbolic. Use for symbolic constants.
  • sym('pi') — Creates a symbolic variable named pi, NOT the mathematical constant π. This is a common source of confusion.

WRONG:

matlab
% Inside a function:
function result = myFunc()
    syms x          % Error or unreliable in compiled/nested functions
    result = x^2;
end

% Creating symbolic constant pi:
p = sym('pi');      % Creates variable named "pi", NOT the constant

CORRECT:

matlab
% Inside a function:
function result = myFunc()
    x = sym('x');   % Use sym inside functions
    result = x^2;
end

% Creating symbolic constant pi:
p = sym(pi);        % Converts numeric pi to exact symbolic π

3. Assumption Management

Assumptions persist in the symbolic engine even after clear. This is a frequent source of subtle bugs.

matlab
% Setting assumptions
syms x real                  % x is real (clears prior assumptions)
syms n positive integer      % n is a positive integer
assume(x > 0)                % x is positive (REPLACES all prior assumptions on x)
assumeAlso(x < 10)           % ADDS assumption: 0 < x < 10

% Checking assumptions
assumptions(x)               % Shows assumptions on x
assumptions                  % Shows ALL assumptions in workspace

% Clearing assumptions — two correct ways:
syms x                       % Recreate with syms: clears assumptions
assume(x, 'clear')           % Explicitly clear assumptions on x
reset(symengine)             % Nuclear option: clears EVERYTHING

Best Practice: Use syms x to clear assumptions (it resets the variable fresh). Use assume(x, 'clear') when you need to reset a specific variable mid-script. The MATLAB clear command only removes workspace variables — it has no effect on the symbolic engine's assumption store.

4. subs Does Not Modify In-Place

The subs function returns a new expression. It does NOT modify the original.

WRONG:

matlab
syms x
f = x^2 + 3*x;
subs(f, x, 2);         % Result is discarded!
disp(f)                % Still x^2 + 3*x

CORRECT:

matlab
syms x
f = x^2 + 3*x;
f_val = subs(f, x, 2);    % Assign the result
% or: f = subs(f, x, 2);  % Overwrite f

5. Do Not Wrap Numeric Literals in sym() Inside Symbolic Expressions

AI tools frequently over-wrap every numeric literal in sym(). When any operand in an arithmetic expression is symbolic, MATLAB automatically promotes all numeric literals in that expression to symbolic. Wrapping literals in sym() adds clutter and can cause errors. When you DO need sym(): Only when creating a standalone symbolic number with NO symbolic variables present in the expression.

matlab
% No symbolic variable involved — sym() IS needed:
half = sym(1/2);                % Exact 1/2, not 0.5 double
half = sym(1)/2;                % Exact 1/2, declaring sym(1) promotes all numeric literals to symbolic
piExact = sym(pi);              % Exact π, not 3.14159...

% Symbolic variable already present — sym() is NOT needed:
syms x
f = x/2 + 1/3;                 % Automatically exact: x/2 + 1/3
g = exp(-x^2/2) / sqrt(2*pi);  % All literals promoted by x

Core Workflow Patterns

Creating Variables and Expressions

matlab
% Multiple variables at once
syms a b c

% Variables with assumptions
syms a b c real
syms n positive integer
syms x
assume(x > 2)


% Symbolic matrices with auto-generated elements
syms A [3 3]                 % Creates A = [A1_1 A1_2 A1_3; ...]

% Symbolic vector
syms a [1 3]                 % Creates row vector a = [a1 a2 a3]

% Symbolic numbers (exact)
a = sym(1/3);           % Exact 1/3
piSym = sym(pi);        % Exact π

Solving Algebraic Equations

matlab
syms x y

% Single equation
sol = solve(x^2 - 5*x + 6 == 0, x);   % Returns [2; 3]

% System of equations
[solx, soly] = solve(x + y == 10, x - y == 2, x, y);

% Return all solutions along with the parameters in the solution and the conditions on the solution
[sol, params, conds] = solve(sin(x) == 0, x, 'ReturnConditions', true);

% Numerical solutions when analytic not possible
solN = vpasolve(x^5 - 3*x^4 + x - 1 == 0, x);

Calculus

matlab
syms x t n

% Differentiation
diff(sin(x), x)             % cos(x)
diff(x^3, x, 2)             % 6*x  (second derivative)

% Integration
int(x^2, x)                 % x^3/3  (indefinite)
int(x^2, x, 0, 1)           % 1/3    (definite, from 0 to 1)

% Limits
limit(sin(x)/x, x, 0)       % 1
limit(1/x, x, 0, 'right')   % Inf
limit(1/x, x, 0, 'left')    % -Inf

% Summation
symsum(1/n^2, n, 1, Inf)     % pi^2/6

% Taylor series
taylor(exp(x), x, 0, 'Order', 6)   % x^5/120 + x^4/24 + x^3/6 + x^2/2 + x + 1 

% Gradient, Hessian, Jacobian, Laplacian, Divergence, Curl — use dedicated functions, not manual diff
syms x y z
f = x^2*y + y^3;
gradient(f, [x, y])              % [2*x*y; x^2 + 3*y^2]
hessian(f, [x, y])               % [2*y, 2*x; 2*x, 6*y]
laplacian(f, [x, y])             % 2*y + 6*y = 8*y (trace of Hessian)
g = [x^2*y; 5*x + sin(y)];
jacobian(g, [x, y])              % [2*x*y, x^2; 5, cos(y)]
V = [x^2*y; y^2*z; z^2*x];
divergence(V, [x, y, z])         % 2*x*y + 2*y*z + 2*z*x
curl(V, [x, y, z])               % [-y^2; -z^2; -x^2]

Matrix Operations

matlab
syms a b c d
A = [a b; c d];

% Determinant
det(A)                   % a*d - b*c

% Inverse
inv(A)                   % Symbolic inverse

% Eigenvalues and eigenvectors
[V, D] = eig(A)

% Characteristic polynomial
charpoly = det(A - sym('lambda')*eye(2))

% Jacobian of a coordinate change
syms r(t) phi(t) theta(t);  % polar coordinates that are a function of time
R = [r*sin(phi)*cos(theta), r*sin(phi)*sin(theta), r*cos(phi)] % coordinate transform from spherical to Cartesian
jacobian(R,[r,phi,theta])

Application Patterns

For detailed workflows, see the reference files below. Read the relevant file when the user's task matches:

  • references/simplification-and-polynomials.md — simplify/expand/factor/collect/partfrac/rewrite, sym2poly vs coeffs, variable-precision arithmetic (VPA)
  • references/control-systems.md — Deriving transfer functions from ODEs, tf/ss derivation from first principles, Laplace/Fourier/Z-transform, Bode plots from symbolic models
  • references/ode-solving.md — dsolve syntax, odeToVectorField + matlabFunction + ode45 pipeline, parameterized ODE solving
  • references/plotting-and-display.md — fplot/fsurf/fmesh/fcontour/fimplicit/fanimator family, disp() vs pretty(), symbolic plotting best practices
  • references/matlabFunction-patterns.md — Converting symbolic expressions to function handles/files, 'Vars'/'Optimize'/'File' options, piecewise handling, critical error-prevention rules
  • references/extract-pde-coefficients.md — pdeCoefficients workflow for extracting PDE Toolbox coefficients, pdeCoefficientsToDouble, systems of PDEs
  • references/symbolic-to-c-code.md — matlabFunction(..., 'File', ...) + codegen pipeline for C/C++ generation, when to use ccode vs full pipeline
  • references/symmatrix-workflow.md — Atomic symbolic matrices with symmatrix, symmatrix2sym conversion, symfunmatrix, supported vs unsupported operations
  • references/symunit-workflow.md — Physical units/constants via symunit, newUnit/removeUnit, correct constant names (u.hc, u.c_0), unit conversion
  • references/rewrite-combine-expressions.md — Valid targets for rewrite and combine, IgnoreAnalyticConstraints for log combination, when to use which function

Common Mistakes and Fixes

MistakeFix
solve('x^2=1')syms x; solve(x^2 == 1, x)
dsolve('Dy = y')syms y(t); dsolve(diff(y,t) == y)
subs(f,x,2) without assigningf = subs(f,x,2)
Attempting to clear assumptions with the clear commandsyms x or assume(x,'clear') — only these reset the symbolic engine
Using syms inside a functionUse x = sym('x') inside functions
Manually extracting PDE coefficients by inspectionUse pdeCoefficients(pdeeq, u)
Computing Laplacian as sum of second derivativesUse laplacian(f, vars)
Using ccode() and manually building C filesUse matlabFunction(..., 'File', ...) then codegen
Using sym('A', [n n]) for matrix-level algebraUse symmatrix('A', [n n])
Hard-coding physical constants as numbersUse u = symunit; u.hc; u.c_0; u.m_e
Using combine(expr, 'power')Invalid target — valid: 'atan', 'exp', 'gamma', 'int', 'log', 'sincos', 'sinhcosh'
Computing gradient/Hessian/Jacobian/Laplacian/divergence/curl manually with diffUse gradient, hessian, jacobian, laplacian, divergence, curl
Manually building numeric arrays to plot a symbolic expressionUse fplot(f, [a b]), fsurf, fmesh, fcontour, or fanimator — they accept symbolic directly
Adding 'Optimize' to matlabFunction for a function handleFor handles: matlabFunction(expr, 'Vars', {...}) — nothing else needed. 'Optimize' is only for 'File' output
Keeping everything symbolic for a parametric sweepConvert to numeric: use matlabFunction then loop, or subs+double in a loop

See also: application-specific mistakes in each reference file.

Conventions for Modern Features

  • Use gradient, hessian, jacobian, laplacian, divergence, and curl when computing these standard vector calculus objects — do not manually assemble them from diff calls
  • Prefer pdeCoefficients() for extracting PDE Toolbox coefficients when the PDE is in a supported form
  • Prefer physical constants from symunit (e.g., u.hc, u.c_0) when available; hard-code only if the constant is not in the symunit catalog
  • Use symmatrix when the user asks for atomic/textbook-style matrices
  • Never pass an invalid target to combine or rewrite — consult the reference for valid targets

Checklist Before Generating Symbolic Code

  • Using syms (not string-based sym('...')) for variable creation in scripts
  • Using == for equations, not =
  • Using diff(y, t, n) for derivatives, not D notation
  • Using gradient, hessian, jacobian, laplacian, divergence, curl instead of manual diff when computing these objects
  • Specifying the independent variable explicitly in diff, int, laplace
  • Assigning subs(...) output to a variable
  • NOT wrapping numeric literals in sym() when a symbolic variable is already in the expression
  • Setting assumptions with assume/assumeAlso, clearing with syms x or assume(x,'clear')
  • Using fplot/fsurf/fanimator for symbolic plots (they accept symbolic expressions directly)
  • For parametric sweeps: converting to numeric (matlabFunction or subs+double in a loop)

Troubleshooting

Issue: solve returns empty or unexpected results

  • Check: Are there assumptions restricting the domain? Use assumptions to check.
  • Try: solve(eqn, x, 'ReturnConditions', true) to see conditions on solutions.
  • Try: vpasolve for numeric solutions when no closed form exists.

Issue: Stale assumptions causing wrong results

  • Fix: Add syms <varname> at the top of your script to clear assumptions.
  • Nuclear option: reset(symengine) clears everything.

See also: application-specific troubleshooting in each reference file.


Copyright 2026 The MathWorks, Inc.

Fichiers inclus

Le modèle lit ces fichiers à la demande lorsque la compétence est chargée. Ils sont accessibles en lecture et ne sont jamais exécutés.

Foire aux questions

À quoi sert la compétence IA Matlab Use Symbolic Math ?

Generate correct MATLAB code using the Symbolic Math Toolbox. Use when the user asks for symbolic computations, analytical solutions, symbolic differentiation/integration, equation solving, or converting symbolic results to numeric MATLAB functions. Also use when converting differential equations to transfer functions or state-space form, extracting PDE coefficients (pdeCoefficients), symbolic-to-C code generation (matlabFunction + codegen), symbolic matrix variables (symmatrix), physical units and constants (symunit, newUnit), or rewriting/combining algebraic expressions (rewrite, combine).

Pourquoi utiliser Matlab Use Symbolic Math sur TypingMind ?

Parce que vous l’installez une seule fois pour l’utiliser avec n’importe quel modèle. Matlab Use Symbolic Math se compose de simples instructions en Markdown plutôt que de code propre à un fournisseur. La même compétence fonctionne donc avec GPT-5, Claude, Gemini, Grok ou un modèle local, et vous pouvez changer de modèle en cours de discussion sans perturber son fonctionnement. TypingMind utilise vos propres clés API : vous payez donc directement les fournisseurs plutôt qu’un abonnement par siège, et vos compétences et discussions restent dans votre propre espace de stockage.

Comment installer Matlab Use Symbolic Math dans TypingMind ?

Dans TypingMind, ouvrez Plugins → Compétences → Installer depuis GitHub et collez https://github.com/matlab/matlab-agentic-toolkit/tree/main/skills-catalog/math-and-optimization/matlab-use-symbolic-math. TypingMind lit le fichier SKILL.md, regroupe les fichiers associés et installe le tout sous forme de compétence que vous pouvez activer pour chaque discussion.

Quels modèles d’IA peuvent utiliser Matlab Use Symbolic Math ?

N’importe quel modèle que vous connectez dans TypingMind. Les compétences IA sont de simples instructions en Markdown, et non du code propre à un fournisseur. GPT, Claude, Gemini, Grok et les modèles locaux peuvent donc tous charger cette compétence lorsqu’une demande lui correspond.

Combien de modèles d’IA puis-je utiliser avec Matlab Use Symbolic Math ?

Autant que vous le souhaitez. Vous pouvez utiliser Matlab Use Symbolic Math avec tout modèle qui prend en charge les compétences : GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama et bien d’autres, le tout dans TypingMind avec vos propres clés API.

La compétence IA Matlab Use Symbolic Math est-elle gratuite ?

Cette compétence est publiée sur GitHub par matlab. Consultez le dépôt pour connaître les conditions de licence. Vous ne payez que votre propre fournisseur d’IA pour les tokens utilisés.

Que sont les compétences IA ?

Une compétence IA est un ensemble d’instructions réutilisables qui apprend à un modèle d’IA à accomplir une tâche précise. Elle suit le format ouvert Agent Skills : un fichier SKILL.md contenant un nom et une description, ainsi que les éventuels scripts, gabarits ou fichiers de référence dont le modèle peut avoir besoin. Le modèle ne lit les instructions que lorsque votre demande correspond à la compétence. Une compétence installée ne coûte donc rien tant qu’elle n’est pas utilisée.

En quoi les compétences IA diffèrent-elles des plugins ou des serveurs MCP ?

Un plugin ou un serveur MCP fournit au modèle de nouveaux outils à appeler : du code qui s’exécute quelque part et renvoie un résultat. Une compétence IA lui apporte plutôt des connaissances et une méthode : comment aborder une tâche, quelles étapes suivre et à quoi ressemble un bon résultat. Les compétences sont de simples instructions en Markdown. Elles ne nécessitent donc ni serveur, ni clé API, ni environnement d’exécution, et fonctionnent avec n’importe quel modèle.

Tout voir

Créez votre propre espace de travail IA dès maintenant

Abonnez-vous à notre newsletter pour être informé des nouvelles fonctionnalités et des prochains cadeaux à gagner 👇