It's known that we can easily define a function with optional value which is not related with other arguments, but my question is how can I define a function with an optional value which is really related with other variables.
For example
fun[a_, b_:g[a]] = a + g[a]
where g[a] = a^2
is a given function. I'd like to set the optional value of b
to be g[a]
.