val s = -2.0; val e = 1.0
val sy = -1.0; val ey = 3.0
val step = 0.1
val xScale=100 ; val yScale=20
def f(x: Double) = 3 * x * x + x
clear
runInBackground {
val t = newTurtle(s*xScale, 0)
t.moveTo(e*xScale, 0)
}
runInBackground {
newTurtle(0, sy*yScale).moveTo(0, ey*yScale)
}
jumpTo(s*xScale, f(s)*yScale)
for (x <- s to e by step) moveTo(x*xScale, f(x)*yScale)
(ここからダウンロードもできます)
val s = -10.0; val e = 10.0
val sy = -1.0; val ey = 1.0
val step = 0.2
val xScale=10 ; val yScale=100
def f(x: Double) = math.sin(x)
clear
runInBackground {
val t = newTurtle(s*xScale, 0)
t.moveTo(e*xScale, 0)
}
runInBackground {
newTurtle(0, sy*yScale).moveTo(0, ey*yScale)
}
jumpTo(s*xScale, f(s)*yScale)
for (x <- s to e by step) moveTo(x*xScale, f(x)*yScale)
(ここからダウンロードもできます)
val s = -5.0; val e = 5.0
val sy = -1.0; val ey = 1.0
val step = 0.05
val xScale=100 ; val yScale=100
def f(x: Double) = math.sin(x*3)
def g(x: Double) = math.cos(x*5)
clear
runInBackground {
val t = newTurtle(s*xScale, 0)
t.moveTo(e*xScale, 0)
}
runInBackground {
newTurtle(0, sy*yScale).moveTo(0, ey*yScale)
}
jumpTo(g(s)*xScale, f(s)*yScale)
for (x <- s to e by step) moveTo(g(x)*xScale, f(x)*yScale)
(ここからダウンロードもできます)