Skip to content

Instantly share code, notes, and snippets.

@barche
Created May 24, 2021 13:12
Show Gist options
  • Save barche/bae64b2916323155b3659292a0ecdc8d to your computer and use it in GitHub Desktop.
Save barche/bae64b2916323155b3659292a0ecdc8d to your computer and use it in GitHub Desktop.
### A Pluto.jl notebook ###
# v0.14.2
using Markdown
using InteractiveUtils
# This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error).
macro bind(def, element)
quote
local el = $(esc(element))
global $(esc(def)) = Core.applicable(Base.get, el) ? Base.get(el) : missing
el
end
end
# ╔═╡ 3559d1e3-2129-423c-9a70-09224afb366c
using Plots,PlutoUI
# ╔═╡ 8841ce60-40c3-4241-8175-b0917d892f30
@bind a Slider(0:0.1:10)
# ╔═╡ 9cea2325-d8e7-4bd0-a9e9-4a1105661da1
@bind b Slider(0:0.1:10)
# ╔═╡ bca846fc-ed8a-4888-baf3-f7ad165438f7
line(x) = a^2 + (b^2 - a^2)/(b+a)*(x+a)
# ╔═╡ 4ff4f718-be7c-4edb-b2a3-a6254f579148
begin
plot(line, -a, b)
scatter!([-a,b,0],[a^2,b^2,a*b])
plot!(x -> x^2, -a*1.1, b*1.1, framestyle = :zerolines,legend=nothing,title="a = $a, b = $b")
end
# ╔═╡ 4438f2d7-268a-4249-8d18-6beafa706ac0
line(0) == a*b
# ╔═╡ Cell order:
# ╠═3559d1e3-2129-423c-9a70-09224afb366c
# ╠═8841ce60-40c3-4241-8175-b0917d892f30
# ╠═9cea2325-d8e7-4bd0-a9e9-4a1105661da1
# ╠═bca846fc-ed8a-4888-baf3-f7ad165438f7
# ╠═4ff4f718-be7c-4edb-b2a3-a6254f579148
# ╠═4438f2d7-268a-4249-8d18-6beafa706ac0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment