Go back to the Contents page.
Press Show to reveal the code chunks.
# Set seed for reproducibility
set.seed(1982)
# Set global options for all code chunks
knitr::opts_chunk$set(
# Disable messages printed by R code chunks
message = FALSE,
# Disable warnings printed by R code chunks
warning = FALSE,
# Show R code within code chunks in output
echo = TRUE,
# Include both R code and its results in output
include = TRUE,
# Evaluate R code chunks
eval = FALSE,
# Enable caching of R code chunks for faster rendering
cache = FALSE,
# Align figures in the center of the output
fig.align = "center",
# Enable retina display for high-resolution figures
retina = 2,
# Show errors in the output instead of stopping rendering
error = TRUE,
# Do not collapse code and output into a single block
collapse = FALSE
)
# Start the figure counter
fig_count <- 0
# Define the captioner function
captioner <- function(caption) {
fig_count <<- fig_count + 1
paste0("Figure ", fig_count, ": ", caption)
}library(MetricGraph)
library(ggplot2)
library(reshape2)
library(dplyr)
library(viridis)
library(plotly)
library(patchwork)
library(slackr)
source("keys.R")
slackr_setup(token = token) # token comes from keys.R## [1] "Successfully connected to Slack"
capture.output(
knitr::purl(here::here("functionality1.Rmd"), output = here::here("functionality1.R")),
file = here::here("old/purl_log.txt")
)
source(here::here("functionality1.R"))Let \(\Gamma = (\mathcal{V}, \mathcal{E})\) be a metric graph with vertex set \(\mathcal{V} = \{v_1, v, v_2\}\) and edge set \(\mathcal{E} = \{e_1, e_2\}\). Assume that the edges \(e_1\) and \(e_2\) meet at the vertex \(v\), so that \(v\) is their common endpoint. For later reference, we recall the Kirchhoff vertex conditions \[\begin{equation} \label{eq:kirchhoff_cond} \tag{1} \mathcal{K}(\Gamma) = \left\{f\in C(\Gamma)\;\middle|\; \forall v\in \mathcal{V}:\; \sum_{e\in\mathcal{E}_v}\partial_e f(v)=0 \right\}, \end{equation}\] where \(\mathcal{E}_v\) denotes the set of edges incident to \(v\), and \[\begin{equation} \label{eq:dir_der} \tag{2} \partial_ef(v) = \begin{cases} f'_e(0), \quad &\text{if }v=0,\\ -f'_e(\ell_e), \quad &\text{if }v=\ell_e. \end{cases} \end{equation}\]
apply_edge_functions_fast <- function(graph, f_list) {
if (length(f_list) != graph$nE) {
stop(sprintf(
"Number of functions (%d) must equal number of edges (%d).",
length(f_list), graph$nE
))
}
VtE <- graph$mesh$VtE
edge_lengths <- graph$edge_lengths
edge <- VtE[,1]
s_norm <- VtE[,2]
s_true <- s_norm * edge_lengths[edge]
out <- sapply(seq_len(nrow(VtE)), function(i) f_list[[edge[i]]](s_true[i]))
return(out)
}We first assume that the edges are compatibly oriented, namely \(e_1 = [0,\ell_1]\) and \(e_2=[0,\ell_2]\), with the vertex \(v\) corresponding to \(\ell_1\) on \(e_1\) and \(0\) on \(e_2\). With this parametrization, we can glue the two edges into a single interval \([e_1,e_2]\simeq [0,\ell_1+\ell_2]\) and view a function \(f = \{f_{e_1},f_{e_2}\}\in C(\Gamma)\) as a function \(\hat{f}\in C([0,\ell_1+\ell_2])\) so that \(f_{e_1}(\ell_1) = \hat{f}(v) = f_{e_2}(0)\). Consider the function \(f = \{f_{e_1},f_{e_2}\}\) given by \[\begin{equation*} \begin{cases} f_{e_1}(t) = t^4,& t\in[0,\ell_1],\\ f_{e_2}(t) = (t+\ell_1)^4,& t\in[0,\ell_2]. \end{cases} \end{equation*}\] Its edgewise derivatives are given by \[\begin{equation*} \begin{cases} f'_{e_1}(t) = 4t^3,& t\in[0,\ell_1],\\ f'_{e_2}(t) = 4(t+\ell_1)^3,& t\in[0,\ell_2]. \end{cases} \end{equation*}\] Under the above identification, \(f\) corresponds to the function \[\begin{align*} \hat{f}(t) = t^4,\quad t\in[0,\ell_1 + \ell_2], \end{align*}\] whose derivative is \[\begin{align*} \hat{f}(t) = 4t^3,\quad t\in[0,\ell_1 + \ell_2]. \end{align*}\] In particular, \(\hat{f} \in C^1([0,\ell_1+\ell_2])\), and therefore \(f\) has a continuous first derivative across the vertex \(v\). See Figure 2. Moreover, the edgewise derivatives must agree at \(v\), that is, we must have \(f'_{e_1}(\ell_1) = \hat{f}'(v) = f'_{e_2}(0)\), which is the case since \[\begin{align*} f'_{e_1}(\ell_1) = 4\ell_1^3\quad\text{ and }\quad \hat{f}'(v) = \hat{f}'(\ell_1)=4\ell_1^3\quad \text{ and }\quad f'_{e_2}(0) = 4\ell_1^3. \end{align*}\] By using \(\eqref{eq:dir_der}\), we get that \[\begin{align*} \partial_{e_1}f(v) = -f'_{e_1}(\ell_1)=-4\ell_1^3\quad\text{ and }\quad \partial_{e_2}f(v) = f'_{e_2}(0)=4\ell_1^3, \end{align*}\] and therefore, \[\begin{equation} \sum_{e \in \mathcal{E}_v} \partial_e f(v) =\partial_{e_1}f(v) + \partial_{e_2}f(v) = -f'_{e_1}(\ell_1) + f'_{e_2}(0) = -4\ell_1^3 + 4\ell_1^3 = 0, \end{equation}\] which means that \(f\) satisfies the Kirchhoff vertex conditions \(\eqref{eq:kirchhoff_cond}\) at vertex \(v\). This is an instance of the fact that \(f\) satisfies the Kirchhoff vertex conditions \(\eqref{eq:kirchhoff_cond}\) at all vertices \(v\) with \(\deg(v) =2\) if and only if \(f'\) is continuous at at all vertices \(v\) with \(\deg(v) =2\).
h = 0.01
ell1 <- 1
ell2 <- 0.4
e1 <- rbind(c(-ell1,0), # (x,y) = underline(e_1)
c(0,0)) # (x,y) = overline(e_1)
e2 <- rbind(c(0,0),
c(ell2,0))
e1_ini_x <- -ell1; e1_ini_y <- 0; e1_ini_z <- 0
e1_fin_x <- 0; e1_fin_y <- 0; e1_fin_z <- 0
# Midpoint
xm1 <- (e1_fin_x + e1_ini_x)/2
ym1 <- (e1_fin_y + e1_ini_y)/2
zm1 <- (e1_fin_z + e1_ini_z)/2
# Direction vector
dx1 <- e1_fin_x - e1_ini_x
dy1 <- e1_fin_y - e1_ini_y
dz1 <- e1_fin_z - e1_ini_z
e2_ini_x <- 0; e2_ini_y <- 0; e2_ini_z <- 0
e2_fin_x <- ell2; e2_fin_y <- 0; e2_fin_z <- 0
# Midpoint
xm2 <- (e2_fin_x + e2_ini_x)/2
ym2 <- (e2_fin_y + e2_ini_y)/2
zm2 <- (e2_fin_z + e2_ini_z)/2
# Direction vector
dx2 <- e2_fin_x - e2_ini_x
dy2 <- e2_fin_y - e2_ini_y
dz2 <- e2_fin_z - e2_ini_z
graph <- metric_graph$new(edges = list(e1 = e1, e2 = e2))
graph$build_mesh(h = h)fe1 <- function(t) t^4
fe2 <- function(t) (t + ell1)^4
dfe1 <- function(t) 4*t^3
dfe2 <- function(t) 4*(t + ell1)^3
ddfe1 <- function(t) 12*t^2
ddfe2 <- function(t) 12*(t + ell1)^2
dddfe1 <- function(t) 24*t
dddfe2 <- function(t) 24*(t + ell1)
f_list <- list(fe1, fe2)
df_list <- list(dfe1, dfe2)
ddf_list <- list(ddfe1, ddfe2)
dddf_list <- list(dddfe1, dddfe2)
f_list_aux <- f_list
df_list_aux <- df_list
ddf_list_aux <- ddf_list
dddf_list_aux <- dddf_list
f <- apply_edge_functions_fast(graph, f_list)
df <- apply_edge_functions_fast(graph, df_list)
ddf <- apply_edge_functions_fast(graph, ddf_list)
dddf <- apply_edge_functions_fast(graph, dddf_list)sizeref <- 0.1
pf <- graph$plot_function(X = f, vertex_size = gsw, edge_width = gsw, line_width = gsw, type = "plotly") |>
add_trace(
type = "cone",
x = ym1,
y = xm1,
z = zm1,
u = dy1,
v = dx1,
w = dz1,
sizemode = "absolute",
sizeref = sizeref,
showscale = FALSE,
showlegend = FALSE,
colorscale = list(c(0, 1), c("green", "green")),
cmin = 0,
cmax = 1
) |>
add_trace(
type = "cone",
x = ym2,
y = xm2,
z = zm2,
u = dy2,
v = dx2,
w = dz2,
sizemode = "absolute",
sizeref = sizeref,
showscale = FALSE,
showlegend = FALSE,
colorscale = list(c(0, 1), c("green", "green")),
cmin = 0,
cmax = 1
) |>
config(mathjax = 'cdn') |>
plotly::layout(title = list(text = TeX("f"), y = 0.8),
font = list(family = "Palatino"),
scene = list(xaxis = list(title = list(text = "x", font = list(color = colaxnn)), tickfont = list(color = colaxnn)),
yaxis = list(title = list(text = "y", font = list(color = colaxnn)), tickfont = list(color = colaxnn)),
zaxis = list(title = list(text = "z", font = list(color = colaxnn)), tickfont = list(color = colaxnn)),
aspectratio = list(x = 2,
y = 2,
z = 2),
camera = list(eye = list(x = x_eye,
y = y_eye,
z = z_eye),
center = list(x = 0,
y = 0,
z = 0)),
annotations = list(
list(
x = e1_ini_y, y = e1_ini_x, z = e1_ini_z,
text = TeX("v_1"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = 0, y = 0, z = 0,
text = TeX("v"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = e2_fin_y, y = e2_fin_x, z = e2_fin_z,
text = TeX("v_2"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = ym1, y = xm1, z = zm1,
text = TeX("e_1"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = ym2, y = xm2, z = zm2,
text = TeX("e_2"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"))
))
pdf <- graph$plot_function(X = df, vertex_size = gsw, edge_width = gsw, line_width = gsw, type = "plotly") |>
add_trace(
type = "cone",
x = ym1,
y = xm1,
z = zm1,
u = dy1,
v = dx1,
w = dz1,
sizemode = "absolute",
sizeref = sizeref,
showscale = FALSE,
showlegend = FALSE,
colorscale = list(c(0, 1), c("green", "green")),
cmin = 0,
cmax = 1
) |>
add_trace(
type = "cone",
x = ym2,
y = xm2,
z = zm2,
u = dy2,
v = dx2,
w = dz2,
sizemode = "absolute",
sizeref = sizeref,
showscale = FALSE,
showlegend = FALSE,
colorscale = list(c(0, 1), c("green", "green")),
cmin = 0,
cmax = 1
) |>
config(mathjax = 'cdn') |>
plotly::layout(title = list(text = TeX("f'"), y = 0.8),
font = list(family = "Palatino"),
scene = list(xaxis = list(title = list(text = "x", font = list(color = colaxnn)), tickfont = list(color = colaxnn)),
yaxis = list(title = list(text = "y", font = list(color = colaxnn)), tickfont = list(color = colaxnn)),
zaxis = list(title = list(text = "z", font = list(color = colaxnn)), tickfont = list(color = colaxnn)),
aspectratio = list(x = 2,
y = 2,
z = 2),
camera = list(eye = list(x = x_eye,
y = y_eye,
z = z_eye),
center = list(x = 0,
y = 0,
z = 0)),
annotations = list(
list(
x = e1_ini_y, y = e1_ini_x, z = e1_ini_z,
text = TeX("v_1"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = 0, y = 0, z = 0,
text = TeX("v"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = e2_fin_y, y = e2_fin_x, z = e2_fin_z,
text = TeX("v_2"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = ym1, y = xm1, z = zm1,
text = TeX("e_1"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = ym2, y = xm2, z = zm2,
text = TeX("e_2"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"))
))
pddf <- graph$plot_function(X = ddf, vertex_size = gsw, edge_width = gsw, line_width = gsw, type = "plotly") |>
add_trace(
type = "cone",
x = ym1,
y = xm1,
z = zm1,
u = dy1,
v = dx1,
w = dz1,
sizemode = "absolute",
sizeref = sizeref,
showscale = FALSE,
showlegend = FALSE,
colorscale = list(c(0, 1), c("green", "green")),
cmin = 0,
cmax = 1
) |>
add_trace(
type = "cone",
x = ym2,
y = xm2,
z = zm2,
u = dy2,
v = dx2,
w = dz2,
sizemode = "absolute",
sizeref = sizeref,
showscale = FALSE,
showlegend = FALSE,
colorscale = list(c(0, 1), c("green", "green")),
cmin = 0,
cmax = 1
) |>
config(mathjax = 'cdn') |>
plotly::layout(title = list(text = TeX("f''"), y = 0.8),
font = list(family = "Palatino"),
scene = list(xaxis = list(title = list(text = "x", font = list(color = colaxnn)), tickfont = list(color = colaxnn)),
yaxis = list(title = list(text = "y", font = list(color = colaxnn)), tickfont = list(color = colaxnn)),
zaxis = list(title = list(text = "z", font = list(color = colaxnn)), tickfont = list(color = colaxnn)),
aspectratio = list(x = 2,
y = 2,
z = 2),
camera = list(eye = list(x = x_eye,
y = y_eye,
z = z_eye),
center = list(x = 0,
y = 0,
z = 0)),
annotations = list(
list(
x = e1_ini_y, y = e1_ini_x, z = e1_ini_z,
text = TeX("v_1"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = 0, y = 0, z = 0,
text = TeX("v"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = e2_fin_y, y = e2_fin_x, z = e2_fin_z,
text = TeX("v_2"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = ym1, y = xm1, z = zm1,
text = TeX("e_1"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = ym2, y = xm2, z = zm2,
text = TeX("e_2"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"))
))
pdddf <- graph$plot_function(X = dddf, vertex_size = gsw, edge_width = gsw, line_width = gsw, type = "plotly") |>
add_trace(
type = "cone",
x = ym1,
y = xm1,
z = zm1,
u = dy1,
v = dx1,
w = dz1,
sizemode = "absolute",
sizeref = sizeref,
showscale = FALSE,
showlegend = FALSE,
colorscale = list(c(0, 1), c("green", "green")),
cmin = 0,
cmax = 1
) |>
add_trace(
type = "cone",
x = ym2,
y = xm2,
z = zm2,
u = dy2,
v = dx2,
w = dz2,
sizemode = "absolute",
sizeref = sizeref,
showscale = FALSE,
showlegend = FALSE,
colorscale = list(c(0, 1), c("green", "green")),
cmin = 0,
cmax = 1
) |>
config(mathjax = 'cdn') |>
plotly::layout(title = list(text = TeX("f'''"), y = 0.8),
font = list(family = "Palatino"),
scene = list(xaxis = list(title = list(text = "x", font = list(color = colaxnn)), tickfont = list(color = colaxnn)),
yaxis = list(title = list(text = "y", font = list(color = colaxnn)), tickfont = list(color = colaxnn)),
zaxis = list(title = list(text = "z", font = list(color = colaxnn)), tickfont = list(color = colaxnn)),
aspectratio = list(x = 2,
y = 2,
z = 2),
camera = list(eye = list(x = x_eye,
y = y_eye,
z = z_eye),
center = list(x = 0,
y = 0,
z = 0)),
annotations = list(
list(
x = e1_ini_y, y = e1_ini_x, z = e1_ini_z,
text = TeX("v_1"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = 0, y = 0, z = 0,
text = TeX("v"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = e2_fin_y, y = e2_fin_x, z = e2_fin_z,
text = TeX("v_2"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = ym1, y = xm1, z = zm1,
text = TeX("e_1"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = ym2, y = xm2, z = zm2,
text = TeX("e_2"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"))
))
save(pf, file = here::here("data_files/pf.Rdata"))
save(pdf, file = here::here("data_files/pdf.Rdata"))
save(pddf, file = here::here("data_files/pddf.Rdata"))
save(pdddf, file = here::here("data_files/pdddf.Rdata"))Figure 1: Function \(f = \{f_e\}_{e\in\mathcal{E}}\) given by \(f_{e_1}(t) = t^4\) and \(f_{e_2}(t) = (t+\ell_1)^4\).
Figure 2: Function \(f' = \{f'_e\}_{e\in\mathcal{E}}\) given by \(f'_{e_1}(t) = 4t^3\) and \(f'_{e_2}(t) = 4(t+\ell_1)^3\).
Figure 3: Function \(f'' = \{f''_e\}_{e\in\mathcal{E}}\) given by \(f''_{e_1}(t) = 12t^2\) and \(f''_{e_2}(t) = 12(t+\ell_1)^2\).
my_apply_edge_functions <- function(graph, f_list, ell1, ell2, h){
l1_mesh <- seq(0, ell1, by = h)
l2_mesh <- seq(0, ell2, by = h)
f1 <- f_list[[1]](l1_mesh)
f2 <- f_list[[2]](l2_mesh)
l1_mesh_norm <- l1_mesh/ell1
l2_mesh_norm <- l2_mesh/ell2
PtE1 <- cbind(rep(1, length(l1_mesh)), l1_mesh_norm)
PtE2 <- cbind(rep(2, length(l2_mesh)), l2_mesh_norm)
XY1 <- graph$coordinates(PtE1)
XY2 <- graph$coordinates(PtE2)
DF1 <- data.frame(x = XY1[,1], y = XY1[,2], z = f1)
DF2 <- data.frame(x = XY2[,1], y = XY2[,2], z = f2)
DF <- rbind(DF1, rep(NA, 3), DF2)
return(list(DF = DF))
}Now study the case where the edges are not compatible oriented. For that, we flip edge \(e_2\), that is, \(e_1 = [0,\ell_1]\) and \(e_2=[0,\ell_2]\) with \(v\) corresponding to \(\ell_1\) on \(e_1\) and \(\ell_2\) on \(e_2\). Consider the function \(g = \{g_{e_1},g_{e_2}\}\) given by \[\begin{equation*} \begin{cases} g_{e_1}(\tau) = \tau^4,& \tau\in[0,\ell_1],\\ g_{e_2}(\tau) = (\tau-(\ell_1+\ell_2))^4,& \tau\in[0,\ell_2]. \end{cases} \end{equation*}\] Its edgewise derivatives are given by \[\begin{equation*} \begin{cases} g'_{e_1}(\tau) = 4\tau^3,& \tau\in[0,\ell_1],\\ g'_{e_2}(\tau) = 4(\tau-(\ell_1+\ell_2))^3,& \tau\in[0,\ell_2]. \end{cases} \end{equation*}\] The coordinates derivatives at \(v\) are given by \[\begin{equation} g'_{e_1}(\ell_1)=4\ell_1^3\quad\text{ and }\quad g'_{e_2}(\ell_2)=-4\ell_1^3. \end{equation}\] Let us check the Kirchhoff vertex conditions \(\eqref{eq:kirchhoff_cond}\) at vertex \(v\). By using \(\eqref{eq:dir_der}\), we get that \[\begin{align*} \partial_{e_1}g(v) = -g'_{e_1}(\ell_1)=-4\ell_1^3\quad\text{ and }\quad \partial_{e_2}g(v) = -g'_{e_2}(\ell_2)=4\ell_1^3, \end{align*}\] and therefore, \[\begin{equation} \label{eq:invariant_c} \tag{3} \sum_{e \in \mathcal{E}_v} \partial_e g(v) =\partial_{e_1}g(v) + \partial_{e_2}g(v) = -g'_{e_1}(\ell_1) -g'_{e_2}(\ell_2) = -4\ell_1^3 + 4\ell_1^3 = 0, \end{equation}\] which shows that \(g\) satisfies the Kirchhoff vertex conditions \(\eqref{eq:kirchhoff_cond}\) at vertex \(v\). At first glance, the edgewise derivative, \(g' = \{g'_{e_1},g'_{e_2}\}\) appears discontinuous at \(v\), which might seem contradictory. See Figure 6.
To clarify, observe that \(f = g\) as functions on the graph. Indeed, by reparametrizing edge \(e_1\) by \(\tau=t\) and edge \(e_2\) by \(\tau = \ell_2-t\), we obtain \(f_{e_1}=g_{e_1}\) and \(f_{e_2}=g_{e_2}\). More precisely, \[\begin{align} \label{eq:eq_of_f_g} \tag{4} g_{e_1}(\tau) = g_{e_1}(t) = t^4 = f_{e_1}(t)\quad\text{ and }\quad g_{e_2}(\tau) = g_{e_2}(\ell_2-t) = (\ell_2-t-(\ell_1+\ell_2))^4 = (t+\ell_1)^4= f_{e_2}(t), \end{align}\] Thus \(f\) and \(g\) coincide on each edge after reparametrization, and define the same function on the graph. The apparent discontinuity of \(g'\) arises solely from the reversed coordinate on \(e_2\). The function itself has not changed, only its coordinate representation.
From \(\eqref{eq:eq_of_f_g}\), by the chain rule, the first derivative transforms as \[\begin{equation} \label{eq:der_inv} \tag{5} g'_{e_2}(\tau) = \dfrac{d}{d\tau} (g_{e_2}(\tau)) = \dfrac{d}{d\tau} (f_{e_2}(t)) = \dfrac{d}{dt} (f_{e_2}(t)) \dfrac{dt}{d\tau} = - \dfrac{d}{dt} (f_{e_2}(t)) = - f'_{e_2}(t) \end{equation}\]
so the coordinate derivative changes sign under reparametrization. Hence, edgewise derivatives are not invariant under orientation changes. By contrast, the outward derivative \(\partial_e g(v)\) is invariant, and is therefore the correct intrinsic quantity to check the Kirchhoff condition.
In the compatible orientation case, \(f'_{e_1}(\ell_1) = f'_{e_2}(0)\), so the coordinate derivatives match. In the flipped orientation case, \(g'_{e_1}(\ell_1) \neq g'_{e_2}(\ell_2)\), but this mismatch is purely a consequence of the reversed parametrization. The correct invariant comparison is \(\eqref{eq:invariant_c}\), which demonstrates that the Kirchhoff condition is intrinsic and independent of edge parametrization.
In conclusion, the apparent contradiction arises only when comparing coordinate derivatives with opposite orientations, which is not geometrically meaningful. Continuity of the derivative at a vertex must be interpreted intrinsically: at a degree-two vertex, this intrinsic continuity is equivalent to the Kirchhoff condition.
e1_ini_x <- -ell1; e1_ini_y <- 0; e1_ini_z <- 0
e1_fin_x <- 0; e1_fin_y <- 0; e1_fin_z <- 0
# Midpoint
xm1 <- (e1_fin_x + e1_ini_x)/2
ym1 <- (e1_fin_y + e1_ini_y)/2
zm1 <- (e1_fin_z + e1_ini_z)/2
# Direction vector
dx1 <- e1_fin_x - e1_ini_x
dy1 <- e1_fin_y - e1_ini_y
dz1 <- e1_fin_z - e1_ini_z
e2_ini_x <- ell2; e2_ini_y <- 0; e2_ini_z <- 0
e2_fin_x <- 0; e2_fin_y <- 0; e2_fin_z <- 0
# Midpoint
xm2 <- (e2_fin_x + e2_ini_x)/2
ym2 <- (e2_fin_y + e2_ini_y)/2
zm2 <- (e2_fin_z + e2_ini_z)/2
# Direction vector
dx2 <- e2_fin_x - e2_ini_x
dy2 <- e2_fin_y - e2_ini_y
dz2 <- e2_fin_z - e2_ini_zfe1 <- function(t) t^4
fe2 <- function(t) (t - (ell1 + ell2))^4
dfe1 <- function(t) 4*t^3
dfe2 <- function(t) 4*(t - (ell1 + ell2))^3
ddfe1 <- function(t) 12*t^2
ddfe2 <- function(t) 12*(t - (ell1 + ell2))^2
dddfe1 <- function(t) 24*t
dddfe2 <- function(t) 24*(t - (ell1 + ell2))
f_list <- list(fe1, fe2)
df_list <- list(dfe1, dfe2)
ddf_list <- list(ddfe1, ddfe2)
dddf_list <- list(dddfe1, dddfe2)
f <- my_apply_edge_functions(graph, f_list, ell1, ell2, h)
df <- my_apply_edge_functions(graph, df_list, ell1, ell2, h)
ddf <- my_apply_edge_functions(graph, ddf_list, ell1, ell2, h)
dddf <- my_apply_edge_functions(graph, dddf_list, ell1, ell2, h)
f_aux <- my_apply_edge_functions(graph, f_list_aux, ell1, ell2, h)
df_aux <- my_apply_edge_functions(graph, df_list_aux, ell1, ell2, h)
ddf_aux <- my_apply_edge_functions(graph, ddf_list_aux, ell1, ell2, h)
dddf_aux <- my_apply_edge_functions(graph, dddf_list_aux, ell1, ell2, h)p_base <- graph$plot_function(X = rep(0, nrow(graph$mesh$VtE)), vertex_size = gsw, line_color = "black", edge_width = gsw, line_width = gsw, type = "plotly")
DF <- f$DF
pf3 <- p_base |>
add_trace(
type = "cone",
x = ym1,
y = xm1,
z = zm1,
u = dy1,
v = dx1,
w = dz1,
sizemode = "absolute",
sizeref = sizeref,
showscale = FALSE,
showlegend = FALSE,
colorscale = list(c(0, 1), c("red", "red")),
cmin = 0,
cmax = 1
) |>
add_trace(
type = "cone",
x = ym2,
y = xm2,
z = zm2,
u = dy2,
v = dx2,
w = dz2,
sizemode = "absolute",
sizeref = sizeref,
showscale = FALSE,
showlegend = FALSE,
colorscale = list(c(0, 1), c("red", "red")),
cmin = 0,
cmax = 1
) |>
add_trace(data = DF,
x = ~y,
y = ~x,
z = ~z,
type = "scatter3d",
mode = "lines",
line = list(color = "rgb(0,0,200)", width = gsw),
showlegend = FALSE) |>
add_trace(x = rep(DF$y, each = 3),
y = rep(DF$x, each = 3),
z = unlist(lapply(DF$z, function(zj) c(0, zj, NA))),
type = "scatter3d",
mode = "lines",
line = list(color = "gray", width = 0.5),
showlegend = FALSE) |>
config(mathjax = 'cdn') |>
plotly::layout(title = list(text = TeX("g"), y = 0.8),
font = list(family = "Palatino"),
scene = list(xaxis = list(title = list(text = "x", font = list(color = colaxnn)), tickfont = list(color = colaxnn)),
yaxis = list(title = list(text = "y", font = list(color = colaxnn)), tickfont = list(color = colaxnn)),
zaxis = list(title = list(text = "z", font = list(color = colaxnn)), tickfont = list(color = colaxnn)),
aspectratio = list(x = 2,
y = 2,
z = 2),
camera = list(eye = list(x = x_eye,
y = y_eye,
z = z_eye),
center = list(x = 0,
y = 0,
z = 0)),
annotations = list(
list(
x = e1_ini_y, y = e1_ini_x, z = e1_ini_z,
text = TeX("v_1"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = 0, y = 0, z = 0,
text = TeX("v"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = e2_ini_y, y = e2_ini_x, z = e2_ini_z,
text = TeX("v_2"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = ym1, y = xm1, z = zm1,
text = TeX("e_1"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = ym2, y = xm2, z = zm2,
text = TeX("\\hat{e}_2"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"))
))
DF <- df$DF
pdf3 <- p_base |>
add_trace(
type = "cone",
x = ym1,
y = xm1,
z = zm1,
u = dy1,
v = dx1,
w = dz1,
sizemode = "absolute",
sizeref = sizeref,
showscale = FALSE,
showlegend = FALSE,
colorscale = list(c(0, 1), c("red", "red")),
cmin = 0,
cmax = 1
) |>
add_trace(
type = "cone",
x = ym2,
y = xm2,
z = zm2,
u = dy2,
v = dx2,
w = dz2,
sizemode = "absolute",
sizeref = sizeref,
showscale = FALSE,
showlegend = FALSE,
colorscale = list(c(0, 1), c("red", "red")),
cmin = 0,
cmax = 1
) |>
add_trace(data = DF,
x = ~y,
y = ~x,
z = ~z,
type = "scatter3d",
mode = "lines",
line = list(color = "rgb(0,0,200)", width = gsw),
showlegend = FALSE) |>
add_trace(x = rep(DF$y, each = 3),
y = rep(DF$x, each = 3),
z = unlist(lapply(DF$z, function(zj) c(0, zj, NA))),
type = "scatter3d",
mode = "lines",
line = list(color = "gray", width = 0.5),
showlegend = FALSE) |>
config(mathjax = 'cdn') |>
plotly::layout(title = list(text = TeX("g'"), y = 0.8),
font = list(family = "Palatino"),
scene = list(xaxis = list(title = list(text = "x", font = list(color = colaxnn)), tickfont = list(color = colaxnn)),
yaxis = list(title = list(text = "y", font = list(color = colaxnn)), tickfont = list(color = colaxnn)),
zaxis = list(title = list(text = "z", font = list(color = colaxnn)), tickfont = list(color = colaxnn)),
aspectratio = list(x = 2,
y = 2,
z = 2),
camera = list(eye = list(x = x_eye,
y = y_eye,
z = z_eye),
center = list(x = 0,
y = 0,
z = 0)),
annotations = list(
list(
x = e1_ini_y, y = e1_ini_x, z = e1_ini_z,
text = TeX("v_1"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = 0, y = 0, z = 0,
text = TeX("v"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = e2_ini_y, y = e2_ini_x, z = e2_ini_z,
text = TeX("v_2"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = ym1, y = xm1, z = zm1,
text = TeX("e_1"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = ym2, y = xm2, z = zm2,
text = TeX("\\hat{e}_2"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"))
))
DF <- ddf$DF
pddf3 <- p_base |>
add_trace(
type = "cone",
x = ym1,
y = xm1,
z = zm1,
u = dy1,
v = dx1,
w = dz1,
sizemode = "absolute",
sizeref = sizeref,
showscale = FALSE,
showlegend = FALSE,
colorscale = list(c(0, 1), c("red", "red")),
cmin = 0,
cmax = 1
) |>
add_trace(
type = "cone",
x = ym2,
y = xm2,
z = zm2,
u = dy2,
v = dx2,
w = dz2,
sizemode = "absolute",
sizeref = sizeref,
showscale = FALSE,
showlegend = FALSE,
colorscale = list(c(0, 1), c("red", "red")),
cmin = 0,
cmax = 1
) |>
add_trace(data = DF,
x = ~y,
y = ~x,
z = ~z,
type = "scatter3d",
mode = "lines",
line = list(color = "rgb(0,0,200)", width = gsw),
showlegend = FALSE) |>
add_trace(x = rep(DF$y, each = 3),
y = rep(DF$x, each = 3),
z = unlist(lapply(DF$z, function(zj) c(0, zj, NA))),
type = "scatter3d",
mode = "lines",
line = list(color = "gray", width = 0.5),
showlegend = FALSE) |>
config(mathjax = 'cdn') |>
plotly::layout(title = list(text = TeX("g''"), y = 0.8),
font = list(family = "Palatino"),
scene = list(xaxis = list(title = list(text = "x", font = list(color = colaxnn)), tickfont = list(color = colaxnn)),
yaxis = list(title = list(text = "y", font = list(color = colaxnn)), tickfont = list(color = colaxnn)),
zaxis = list(title = list(text = "z", font = list(color = colaxnn)), tickfont = list(color = colaxnn)),
aspectratio = list(x = 2,
y = 2,
z = 2),
camera = list(eye = list(x = x_eye,
y = y_eye,
z = z_eye),
center = list(x = 0,
y = 0,
z = 0)),
annotations = list(
list(
x = e1_ini_y, y = e1_ini_x, z = e1_ini_z,
text = TeX("v_1"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = 0, y = 0, z = 0,
text = TeX("v"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = e2_ini_y, y = e2_ini_x, z = e2_ini_z,
text = TeX("v_2"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = ym1, y = xm1, z = zm1,
text = TeX("e_1"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = ym2, y = xm2, z = zm2,
text = TeX("\\hat{e}_2"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"))
))
DF <- dddf$DF
pdddf3 <- p_base |>
add_trace(
type = "cone",
x = ym1,
y = xm1,
z = zm1,
u = dy1,
v = dx1,
w = dz1,
sizemode = "absolute",
sizeref = sizeref,
showscale = FALSE,
showlegend = FALSE,
colorscale = list(c(0, 1), c("red", "red")),
cmin = 0,
cmax = 1
) |>
add_trace(
type = "cone",
x = ym2,
y = xm2,
z = zm2,
u = dy2,
v = dx2,
w = dz2,
sizemode = "absolute",
sizeref = sizeref,
showscale = FALSE,
showlegend = FALSE,
colorscale = list(c(0, 1), c("red", "red")),
cmin = 0,
cmax = 1
) |>
add_trace(data = DF,
x = ~y,
y = ~x,
z = ~z,
type = "scatter3d",
mode = "lines",
line = list(color = "rgb(0,0,200)", width = gsw),
showlegend = FALSE) |>
add_trace(x = rep(DF$y, each = 3),
y = rep(DF$x, each = 3),
z = unlist(lapply(DF$z, function(zj) c(0, zj, NA))),
type = "scatter3d",
mode = "lines",
line = list(color = "gray", width = 0.5),
showlegend = FALSE) |>
config(mathjax = 'cdn') |>
plotly::layout(title = list(text = TeX("g'''"), y = 0.8),
font = list(family = "Palatino"),
scene = list(xaxis = list(title = list(text = "x", font = list(color = colaxnn)), tickfont = list(color = colaxnn)),
yaxis = list(title = list(text = "y", font = list(color = colaxnn)), tickfont = list(color = colaxnn)),
zaxis = list(title = list(text = "z", font = list(color = colaxnn)), tickfont = list(color = colaxnn)),
aspectratio = list(x = 2,
y = 2,
z = 2),
camera = list(eye = list(x = x_eye,
y = y_eye,
z = z_eye),
center = list(x = 0,
y = 0,
z = 0)),
annotations = list(
list(
x = e1_ini_y, y = e1_ini_x, z = e1_ini_z,
text = TeX("v_1"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = 0, y = 0, z = 0,
text = TeX("v"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = e2_ini_y, y = e2_ini_x, z = e2_ini_z,
text = TeX("v_2"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = ym1, y = xm1, z = zm1,
text = TeX("e_1"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = ym2, y = xm2, z = zm2,
text = TeX("\\hat{e}_2"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"))
))
save(pf3, file = here::here("data_files/pf3.Rdata"))
save(pdf3, file = here::here("data_files/pdf3.Rdata"))
save(pddf3, file = here::here("data_files/pddf3.Rdata"))
save(pdddf3, file = here::here("data_files/pdddf3.Rdata"))Figure 5: Function \(g = \{g_e\}_{e\in\mathcal{E}}\) given by \(g_{e_1}(\tau) = \tau^4\) and \(g_{\hat{e}_2}(\tau) = (\tau-(\ell_1+\ell_2))^4\).
Figure 6: Function \(g' = \{g'_e\}_{e\in\mathcal{E}}\) given by \(g'_{e_1}(\tau) = 4\tau^3\) and \(g'_{\hat{e}_2}(\tau) = 4(\tau-(\ell_1+\ell_2))^3\).
Figure 7: Function \(g'' = \{g''_e\}_{e\in\mathcal{E}}\) given by \(g''_{e_1}(\tau) = 12\tau^2\) and \(g''_{\hat{e}_2}(\tau) = 12(\tau-(\ell_1+\ell_2))^2\).
Figure 6 illustrates precisely the relation expressed in \(\eqref{eq:der_inv}\). That is, \(g'_{e_2}\) can be obtained by multiplying \(f'_{e_2}\) by \(-1\).
We again apply the chain rule in \(\eqref{eq:der_inv}\) to obtain \[\begin{equation} g''_{e_2}(\tau) = \dfrac{d}{d\tau} ( - f'_{e_2}(t)) = - \dfrac{d}{dt} (f'_{e_2}(t)) \dfrac{dt}{d\tau} = f''_{e_2}(t), \end{equation}\] so that the second derivative does not change sign under a flip. See Figure 7. This means that even order derivatives are orientation-independent. In general, for the \(k\)-th derivative, we have \[\begin{equation} \dfrac{d^k}{d\tau^k}(g_{e_2}(\tau)) = (-1)^k\dfrac{d^k}{dt^k}(f_{e_2}(t)). \end{equation}\]
DF <- f_aux$DF
pf_aux <- p_base |>
add_trace(
type = "cone",
x = ym1,
y = xm1,
z = zm1,
u = dy1,
v = dx1,
w = dz1,
sizemode = "absolute",
sizeref = sizeref,
showscale = FALSE,
showlegend = FALSE,
colorscale = list(c(0, 1), c("red", "red")),
cmin = 0,
cmax = 1
) |>
add_trace(
type = "cone",
x = ym2,
y = xm2,
z = zm2,
u = dy2,
v = dx2,
w = dz2,
sizemode = "absolute",
sizeref = sizeref,
showscale = FALSE,
showlegend = FALSE,
colorscale = list(c(0, 1), c("red", "red")),
cmin = 0,
cmax = 1
) |>
add_trace(data = DF,
x = ~y,
y = ~x,
z = ~z,
type = "scatter3d",
mode = "lines",
line = list(color = "rgb(0,0,200)", width = gsw),
showlegend = FALSE) |>
add_trace(x = rep(DF$y, each = 3),
y = rep(DF$x, each = 3),
z = unlist(lapply(DF$z, function(zj) c(0, zj, NA))),
type = "scatter3d",
mode = "lines",
line = list(color = "gray", width = 0.5),
showlegend = FALSE) |>
config(mathjax = 'cdn') |>
plotly::layout(title = list(text = TeX("\\hat{f}"), y = 0.8),
font = list(family = "Palatino"),
scene = list(xaxis = list(title = list(text = "x", font = list(color = colaxnn)), tickfont = list(color = colaxnn)),
yaxis = list(title = list(text = "y", font = list(color = colaxnn)), tickfont = list(color = colaxnn)),
zaxis = list(title = list(text = "z", font = list(color = colaxnn)), tickfont = list(color = colaxnn)),
aspectratio = list(x = 2,
y = 2,
z = 2),
camera = list(eye = list(x = x_eye,
y = y_eye,
z = z_eye),
center = list(x = 0,
y = 0,
z = 0)),
annotations = list(
list(
x = e1_ini_y, y = e1_ini_x, z = e1_ini_z,
text = TeX("v_1"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = 0, y = 0, z = 0,
text = TeX("v"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = e2_ini_y, y = e2_ini_x, z = e2_ini_z,
text = TeX("v_2"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = ym1, y = xm1, z = zm1,
text = TeX("e_1"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = ym2, y = xm2, z = zm2,
text = TeX("\\hat{e}_2"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"))
))
DF <- df_aux$DF
pdf_aux <- p_base |>
add_trace(
type = "cone",
x = ym1,
y = xm1,
z = zm1,
u = dy1,
v = dx1,
w = dz1,
sizemode = "absolute",
sizeref = sizeref,
showscale = FALSE,
showlegend = FALSE,
colorscale = list(c(0, 1), c("red", "red")),
cmin = 0,
cmax = 1
) |>
add_trace(
type = "cone",
x = ym2,
y = xm2,
z = zm2,
u = dy2,
v = dx2,
w = dz2,
sizemode = "absolute",
sizeref = sizeref,
showscale = FALSE,
showlegend = FALSE,
colorscale = list(c(0, 1), c("red", "red")),
cmin = 0,
cmax = 1
) |>
add_trace(data = DF,
x = ~y,
y = ~x,
z = ~z,
type = "scatter3d",
mode = "lines",
line = list(color = "rgb(0,0,200)", width = gsw),
showlegend = FALSE) |>
add_trace(x = rep(DF$y, each = 3),
y = rep(DF$x, each = 3),
z = unlist(lapply(DF$z, function(zj) c(0, zj, NA))),
type = "scatter3d",
mode = "lines",
line = list(color = "gray", width = 0.5),
showlegend = FALSE) |>
config(mathjax = 'cdn') |>
plotly::layout(title = list(text = TeX("\\hat{f}'"), y = 0.8),
font = list(family = "Palatino"),
scene = list(xaxis = list(title = list(text = "x", font = list(color = colaxnn)), tickfont = list(color = colaxnn)),
yaxis = list(title = list(text = "y", font = list(color = colaxnn)), tickfont = list(color = colaxnn)),
zaxis = list(title = list(text = "z", font = list(color = colaxnn)), tickfont = list(color = colaxnn)),
aspectratio = list(x = 2,
y = 2,
z = 2),
camera = list(eye = list(x = x_eye,
y = y_eye,
z = z_eye),
center = list(x = 0,
y = 0,
z = 0)),
annotations = list(
list(
x = e1_ini_y, y = e1_ini_x, z = e1_ini_z,
text = TeX("v_1"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = 0, y = 0, z = 0,
text = TeX("v"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = e2_ini_y, y = e2_ini_x, z = e2_ini_z,
text = TeX("v_2"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = ym1, y = xm1, z = zm1,
text = TeX("e_1"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = ym2, y = xm2, z = zm2,
text = TeX("\\hat{e}_2"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"))
))
DF <- ddf_aux$DF
pddf_aux <- p_base |>
add_trace(
type = "cone",
x = ym1,
y = xm1,
z = zm1,
u = dy1,
v = dx1,
w = dz1,
sizemode = "absolute",
sizeref = sizeref,
showscale = FALSE,
showlegend = FALSE,
colorscale = list(c(0, 1), c("red", "red")),
cmin = 0,
cmax = 1
) |>
add_trace(
type = "cone",
x = ym2,
y = xm2,
z = zm2,
u = dy2,
v = dx2,
w = dz2,
sizemode = "absolute",
sizeref = sizeref,
showscale = FALSE,
showlegend = FALSE,
colorscale = list(c(0, 1), c("red", "red")),
cmin = 0,
cmax = 1
) |>
add_trace(data = DF,
x = ~y,
y = ~x,
z = ~z,
type = "scatter3d",
mode = "lines",
line = list(color = "rgb(0,0,200)", width = gsw),
showlegend = FALSE) |>
add_trace(x = rep(DF$y, each = 3),
y = rep(DF$x, each = 3),
z = unlist(lapply(DF$z, function(zj) c(0, zj, NA))),
type = "scatter3d",
mode = "lines",
line = list(color = "gray", width = 0.5),
showlegend = FALSE) |>
config(mathjax = 'cdn') |>
plotly::layout(title = list(text = TeX("\\hat{f}''"), y = 0.8),
font = list(family = "Palatino"),
scene = list(xaxis = list(title = list(text = "x", font = list(color = colaxnn)), tickfont = list(color = colaxnn)),
yaxis = list(title = list(text = "y", font = list(color = colaxnn)), tickfont = list(color = colaxnn)),
zaxis = list(title = list(text = "z", font = list(color = colaxnn)), tickfont = list(color = colaxnn)),
aspectratio = list(x = 2,
y = 2,
z = 2),
camera = list(eye = list(x = x_eye,
y = y_eye,
z = z_eye),
center = list(x = 0,
y = 0,
z = 0)),
annotations = list(
list(
x = e1_ini_y, y = e1_ini_x, z = e1_ini_z,
text = TeX("v_1"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = 0, y = 0, z = 0,
text = TeX("v"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = e2_ini_y, y = e2_ini_x, z = e2_ini_z,
text = TeX("v_2"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = ym1, y = xm1, z = zm1,
text = TeX("e_1"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = ym2, y = xm2, z = zm2,
text = TeX("\\hat{e}_2"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"))
))
DF <- dddf_aux$DF
pdddf_aux <- p_base |>
add_trace(
type = "cone",
x = ym1,
y = xm1,
z = zm1,
u = dy1,
v = dx1,
w = dz1,
sizemode = "absolute",
sizeref = sizeref,
showscale = FALSE,
showlegend = FALSE,
colorscale = list(c(0, 1), c("red", "red")),
cmin = 0,
cmax = 1
) |>
add_trace(
type = "cone",
x = ym2,
y = xm2,
z = zm2,
u = dy2,
v = dx2,
w = dz2,
sizemode = "absolute",
sizeref = sizeref,
showscale = FALSE,
showlegend = FALSE,
colorscale = list(c(0, 1), c("red", "red")),
cmin = 0,
cmax = 1
) |>
add_trace(data = DF,
x = ~y,
y = ~x,
z = ~z,
type = "scatter3d",
mode = "lines",
line = list(color = "rgb(0,0,200)", width = gsw),
showlegend = FALSE) |>
add_trace(x = rep(DF$y, each = 3),
y = rep(DF$x, each = 3),
z = unlist(lapply(DF$z, function(zj) c(0, zj, NA))),
type = "scatter3d",
mode = "lines",
line = list(color = "gray", width = 0.5),
showlegend = FALSE) |>
config(mathjax = 'cdn') |>
plotly::layout(title = list(text = TeX("\\hat{f}'''"), y = 0.8),
font = list(family = "Palatino"),
scene = list(xaxis = list(title = list(text = "x", font = list(color = colaxnn)), tickfont = list(color = colaxnn)),
yaxis = list(title = list(text = "y", font = list(color = colaxnn)), tickfont = list(color = colaxnn)),
zaxis = list(title = list(text = "z", font = list(color = colaxnn)), tickfont = list(color = colaxnn)),
aspectratio = list(x = 2,
y = 2,
z = 2),
camera = list(eye = list(x = x_eye,
y = y_eye,
z = z_eye),
center = list(x = 0,
y = 0,
z = 0)),
annotations = list(
list(
x = e1_ini_y, y = e1_ini_x, z = e1_ini_z,
text = TeX("v_1"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = 0, y = 0, z = 0,
text = TeX("v"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = e2_ini_y, y = e2_ini_x, z = e2_ini_z,
text = TeX("v_2"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = ym1, y = xm1, z = zm1,
text = TeX("e_1"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"),
list(
x = ym2, y = xm2, z = zm2,
text = TeX("\\hat{e}_2"),
textangle = 0, ax = 0, ay = 35,
font = list(color = "black", size = gfsize),
arrowcolor = "rgba(0,0,0,0)"))
))
save(pf_aux, file = here::here("data_files/pf_aux.Rdata"))
save(pdf_aux, file = here::here("data_files/pdf_aux.Rdata"))
save(pddf_aux, file = here::here("data_files/pddf_aux.Rdata"))
save(pdddf_aux, file = here::here("data_files/pdddf_aux.Rdata"))Figure 9: Function \(f = \{f_e\}_{e\in\mathcal{E}}\) given by \(f_{e_1}(t) = t^4\) and \(f_{e_2}(t) = (t+\ell_1)^4\).
Figure 10: Function \(\hat{f} = \{f_e\}_{e\in\mathcal{E}}\) given by \(f_{e_1}(t) = t^4\) and \(f_{\hat{e}_2}(t) = (t+\ell_1)^4\).
Figure 12: Function \(\hat{f} = \{f_e\}_{e\in\mathcal{E}}\) given by \(f_{e_1}(t) = t^4\) and \(f_{\hat{e}_2}(t) = (t+\ell_1)^4\).
Figure 13: Function \(\hat{f}' = \{f'_e\}_{e\in\mathcal{E}}\) given by \(f'_{e_1}(t) = 4t^3\) and \(f'_{\hat{e}_2}(t) = 4(t+\ell_1)^3\).
Figure 14: Function \(\hat{f}'' = \{f''_e\}_{e\in\mathcal{E}}\) given by \(f''_{e_1}(t) = 12t^2\) and \(f''_{\hat{e}_2}(t) = 12(t+\ell_1)^2\).
We used R version 4.5.2 (R Core Team 2025a) and the following R packages: cowplot v. 1.2.0 (Wilke 2025), ggmap v. 4.0.2 (Kahle and Wickham 2013), ggpubr v. 0.6.3 (Kassambara 2026), ggtext v. 0.1.2 (Wilke and Wiernik 2022), glue v. 1.8.0 (Hester and Bryan 2024), grid v. 4.5.2 (R Core Team 2025b), here v. 1.0.1 (Müller 2020), htmltools v. 0.5.8.1 (Cheng et al. 2024), INLA v. 25.11.22 (Rue, Martino, and Chopin 2009; Lindgren, Rue, and Lindström 2011; Martins et al. 2013; Lindgren and Rue 2015; De Coninck et al. 2016; Rue et al. 2017; Verbosio et al. 2017; Bakka et al. 2018; Kourounis, Fuchs, and Schenk 2018), inlabru v. 2.13.0 (Yuan et al. 2017; Bachl et al. 2019), knitr v. 1.50 (Xie 2014, 2015, 2025), latex2exp v. 0.9.8 (Meschiari 2026), Matrix v. 1.7.3 (Bates, Maechler, and Jagan 2025), MetricGraph v. 1.5.0.9000 (Bolin, Simas, and Wallin 2023a, 2023b, 2024, 2025; Bolin et al. 2024), OpenStreetMap v. 0.4.1 (Fellows and Stotz 2025), patchwork v. 1.3.1 (Pedersen 2025), plotly v. 4.11.0 (Sievert 2020), plotrix v. 3.8.14 (J 2006), renv v. 1.1.7 (Ushey and Wickham 2026), reshape2 v. 1.4.4 (Wickham 2007), reticulate v. 1.44.1 (Ushey, Allaire, and Tang 2025), rmarkdown v. 2.30 (Xie, Allaire, and Grolemund 2018; Xie, Dervieux, and Riederer 2020; Allaire et al. 2025), rSPDE v. 2.5.2.9000 (Bolin and Kirchner 2020; Bolin and Simas 2023; Bolin, Simas, and Xiong 2024), scales v. 1.4.0 (Wickham, Pedersen, and Seidel 2025), sf v. 1.1.0 (E. Pebesma 2018; E. Pebesma and Bivand 2023), slackr v. 3.4.0 (Kaye et al. 2025), sp v. 2.2.1 (E. J. Pebesma and Bivand 2005; Bivand, Pebesma, and Gomez-Rubio 2013), tidyverse v. 2.0.0 (Wickham et al. 2019), tikzDevice v. 0.12.6 (Sharpsteen and Bracken 2023), viridis v. 0.6.5 (Garnier et al. 2024), xaringanExtra v. 0.8.0 (Aden-Buie and Warkentin 2024).