Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

NOTEBOOKS TUTORIAL SAGEMATH

Views: 4541
%auto typeset_mode(True, display=False)

INTERATIVIDADE

Recursos Básicos

  • Botao

@interact def fbotao(Aperte=selector(['Sage', 'Julia', 'Python','Octave'],buttons=True)): show(Aperte)
Interact: please open in CoCalc
@interact def fbotoes(Aperte=selector(['Sage', 'Julia', 'Python','Octave','Scilab','Maxima'],nrows=2,ncols = 3,buttons=True)): show(Aperte)
Interact: please open in CoCalc
  • Seletor

@interact def fselecao(selecione=selector(['Sage', 'Julia', 'Python','Octave'])): show(selecione)
Interact: please open in CoCalc
  • Faixa de valores (slider)

@interact def frange_slider(numero = ('Numero',(1,10))): show(numero)
Interact: please open in CoCalc
@interact def fslider(faixa = range_slider(-3,3,default=(-3,3))): show(faixa)
Interact: please open in CoCalc
  • Seletor de Cor

@interact def fcolor(c = color_selector('blue')): print(c)
Interact: please open in CoCalc
  • Check Box

@interact def fcheckbox(check=checkbox(True, label='Marque')): show(check)
Interact: please open in CoCalc
  • Lista de Objetos

@interact def _(lista=('Lista', input_grid(1, 4, default=[[1,2,3,'bola']]))): show(lista)
Interact: please open in CoCalc
  • Tabela

@interact def _(tabela=('Tabela', input_grid(2, 3, default=[[1,2,3],[4,4,4]]))): show(tabela)
Interact: please open in CoCalc
  • Gráficos

@interact def fgraf(f = x^2): show(plot(f,(x,-2,2)),figsize = (4,3))
Interact: please open in CoCalc
@interact def fgraf(f=x^2, a=-3, b=3): show(plot(f,(x,a,b)),figsize = (4,3))
Interact: please open in CoCalc
@interact def fgraf(f=('$f$', x^2), a=('Inferior', -3), b=('Superior', 3)): show(plot(f,(x,a,b)),figsize = (4,3))
Interact: please open in CoCalc
@interact def fgraf(f=('$f$', x^2), a=('Inferior', -3), b=('Superior', (-2,4)), tamanho = ('Tamanho',(2,4))): show(plot(f,(x,a,b)),figsize = (tamanho,tamanho))
Interact: please open in CoCalc
@interact def fgraf(f=input_box(x^2, width=20, label="$f$"), a=input_box(-3,width=20, label="$a$"), b=('Superior', (-2,4)), tamanho = ('Tamanho',(2,5))): show(plot(f,(x,a,b)),figsize = (tamanho,tamanho))
Interact: please open in CoCalc
@interact def fgraf(f=input_box(x^2,width=20),color=color_selector('red'), zoom=range_slider(-3,3,default=(-3,3))): show(plot(f,(x,zoom[0], zoom[1]), color=color), figsize = (4,3))
Interact: please open in CoCalc
@interact def fgraf(f=input_box(x^2,width=20),color=color_selector('red'),Preencher=True,zoom=range_slider(-3,3,default=(-3,3)),tamanho = ('Tamanho',(2,5))): show(plot(f,(x,zoom[0], zoom[1]), color=color,fill=Preencher), figsize = (tamanho,tamanho))
Interact: please open in CoCalc
def ftermSquare(n): return(1/n*sin(n*x*pi/3)) def ftermSawtooth(n): return(1/n*sin(n*x*pi/3)) def ftermParabola(n): return((-1)^n/n^2 * cos(n*x)) def fseriesSquare(n): return(4/pi*sum(ftermSquare(i) for i in range (1,2*n,2))) def fseriesSawtooth(n): return(1/2-1/pi*sum(ftermSawtooth(i) for i in range (1,n))) def fseriesParabola(n): return(pi^2/3 + 4*sum(ftermParabola(i) for i in range(1,n))) @interact def plotFourier(n=slider(1, 30,1,10,'Number of terms'),Function=['Dente de Serra','Onda Quadrada','Parabola']): if Function=='Dente de Serra': show(plot(fseriesSawtooth(n),(x,-6,6),figsize=(4,3))) if Function=='Onda Quadrada': show(plot(fseriesSquare(n),(x,-6,6),figsize=(4,3))) if Function=='Parabola': show(plot(fseriesParabola(n),(x,-6,6),figsize=(4,3)))
Interact: please open in CoCalc

Animação