cadernos_json). Edite o texto livre (Markdown ou texto simples) e salve para recarregar o conteúdo renderizado.
IS–LM Ultra • Equilíbrio + Estática Comparativa
1) Controles (parâmetros estruturais)
2) Choques (políticas e cenários)
3) Resultados numéricos (equilíbrio e variações)
ΔI ≈
4) Matemática do modelo (LaTeX dinâmico)
\(\frac{dY}{dr}\big|_{IS}=-\frac{b}{1-c}\), \(\frac{dY}{dr}\big|_{LM}=\frac{h}{k}\).
5) Estática comparativa (efeitos marginais)
6) Leitura de prova
• Aumentou \(M/P\): LM → direita/baixo: \(r\downarrow\), \(Y\uparrow\) (depende de \(b\) e \(c\)).
• Armadilha: \(h\to\infty\) → LM horizontal → monetária ineficaz; fiscal eficaz.
• Clássico: \(h=0\) → LM vertical → fiscal ineficaz; monetária eficaz.
HUD (equações em tempo real)
✅ HTML avançado (LaTeX + sliders + equilíbrio + políticas + cenários)
Salve como
is_lm_ultra.htmle abra no navegador.
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>IS–LM Ultra (LaTeX + Equilíbrio + Estática Comparativa)</title>
<style>
:root{
--bg:#020617; --panel:#0b1220; --panel2:#0a1020;
--line:#1e293b; --txt:#e5e7eb; --muted:#94a3b8;
--is:#38bdf8; --is2:#0ea5e9; --lm:#22c55e; --lm2:#4ade80;
--eq:#ef4444; --grid:#0f1b34;
}
body{
margin:0; height:100vh; display:flex; background:var(--bg); color:var(--txt);
font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
}
#left{
width:420px; min-width:420px; box-sizing:border-box;
border-right:2px solid var(--line);
padding:14px 14px 10px; background:linear-gradient(180deg,var(--panel),var(--panel2));
overflow:auto;
}
h1{ font-size:18px; margin:0 0 10px; color:var(--is); }
.row{ display:flex; gap:10px; }
.card{
border:1px solid var(--line); border-radius:10px; padding:10px; margin:10px 0;
background:rgba(2,6,23,.35);
}
.card h2{ font-size:14px; margin:0 0 8px; color:#a5b4fc; }
.btn{
width:100%; padding:10px; margin:6px 0; border:0; border-radius:10px;
background:#13213e; color:var(--txt); cursor:pointer; font-size:13px;
}
.btn:hover{ background:#1a2a4e; }
.btn2{ background:#112c22; }
.btn2:hover{ background:#16382c; }
.btn3{ background:#2a1d10; }
.btn3:hover{ background:#3a2715; }
.btn4{ background:#2a1020; }
.btn4:hover{ background:#3a142c; }
.grid2{
display:grid; grid-template-columns:1fr 1fr; gap:10px;
}
label{ font-size:12px; color:var(--muted); display:block; margin-bottom:4px; }
input[type="range"]{ width:100%; }
.v{ font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size:12px; color:#cbd5e1; }
.kpi{
display:grid; grid-template-columns:1fr 1fr; gap:10px;
}
.kpi .box{
border:1px solid var(--line); border-radius:10px; padding:10px; background:rgba(2,6,23,.28);
}
.kpi .t{ font-size:11px; color:var(--muted); }
.kpi .n{ font-size:16px; color:#f8fafc; font-weight:700; }
.note{ font-size:12px; color:var(--muted); line-height:1.45; }
.mathbox{
border:1px dashed #334155; border-radius:10px; padding:10px;
background:rgba(2,6,23,.25); overflow:auto;
font-size:13px;
}
#right{ flex:1; display:flex; flex-direction:column; }
#topbar{
height:46px; border-bottom:2px solid var(--line);
display:flex; align-items:center; gap:12px; padding:0 14px;
background:rgba(2,6,23,.65);
}
#legend{
display:flex; gap:12px; align-items:center; flex-wrap:wrap;
font-size:12px; color:var(--muted);
}
.dot{ width:10px; height:10px; border-radius:50%; display:inline-block; margin-right:6px; }
#plotWrap{ flex:1; position:relative; }
canvas{ width:100%; height:100%; display:block; background:radial-gradient(circle at 50% 50%, rgba(15,23,42,.35), rgba(2,6,23,1)); }
#overlay{
position:absolute; inset:0; pointer-events:none;
}
#overlay .hud{
position:absolute; right:12px; top:12px; width:340px;
background:rgba(2,6,23,.72); border:1px solid var(--line); border-radius:12px;
padding:10px;
}
.hud h3{ margin:0 0 6px; font-size:13px; color:#fda4af; }
.hud .small{ font-size:12px; color:var(--muted); line-height:1.35; }
.hud .mono{ font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size:12px; color:#e2e8f0; }
</style>
<!-- MathJax (LaTeX) -->
<script>
window.MathJax = {
tex: { inlineMath: [['\\(','\\)'], ['$', '$']] },
options: { skipHtmlTags: ['script','noscript','style','textarea','pre','code'] }
};
</script>
<script defer src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
</head>
<body>
<div id="left">
<h1>IS–LM Ultra • Equilíbrio + Estática Comparativa</h1>
<div class="card">
<h2>1) Controles (parâmetros estruturais)</h2>
<div class="grid2">
<div>
<label>Propensão marginal a consumir \(c\) (0 < c < 1)</label>
<input id="c" type="range" min="0.05" max="0.95" step="0.01" value="0.80" />
<div class="v">c = <span id="cV"></span></div>
</div>
<div>
<label>Sensibilidade do investimento aos juros \(b\) (>0)</label>
<input id="b" type="range" min="1" max="80" step="1" value="20" />
<div class="v">b = <span id="bV"></span></div>
</div>
<div>
<label>Demanda por moeda: coef. renda \(k\) (>0)</label>
<input id="k" type="range" min="0.2" max="2.0" step="0.05" value="0.8" />
<div class="v">k = <span id="kV"></span></div>
</div>
<div>
<label>Demanda por moeda: coef. juros \(h\) (≥0)</label>
<input id="h" type="range" min="0" max="120" step="1" value="20" />
<div class="v">h = <span id="hV"></span></div>
</div>
</div>
<div class="grid2" style="margin-top:8px;">
<div>
<label>Consumo autônomo \(C_0\)</label>
<input id="C0" type="range" min="0" max="600" step="10" value="100" />
<div class="v">C₀ = <span id="C0V"></span></div>
</div>
<div>
<label>Investimento autônomo \(I_0\)</label>
<input id="I0" type="range" min="0" max="600" step="10" value="100" />
<div class="v">I₀ = <span id="I0V"></span></div>
</div>
<div>
<label>Gastos do governo \(G\)</label>
<input id="G" type="range" min="0" max="600" step="10" value="100" />
<div class="v">G = <span id="GV"></span></div>
</div>
<div>
<label>Tributos \(T\)</label>
<input id="T" type="range" min="0" max="600" step="10" value="100" />
<div class="v">T = <span id="TV"></span></div>
</div>
<div style="grid-column:1 / span 2;">
<label>Oferta real de moeda \(\frac{M}{P}\)</label>
<input id="MP" type="range" min="0" max="600" step="10" value="200" />
<div class="v">M/P = <span id="MPV"></span></div>
</div>
</div>
</div>
<div class="card">
<h2>2) Choques (políticas e cenários)</h2>
<button class="btn" onclick="shockFiscal(+80)">Fiscal expansionista: \(\Delta G=+80\) (IS → direita)</button>
<button class="btn btn3" onclick="shockFiscal(-80)">Fiscal contracionista: \(\Delta G=-80\) (IS → esquerda)</button>
<button class="btn btn2" onclick="shockMonetaria(+80)">Monetária expansionista: \(\Delta (M/P)=+80\) (LM → direita/baixo)</button>
<button class="btn btn4" onclick="shockMonetaria(-80)">Monetária restritiva: \(\Delta (M/P)=-80\) (LM → esquerda/cima)</button>
<div class="row" style="margin-top:8px;">
<button class="btn" style="flex:1" onclick="setLiquidityTrap()">Armadilha da liquidez (LM horizontal)</button>
<button class="btn" style="flex:1" onclick="setClassical()">Caso clássico (LM vertical)</button>
</div>
<button class="btn" onclick="setNormal()">Caso intermediário (LM inclinada)</button>
<button class="btn" onclick="resetAll()">Reset geral</button>
</div>
<div class="card">
<h2>3) Resultados numéricos (equilíbrio e variações)</h2>
<div class="kpi">
<div class="box">
<div class="t">Equilíbrio inicial \(Y_0\)</div>
<div class="n" id="Y0"></div>
</div>
<div class="box">
<div class="t">Equilíbrio inicial \(r_0\)</div>
<div class="n" id="r0"></div>
</div>
<div class="box">
<div class="t">Equilíbrio final \(Y_1\)</div>
<div class="n" id="Y1"></div>
</div>
<div class="box">
<div class="t">Equilíbrio final \(r_1\)</div>
<div class="n" id="r1"></div>
</div>
<div class="box">
<div class="t">\(\Delta Y = Y_1-Y_0\)</div>
<div class="n" id="dY"></div>
</div>
<div class="box">
<div class="t">\(\Delta r = r_1-r_0\)</div>
<div class="n" id="dr"></div>
</div>
</div>
<div class="note" style="margin-top:10px;">
<b>Crowding out (proxy):</b> \( \Delta I \approx -b\,\Delta r \).<br/>
<span class="v">ΔI ≈ <span id="dI"></span></span>
</div>
</div>
<div class="card">
<h2>4) Matemática do modelo (LaTeX dinâmico)</h2>
<div class="mathbox" id="math"></div>
<div class="note" style="margin-top:8px;">
Inclinações (interpretação direta):<br/>
\(\frac{dY}{dr}\big|_{IS}=-\frac{b}{1-c}\), \(\frac{dY}{dr}\big|_{LM}=\frac{h}{k}\).
</div>
</div>
<div class="card">
<h2>5) Estática comparativa (efeitos marginais)</h2>
<div class="mathbox" id="comp"></div>
</div>
<div class="card">
<h2>6) Leitura de prova</h2>
<div class="note" id="prova">
• Aumentou \(G\): IS → direita. Se \(b\) alto, então pequena \(\Delta r\) já derruba \(I\) (crowding out alto).<br/>
• Aumentou \(M/P\): LM → direita/baixo: \(r\downarrow\), \(Y\uparrow\) (depende de \(b\) e \(c\)).<br/>
• Armadilha: \(h\to\infty\) → LM horizontal → monetária ineficaz; fiscal eficaz.<br/>
• Clássico: \(h=0\) → LM vertical → fiscal ineficaz; monetária eficaz.
</div>
</div>
</div>
<div id="right">
<div id="topbar">
<div id="legend">
<span><span class="dot" style="background:var(--is)"></span>IS</span>
<span><span class="dot" style="background:var(--is2)"></span>IS′</span>
<span><span class="dot" style="background:var(--lm)"></span>LM</span>
<span><span class="dot" style="background:var(--lm2)"></span>LM′</span>
<span><span class="dot" style="background:var(--eq)"></span>E₀/E₁</span>
</div>
</div>
<div id="plotWrap">
<canvas id="cv"></canvas>
<div id="overlay">
<div class="hud">
<h3>HUD (equações em tempo real)</h3>
<div class="small">
<div class="mono" id="hud1"></div>
<div class="mono" id="hud2" style="margin-top:6px;"></div>
<div class="mono" id="hud3" style="margin-top:6px;"></div>
</div>
</div>
</div>
</div>
</div>
<script>
const cv = document.getElementById("cv");
const ctx = cv.getContext("2d", { alpha:false });
function fit(){
const r = cv.getBoundingClientRect();
cv.width = Math.floor(r.width * devicePixelRatio);
cv.height = Math.floor(r.height * devicePixelRatio);
}
addEventListener("resize", fit); fit();
const UI = {
c: q("c"), b:q("b"), k:q("k"), h:q("h"),
C0:q("C0"), I0:q("I0"), G:q("G"), T:q("T"), MP:q("MP"),
cV:q("cV"), bV:q("bV"), kV:q("kV"), hV:q("hV"),
C0V:q("C0V"), I0V:q("I0V"), GV:q("GV"), TV:q("TV"), MPV:q("MPV"),
Y0:q("Y0"), r0:q("r0"), Y1:q("Y1"), r1:q("r1"), dY:q("dY"), dr:q("dr"), dI:q("dI"),
math:q("math"), comp:q("comp"), hud1:q("hud1"), hud2:q("hud2"), hud3:q("hud3")
};
function q(id){ return document.getElementById(id); }
let base = snapshot();
let shock = { dG:0, dMP:0 };
let mode = "normal"; // normal | trap | classical
function snapshot(){
return {
c:+UI.c.value, b:+UI.b.value, k:+UI.k.value, h:+UI.h.value,
C0:+UI.C0.value, I0:+UI.I0.value, G:+UI.G.value, T:+UI.T.value, MP:+UI.MP.value
};
}
function A(p){ return p.C0 - p.c*p.T + p.I0 + p.G; } // A = C0 - cT + I0 + G
function solveEq(p){
// IS: Y = (A/(1-c)) - (b/(1-c)) r
// LM: Y = (MP/k) + (h/k) r
// => r* = [A/(1-c) - MP/k] / [b/(1-c) + h/k]
const denom = (p.b/(1-p.c)) + (p.h/p.k);
// tratamento de casos extremos:
if(mode==="trap"){
// LM horizontal: r ~ constante (aprox). modelamos como h grande:
// mantendo fórmula, mas impondo h muito grande para aproximar.
// (já setado via setLiquidityTrap)
}
if(mode==="classical"){
// LM vertical: h=0 (já setado). denom = b/(1-c).
}
let r = ( (A(p)/(1-p.c)) - (p.MP/p.k) ) / denom;
let Y = (p.MP/p.k) + (p.h/p.k)*r; // usar LM
return { Y, r, denom };
}
function fmt(x){
if(!isFinite(x)) return "—";
return (Math.round(x*100)/100).toFixed(2);
}
function updateUI(){
const p = snapshot();
// refletir valores
UI.cV.textContent = p.c.toFixed(2);
UI.bV.textContent = p.b.toFixed(0);
UI.kV.textContent = p.k.toFixed(2);
UI.hV.textContent = p.h.toFixed(0);
UI.C0V.textContent = p.C0.toFixed(0);
UI.I0V.textContent = p.I0.toFixed(0);
UI.GV.textContent = p.G.toFixed(0);
UI.TV.textContent = p.T.toFixed(0);
UI.MPV.textContent = p.MP.toFixed(0);
// base (sem choque)
const p0 = {...p, G:p.G - shock.dG, MP:p.MP - shock.dMP}; // estado inicial
const e0 = solveEq(p0);
const e1 = solveEq(p);
UI.Y0.textContent = fmt(e0.Y);
UI.r0.textContent = fmt(e0.r);
UI.Y1.textContent = fmt(e1.Y);
UI.r1.textContent = fmt(e1.r);
const dY = e1.Y - e0.Y;
const dr = e1.r - e0.r;
UI.dY.textContent = fmt(dY);
UI.dr.textContent = fmt(dr);
// proxy crowding out: ΔI ≈ -b Δr
const dI = -p.b * dr;
UI.dI.textContent = fmt(dI);
// Equações LaTeX (dinâmicas)
const Ap = A(p);
const Ap0 = A(p0);
UI.math.innerHTML = `
\[\\textbf{IS: } Y = \\frac{1}{1-c}A - \\frac{b}{1-c}r
\\quad\\text{com}\\quad A=C_0-cT+I_0+G
\]
\[\\textbf{LM: } \\frac{M}{P}=kY-hr \\;\\Rightarrow\\; Y=\\frac{1}{k}\\frac{M}{P}+\\frac{h}{k}r
\]
\[A_0=${Ap0.toFixed(2)}\\;\\;\\; A_1=${Ap.toFixed(2)}\\quad\\Rightarrow\\quad
(Y_0,r_0)=(${fmt(e0.Y)},${fmt(e0.r)}),\\; (Y_1,r_1)=(${fmt(e1.Y)},${fmt(e1.r)})
\]
`;
// Estática comparativa (forma “prova”)
// Fiscal: dY/dG = [1/(1-c)] * 1 / [1 + (bk)/(h(1-c))]
// Monetária: dY/d(M/P) = [1/k] * 1 / [1 + (bk)/(h(1-c))]
// (em h=0 e h→∞, interpretar limites)
let compHtml = "";
if(p.h === 0){
compHtml = `
\[h=0\\Rightarrow \\text{LM vertical (caso clássico)}.
\]
\[\\frac{\\partial Y}{\\partial G}=0\\quad (\\text{crowding out total}),\\qquad
\\frac{\\partial Y}{\\partial (M/P)}=\\frac{1}{k}.
\]
`;
} else if(p.h > 1000){
compHtml = `
\[h\\to\\infty\\Rightarrow \\text{LM horizontal (armadilha da liquidez)}.
\]
\[\\frac{\\partial Y}{\\partial G}=\\frac{1}{1-c},\\qquad
\\frac{\\partial Y}{\\partial (M/P)}\\approx 0.
\]
`;
} else {
const term = (p.b*p.k)/(p.h*(1-p.c));
const dYdG = (1/(1-p.c)) * (1/(1+term));
const dYdMP = (1/p.k) * (1/(1+term));
compHtml = `
\[\\textbf{Termo de crowding out: } 1+\\frac{bk}{h(1-c)}=1+${term.toFixed(4)}
\]
\[\\boxed{\\frac{\\partial Y}{\\partial G}=\\frac{1}{1-c}\\cdot\\frac{1}{1+\\frac{bk}{h(1-c)}}}
= ${dYdG.toFixed(4)}
\]
\[\\boxed{\\frac{\\partial Y}{\\partial (M/P)}=\\frac{1}{k}\\cdot\\frac{1}{1+\\frac{bk}{h(1-c)}}}
= ${dYdMP.toFixed(4)}
\]
`;
}
UI.comp.innerHTML = compHtml;
// HUD
UI.hud1.textContent = `IS: Y = ${((1/(1-p.c))*Ap).toFixed(2)} − ${(p.b/(1-p.c)).toFixed(2)} r`;
UI.hud2.textContent = `LM: Y = ${(p.MP/p.k).toFixed(2)} + ${(p.h/p.k).toFixed(2)} r`;
UI.hud3.textContent = `Choques: ΔG=${shock.dG} ; Δ(M/P)=${shock.dMP} ; modo=${mode}`;
// render MathJax
if(window.MathJax && MathJax.typesetPromise){
MathJax.typesetPromise([UI.math, UI.comp]).catch(()=>{});
}
// atualizar base para desenho
base = p0;
}
// ----- desenho -----
const world = {
// eixos em “unidades econômicas”
xMin: 0, xMax: 1200, // Y
yMin: 0, yMax: 30 // r
};
function toCanvasY(y){ // y = r
const H = cv.height;
const top = 60*devicePixelRatio, bot = 70*devicePixelRatio;
const t = (y - world.yMin) / (world.yMax - world.yMin);
return (H - bot) - t * (H - top - bot);
}
function toCanvasX(x){ // x = Y
const W = cv.width;
const left = 80*devicePixelRatio, right = 40*devicePixelRatio;
const t = (x - world.xMin) / (world.xMax - world.xMin);
return left + t * (W - left - right);
}
function lineIS(p, r){
// Y = (A/(1-c)) - (b/(1-c)) r
return (A(p)/(1-p.c)) - (p.b/(1-p.c))*r;
}
function lineLM(p, r){
// Y = (MP/k) + (h/k) r
return (p.MP/p.k) + (p.h/p.k)*r;
}
let anim = { t:0, running:true };
function draw(){
const W=cv.width, H=cv.height;
ctx.fillStyle = "#020617";
ctx.fillRect(0,0,W,H);
// grade
ctx.strokeStyle = "rgba(15,27,52,.9)";
ctx.lineWidth = 1*devicePixelRatio;
for(let i=0;i<=6;i++){
const x = world.xMin + i*(world.xMax-world.xMin)/6;
ctx.beginPath(); ctx.moveTo(toCanvasX(x), toCanvasY(world.yMin));
ctx.lineTo(toCanvasX(x), toCanvasY(world.yMax)); ctx.stroke();
}
for(let j=0;j<=6;j++){
const y = world.yMin + j*(world.yMax-world.yMin)/6;
ctx.beginPath(); ctx.moveTo(toCanvasX(world.xMin), toCanvasY(y));
ctx.lineTo(toCanvasX(world.xMax), toCanvasY(y)); ctx.stroke();
}
// eixos
ctx.strokeStyle = "#475569";
ctx.lineWidth = 2*devicePixelRatio;
ctx.beginPath();
ctx.moveTo(toCanvasX(world.xMin), toCanvasY(world.yMin));
ctx.lineTo(toCanvasX(world.xMax), toCanvasY(world.yMin));
ctx.moveTo(toCanvasX(world.xMin), toCanvasY(world.yMin));
ctx.lineTo(toCanvasX(world.xMin), toCanvasY(world.yMax));
ctx.stroke();
// rótulos escala
ctx.fillStyle = "#94a3b8";
ctx.font = `${12*devicePixelRatio}px ui-monospace, Menlo, Consolas`;
for(let i=0;i<=6;i++){
const x = world.xMin + i*(world.xMax-world.xMin)/6;
ctx.fillText(Math.round(x).toString(), toCanvasX(x)-14*devicePixelRatio, toCanvasY(world.yMin)+22*devicePixelRatio);
}
for(let j=0;j<=6;j++){
const y = world.yMin + j*(world.yMax-world.yMin)/6;
ctx.fillText(y.toFixed(0), toCanvasX(world.xMin)-24*devicePixelRatio, toCanvasY(y)+4*devicePixelRatio);
}
ctx.fillText("Y", toCanvasX(world.xMax)+10*devicePixelRatio, toCanvasY(world.yMin)+6*devicePixelRatio);
ctx.fillText("r", toCanvasX(world.xMin)-6*devicePixelRatio, toCanvasY(world.yMax)-10*devicePixelRatio);
// estados
const p0 = base;
const p1 = snapshot();
const e0 = solveEq(p0);
const e1 = solveEq(p1);
// desenhar curvas (amostrando em r)
function drawCurve(p, fnY, color, label){
ctx.strokeStyle = color;
ctx.lineWidth = 3*devicePixelRatio;
ctx.beginPath();
let started=false;
for(let rr=world.yMin; rr<=world.yMax; rr+=0.2){
const YY = fnY(p, rr);
if(!isFinite(YY)) continue;
const cx=toCanvasX(YY), cy=toCanvasY(rr);
if(!started){ ctx.moveTo(cx,cy); started=true; }
else ctx.lineTo(cx,cy);
}
ctx.stroke();
// label próximo de r alto
ctx.fillStyle = color;
ctx.font = `${13*devicePixelRatio}px ui-monospace, Menlo, Consolas`;
const rr = 24;
const YY = fnY(p, rr);
if(isFinite(YY)){
ctx.fillText(label, toCanvasX(YY)+8*devicePixelRatio, toCanvasY(rr)-6*devicePixelRatio);
}
}
// IS/LM originais (p0) e chocadas (p1) — com animação suave de transição
const t = 0.5 - 0.5*Math.cos(Math.min(1, anim.t)*Math.PI); // ease-in-out
// construir "pMix" para animar do p0 para p1 só nos choques
const pMix = {...p0};
pMix.G = p0.G + (p1.G - p0.G)*t;
pMix.MP = p0.MP + (p1.MP - p0.MP)*t;
pMix.c=p1.c; pMix.b=p1.b; pMix.k=p1.k; pMix.h=p1.h; // parâmetros estruturais instantâneos
drawCurve(p0, lineIS, getComputedStyle(document.documentElement).getPropertyValue('--is').trim(), "IS");
drawCurve(p0, lineLM, getComputedStyle(document.documentElement).getPropertyValue('--lm').trim(), "LM");
// curvas em transição (IS’/LM’)
if(shock.dG!==0) drawCurve(pMix, lineIS, getComputedStyle(document.documentElement).getPropertyValue('--is2').trim(), "IS′");
if(shock.dMP!==0) drawCurve(pMix, lineLM, getComputedStyle(document.documentElement).getPropertyValue('--lm2').trim(), "LM′");
// pontos E0 e E1
function drawPoint(e, color, label){
if(!isFinite(e.Y)||!isFinite(e.r)) return;
const cx=toCanvasX(e.Y), cy=toCanvasY(e.r);
ctx.fillStyle = color;
ctx.beginPath(); ctx.arc(cx,cy,6*devicePixelRatio,0,Math.PI*2); ctx.fill();
ctx.fillStyle = "#e5e7eb";
ctx.font = `${12*devicePixelRatio}px ui-monospace, Menlo, Consolas`;
ctx.fillText(label, cx+10*devicePixelRatio, cy-10*devicePixelRatio);
// linhas tracejadas
ctx.strokeStyle = "rgba(226,232,240,.35)";
ctx.setLineDash([6*devicePixelRatio,6*devicePixelRatio]);
ctx.beginPath();
ctx.moveTo(cx, toCanvasY(world.yMin)); ctx.lineTo(cx, cy);
ctx.moveTo(toCanvasX(world.xMin), cy); ctx.lineTo(cx, cy);
ctx.stroke();
ctx.setLineDash([]);
}
// ponto animado (E(t))
const eT = solveEq(pMix);
drawPoint(e0, "#ef4444", "E₀");
drawPoint(e1, "#f97316", "E₁");
drawPoint(eT, "#ffffff", "E(t)");
// setas ΔY/Δr
if(isFinite(e0.Y)&&isFinite(e1.Y)&&isFinite(e0.r)&&isFinite(e1.r)){
ctx.strokeStyle="rgba(239,68,68,.85)";
ctx.lineWidth=2*devicePixelRatio;
// seta horizontal (ΔY)
const x0=toCanvasX(e0.Y), x1=toCanvasX(e1.Y), y0=toCanvasY(e0.r);
arrow(x0,y0,x1,y0);
// seta vertical (Δr)
const xR=toCanvasX(e1.Y), y1=toCanvasY(e1.r);
arrow(xR,toCanvasY(e0.r),xR,y1);
ctx.fillStyle="#fca5a5";
ctx.font=`${12*devicePixelRatio}px ui-monospace, Menlo, Consolas`;
ctx.fillText(`ΔY=${fmt(e1.Y-e0.Y)}`, (x0+x1)/2, y0-12*devicePixelRatio);
ctx.fillText(`Δr=${fmt(e1.r-e0.r)}`, xR+10*devicePixelRatio, (toCanvasY(e0.r)+y1)/2);
}
// anim time
if(anim.running){
anim.t += 0.02;
if(anim.t>=1) anim.t=1;
}
requestAnimationFrame(draw);
}
function arrow(x0,y0,x1,y1){
const head=10*devicePixelRatio;
ctx.beginPath();
ctx.moveTo(x0,y0); ctx.lineTo(x1,y1);
ctx.stroke();
const ang=Math.atan2(y1-y0,x1-x0);
ctx.beginPath();
ctx.moveTo(x1,y1);
ctx.lineTo(x1-head*Math.cos(ang-Math.PI/6), y1-head*Math.sin(ang-Math.PI/6));
ctx.lineTo(x1-head*Math.cos(ang+Math.PI/6), y1-head*Math.sin(ang+Math.PI/6));
ctx.closePath();
ctx.fillStyle="rgba(239,68,68,.85)";
ctx.fill();
}
// ----- eventos -----
function bindAll(){
const ids=["c","b","k","h","C0","I0","G","T","MP"];
ids.forEach(id => q(id).addEventListener("input", ()=>{
updateUI();
restartAnim();
}));
}
bindAll();
function restartAnim(){ anim.t=0; anim.running=true; }
function shockFiscal(dG){
UI.G.value = (+UI.G.value + dG).toFixed(0);
shock.dG += dG;
updateUI(); restartAnim();
}
function shockMonetaria(dMP){
UI.MP.value = (+UI.MP.value + dMP).toFixed(0);
shock.dMP += dMP;
updateUI(); restartAnim();
}
function setLiquidityTrap(){
mode="trap";
UI.h.value = 5000; // aproxima h→∞
updateUI(); restartAnim();
}
function setClassical(){
mode="classical";
UI.h.value = 0; // h=0
updateUI(); restartAnim();
}
function setNormal(){
mode="normal";
if(+UI.h.value===0) UI.h.value=20;
if(+UI.h.value>1000) UI.h.value=20;
updateUI(); restartAnim();
}
function resetAll(){
// default
UI.c.value=0.80; UI.b.value=20; UI.k.value=0.80; UI.h.value=20;
UI.C0.value=100; UI.I0.value=100; UI.G.value=100; UI.T.value=100; UI.MP.value=200;
shock={ dG:0, dMP:0 }; mode="normal";
updateUI(); restartAnim();
}
updateUI();
requestAnimationFrame(draw);
</script>
</body>
</html>
🧪 BLOCO DE QUESTÕES – ALTA COMPLEXIDADE (JSON)
Se você quiser deixar ainda mais “matemático-raiz”, eu consigo colocar no HTML:
- matriz do sistema linear (\begin{pmatrix} \cdot & \cdot \ \cdot & \cdot \end{pmatrix}),
- resolução por Cramer,
- e exibir (\frac{\partial r}{\partial G}), (\frac{\partial r}{\partial (M/P)}) junto com (\frac{\partial Y}{\partial G}) e (\frac{\partial Y}{\partial (M/P)}), tudo em LaTeX ao vivo.
Bloco de Questões
1. Se c aumenta, mantendo os demais parâmetros, a IS fica mais inclinada e a política fiscal tende a ficar menos eficaz. ✅ 0 / ❌ 0
Como dY/dr=−b/(1−c), aumento de c reduz (1−c) e aumenta |dY/dr|, tornando IS mais plana; além disso, 1/(1−c) aumenta, elevando o multiplicador.
2. No modelo IS-LM com C=C0+c(Y−T) e I=I0−br, a inclinação da IS em (Y,r) é dY/dr = −b/(1−c). ✅ 0 / ❌ 0
Da IS: Y=(1/(1−c))A − (b/(1−c))r, com A=C0−cT+I0+G, segue dY/dr=−b/(1−c).
3. No caso clássico (LM vertical, h=0 em L(Y,r)=kY−hr), um aumento de G desloca a IS para a direita e eleva Y. ✅ 0 / ❌ 0
Com LM vertical, o ajuste do novo equilíbrio após ↑G ocorre via r, mantendo Y constante: crowding out total.
4. A política fiscal expansionista é menos eficaz quando o investimento é mais elástico aos juros, pois o crowding out tende a ser maior. ✅ 0 / ❌ 0
Maior elasticidade de I em relação a r implica IS mais plana; pequena elevação de r reduz muito I, anulando parte do efeito de ↑G.
5. Se a LM é horizontal (armadilha da liquidez), uma expansão monetária (↑M/P) tende a não reduzir r nem elevar Y no modelo IS-LM. ✅ 0 / ❌ 0
Em LM horizontal, a taxa de juros não se ajusta para baixo com ↑M/P; a moeda adicional é retida e a política monetária se torna ineficaz.
6. Um aumento de M/P desloca a curva LM para a direita/baixo, reduz r e aumenta Y no novo equilíbrio, mantendo-se a IS fixa. ✅ 0 / ❌ 0
Como Y=(M/P)/k+(h/k)r, ↑(M/P) aumenta Y para qualquer r, deslocando LM; no cruzamento com IS, r cai e Y sobe (caso intermediário).
7. No modelo monetário M/P = kY − hr, a inclinação da LM em (Y,r) é dY/dr = h/k, logo h maior tende a tornar a LM mais plana (menos inclinada em r(Y)). ✅ 0 / ❌ 0
Reescrevendo: Y = (M/P)/k + (h/k)r, então dY/dr = h/k. Para r(Y), dr/dY = k/h diminui quando h aumenta (LM fica mais plana).
8. Quanto maior for b (sensibilidade do investimento aos juros), mais inclinada (mais vertical) será a curva IS. ✅ 0 / ❌ 0
Como dY/dr=−b/(1−c), aumento de b aumenta |dY/dr| e torna a IS mais plana (menos inclinada).