text:
# Home Ground Advantage in AFL

### Dec. 16, 2019, 10:30 p.m.

So with the AFL off season underway I'm going to delve into some new stuff while there's time. I've got a few aims this off season:

• Explore some new analysis to improve upon my models for season 2020 - stuff like this HGA analysis and improving modelling of player information in match predictions.
• Explore some new modelling ideas for AFL - I'm looking into a new, more granular method of modelling AFL.
• Get an AFLW model up and running for next season.

I'm going to start off with some home ground advantage analysis. My model currently just considers travel distance and each teams historic performance at the venue to estimate the home ground advantage effect. I have a few doubts about this modelling now, such as:

• Historic venue performance is prone to over fitting. My model seems a little over fit in a few ways so I want to unwind this over fitting.
• Historic venue performance was calculated based on scoring shots, however HGA may have an impact on scoring accuracy or quality of shots generated too, so I think a score based rather than shots based model is more appropriate.
• My model was quite aggressive on the travel distance. As I don't take venue experience into consideration I think this was causing my model to weight travel distance a little too high. This meant for example that teams travelling to/from Perth were punished too much.

These doubts are based on nothing scientific, just my observations on how my models tips looked compared to other Squiggle models throughout the season.

#### Methodology

In this analysis, I've started with an ELO model that does not consider HGA, then I attempt to explain the margin errors using a variety of features compared for home vs away including:

• Travel Distance
• Venue Experience
• Season
• Round
• Average Historical Venue Performance
• Venue Dimensions relative to Home Venue
• Membership Figures

I found that I could explain HGA using Travel Distance + Venue Experience + Round + Average Historical Venue Performance, but all other features did not explain any of the remaining errors after these factors are taken into account. For those interested in how I came to this conclusion and how much each feature affects HGA, read on!

I started with an ELO model with no HGA considerations, so we've adjusted for team strengths as well as we can without modelling HGA. I used predictions for seasons 1897 - 2018, split into a 50% train and 50% test sets. As AFLTables designates the home team as the winner in finals, this could skew the results so I decided to exclude finals.

Next I collected the features used to explain HGA. The team specific features were calculated as differences such that a positive value should indicate an advantage to the home team. I split the values into those available for all matches, and those limited to fewer matches:

Available for all matches:

• Travel Distance: $\log(1 + \text{Away Team Distance in km}) - \log(1 + \text{Home Team Distance in km})$
• Venue Experience: For the 2 seasons prior to the match (i.e. excluding the current season): $\frac{\text{Home Team Matches at Venue}}{\text{Home Team Matches}} - \frac{\text{Away Team Matches at Venue}}{\text{Away Team Matches}}$
• Season: Year re based so that 1897 maps to 0 and 2018 maps to 121
• Round: $\frac{\text{Round Number}}{\text{Total Rounds in Season}}$
• Historical Venue Performance: Average performance at venue in terms of winning/losing margin relative to expectation in last 100 matches. I take this and multiply by matches considered/100 so there is less weight on historical venue performances over fewer matches. If a team has played less than 5 matches at the venue, I set historical venue performance to 0.

Available for select matches:

• Venue Length: $|\text{Away Team Venue Length} - \text{Match Venue Length}| - |\text{Home Team Venue Length} - \text{Match Venue Length}|$
• Venue Width: $|\text{Away Team Venue Width} - \text{Match Venue Width}| - |\text{Home Team Venue Width} - \text{Match Venue Width}|$
• Memberships: Based on members in prior season: $\frac{\text{Home Team Members}}{\text{Avg Members Per Club}} - \frac{\text{Away Team Member}}{\text{Avg Members Per Club}}$

The reasons for the transformations are as follows:

• We take the log of distance travelled as the effect is not linear. The burden of travelling from Perth to Sydney is not 22% higher than travelling from Perth to Melbourne, even though there is an extra 22% of distance to travel. Using logs puts the extra burden at 2% higher, which could still be wrong but seems more reasonable than 22%.

• We consider matches played at venue from the 2 prior seasons and not the current season as we don't want to introduce a feature that already has an impact from the round built in. If we use the current season, matches towards the end of the season will be assumed to have a higher HGA as there are just more matches that a team could have played at the same venue. HGA might be higher towards the end of the season, but I want to determine this by using a feature specifically for the round.

• We also consider venue experience as a proportion of total matches played in the 2 prior seasons. As seasons change length across the years, if we use number of matches we will be assuming HGA increases as seasons go by just due to there being more matches played in each season.

• We re base season so the first season is 0 so we can use a regression model with no intercept. The coefficient of the season feature will tell us how HGA has changed relative to the very first season. Using no intercept was important as I want the model to be symmetrical. I want the HGA to remain consistent regardless of the order in which teams are named. I realise there may be an increased bias in crowd support for teams named first, but I'm ignoring this for now.

• We express the round as a fraction relative to the total rounds in the season to again avoid any skewing of the analysis due to seasons getting longer over time. If there is a change in HGA over time, this may appear as a change in HGA by round as the high round numbers tend to only exist for very recent seasons.

• We've used historical venue performance from the last 100 matches as a maximum, and 5 matches as a minimum. I've also scaled the value down for small sample sizes, which is what the matches/100 does.

• We've calculated venue length and width measures as absolute difference from the teams' home venue. If dimensions do contribute to HGA, whether the ground is skinnier vs fatter or longer vs shorter shouldn't really matter. What should matter is that the ground dimensions are different to what the players are used to.

• I've expressed member figures relative to average members in that season, as membership figures have risen a lot over the years, so expressing relative to the average that year helps keep these figures distinct from the season. The membership feature also uses this value from the prior season as current season memberships are only finalised in August, so using current season values includes information about the current season which could skew the analysis.

Of these measures, travel distance and venue experience are what is commonly used to model HGA in AFL. The remainder are not normally used but I've made an attempt to investigate whether they provide any extra information in addition to travel distance and venue experience.

#### Analysis

As a first step, I've plotted each of the features I'm attempting to use against the model margin error to validate each makes sense and these plots can be seen below. The left plots show a scatter plot with all matches while the right shows scatter plots with the points binned into smaller intervals so we can see the trend a little easier. Note that due to sample sizes the binned plots may look strange (for example the venue performance binned plot), this is due to there being few matches in the far right bins as well as the values being out of line with the overall trend. Looking at the trend on the left is most relevant in this example.

From these plots it looks like travel, venue experience, venue performance and round explain the errors the most, venue dimensions explain the errors a little and membership figures and season don't look to explain the errors much, if at all.

Now from here, I decided to first attempt to explain the errors in my ELO model using the features available for all matches. As I want to be able to model HGA back to the beginning of VFL/AFL, I want to explain HGA using features available for the entire history. After that I will attempt to use the other features to improve the HGA model further for matches where the extra features are available.

Features available in all matches are travel distance, venue experience, venue performance, season and round. To explain the model errors using these features I used forward selection linear regression. This is a method of linear regression whereby we start with no features and from the features available, add them one by one in order of which gives the biggest improvement to adjusted $$R^2$$ first. We then only add more features if they improve the adjusted $$R^2$$ further, and again we add the ones that give the biggest boost to the adjusted $$R^2$$ first.

If we used regular $$R^2$$, this would always increase as we add more features, however using adjusted $$R^2$$ means we need the improvement in $$R^2$$ to be more than what we would get from random chance just by adding more features. This is a good way to avoid over fitting and adding extra features just for the hell of it.

This brings us to the results, this first regression showed that we can explain the margin errors using the expression:

$\text{Margin Error} = 0.86 \times \text{Travel Distance} + 5.9 \times \text{Venue Experience} + 3.5 \times \text{Round} + 0.19 \times \text{Venue Performance}$

All the coefficients here were statistically significant (p values of $$1.5\times 10^{-6}, 3.7\times 10^{-2}, 5.2\times 10^{-3}, 4.1\times 10^{-8}$$ for travel distance, venue experience, round and venue performance respectively). However using the season as a feature did not improve the adjusted $$R^2$$ so was not included in the final model.

I am quite surprised that the round of the match came out as a significant factor in estimating HGA. The other features are quite easy to rationalise, but I'm at a loss for how to explain why playing a match at the end of the season at your home ground is worth about 3.5 points more than playing the match at the start of the season. Perhaps the burden of travel, the unfamiliarity and extra mental effort takes a larger toll as the season goes on and the players get more battered and bruised each week.

To see if this expression makes sense, consider what would be about the worst case scenario, West Coast or Fremantle travelling from Perth to Melbourne at the end of the season having played approx. 15% of their matches at the MCG in the prior 2 seasons while their opponent has played approx. 60% of their matches there.

According to the above expression, travelling from Perth to Melbourne is worth -7 points (distance of approx 2700km). Having played 15% of matches at the MCG relative to 60% is worth -2.5 points. And playing away from home at the end of the season relative to the start of the season is worth -3.5 points. Ignoring historical venue performance, this adds up to about a 13 point disadvantage which seems pretty reasonable to me.

Using this regression model we can then define a base HGA for each match based on travel distance, venue experience, round and venue performance. If we subtract this from our original margin error we get a new margin error which has the error from travel distance, venue experience and round built in.

As a check, the MAE for our original margin error was 27.6 points and 26.5 points after adjusting for HGA, so our adjusted margin errors have improved by about 1.1 point using these adjustments.

Next we try and explain the adjusted margin errors using venue dimensions and membership figures.

Running the forward regression model again on these 3 features, the result is that only the venue width feature was chosen to be an explanatory variable, and it had a p value of 0.025. The coefficient here was actually -0.12 as well, indicating that when a team plays at a venue which has a width different to their home venue, they actually perform better than expected.

With the coefficient being the opposite sign to what we expect and the p value not being super convincing, this is enough for me to exclude venue width as an explanatory variable, leaving none of the venue dimensions or membership figures as useful in explaining home ground advantage, after we account for venue experience, travel distance and round.

Note that above when we plotted the margin errors against the venue length and width features, we saw the expected relationship between the errors and these features. However after accounting for travel, venue experience, venue performance and round, the venue dimension features don't provide any useful extra information. As venue experience, travel distance, round and venue performance can be calculated for every match and are simpler to maintain and calculate going forwards, I am comfortable using them as a proxy for all home ground advantage factors, including venue dimensions and leaving out any specific adjustment for the actual venue dimensions.

Given the relationship between the margin errors and the membership feature above I'm not surprised it was deemed insignificant in the forward regression. Perhaps membership numbers are too noisy themselves, or are confounded with other variables such as team strength anyway and provide little additional value in estimating HGA.

Finally, if I apply the same margin error adjustment to my test data set I end up with MAE values of 27.7 prior to adjustment and 26.8 after the adjustment, so the adjustments gives a 0.9 point improvement on the test data set, slightly less than the 1.1 point improvement on the train data set but still comparable.

#### Conclusion

HGA can be explained using the travel distance, venue experience, venue performance and round features explained above. The linear relationship of $$\text{HGA} = 0.86 \times \text{Travel Distance} + 5.9 \times \text{Venue Experience} + 3.5 \times \text{Round} + 0.19 \times \text{Venue Performance}$$ could be used to improve the margin errors for my HGA agnostic ELO model by about 1 point.

Venue dimensions appear to correlate with teams' improved performance when playing at home, however this disappears once we account for travel distance, venue experience, venue performance and round.

Membership figures and season were found to not explain any of the home ground advantage effect.

The next step is to use this methodology in an ELO model. As ELO will update team rankings based on performance accounting for HGA, the optimal weights on each feature may actually be slightly different. I would also expect to get an improvement of more than 1 point in MAE when incorporating HGA into an ELO model due to having a better estimate of team strength when HGA adjustments are made.

#### Data notes

Venue dimensions taken mostly from AustralianFootball.com with a few from this Foxsports article and The Footy Almanac.

Membership figures taken from Footy Industry for 1984 - 2016 and AFL website for 2017, 2018 and 2019. Due to incomplete data I only used membership figures from 1992 onwards.

Feel free to reach out on Twitter if you'd like to see any of this data.


text:
# The Fundamental Physics Project Rule Syntax.

Posted 1 year ago
1672 Views
|
|
1 Total Likes
|
 Hello again everyone, hope you are all well.In reading over my last posted question, I realize I may have included too much information, and/or completely botched the subject line of the post, so please allow me to rephrase the question.In the Wolfram Fundamental Physics Project Update Rule:{{X,X,Y},{X,Z,V}} -> {{V,V,W},{W,V,Y},{Z,Y,W}}can anyone, anywhere, explain exactly what the left-hand side is supposed to mean, in English?
 Hi David,do you mean that specific case ({{X,X,Y},{X,Z,V}} -> {{V,V,W},{W,V,Y},{Z,Y,W}}) or a rule in general? Have you taken a look at this book, where most of the subject is explained in details: https://www.wolframphysics.org/technical-introduction/basic-form-of-models/first-example-of-a-rule/Then to see, how that particular rule works in Wolfram Models, you can run the next code snippets in your Wolfram App: rule={{X,X,Y},{X,Z,V}} -> {{V,V,W},{W,V,Y},{Z,Y,W}}; RulePlot[rule] And: Dataset[{ResourceFunction["WolframModelPlot"][#], ToString@#} &/@ResourceFunction["WolframModel"][rule,Automatic, 10, "StatesList"]] Experiment more with the help of the documentation: https://resources.wolframcloud.com/FunctionRepository/resources/WolframModelAnd tell us what did you learn.All the best, -Marko

format: plain


text:
# How is sin(npi/2) = (-1)^((n-1)/2) for odd n?

1. Sep 19, 2009

### jaejoon89

I know the MacLaurin series for sin(x) but can't figure out how this reduces to the above (if it does).

2. Sep 19, 2009

### JG89

sin(npi/2) is going to be equal to -1 or 1, depending on the value of n, right? So the formula seems plausible. You could prove it through induction.

Last edited: Sep 19, 2009
3. Sep 19, 2009

thanks


text:
# Strongly coupled chameleons and the neutronic quantum bouncer

Abstract : We consider the potential detection of chameleons using bouncing ultracold neutrons. We show that the presence of a chameleon field over a planar plate would alter the energy levels of ultra cold neutrons in the terrestrial gravitational field. When chameleons are strongly coupled to nuclear matter, $\beta\gtrsim 10^8$, we find that the shift in energy levels would be detectable with the forthcoming GRANIT experiment, where a sensitivity of order one percent of a peV is expected. We also find that an extremely large coupling $\beta\gtrsim 10^{11}$ would lead to new bound states at a distance of order 2 microns, which is already ruled out by previous Grenoble experiments. The resulting bound, $\beta\lesssim 10^{11}$, is already three orders of magnitude better than the upper bound, $\beta\lesssim 10^{14}$, from precision tests of atomic spectra.
Document type :
Journal articles

http://hal.in2p3.fr/in2p3-00593906
Contributor : Emmanuelle Vernay <>
Submitted on : Wednesday, May 18, 2011 - 8:44:51 AM
Last modification on : Wednesday, April 14, 2021 - 12:13:13 PM

### Citation

Philippe Brax, G. Pignol. Strongly coupled chameleons and the neutronic quantum bouncer. Physical Review Letters, American Physical Society, 2011, 107, pp.111301. ⟨10.1103/PhysRevLett.107.111301⟩. ⟨in2p3-00593906⟩

Record views


text:
# FX Forward pricing with correlation between FX and Zero-Cupon

I would like to extend my question about about FX Forward rates in stochastic interest rate setup: FX forward with stochastic interest rates pricing

We consider a FX process $X_t = X_0 \exp( \int_0^t(r^d_s-r^f_s)ds -\frac{\sigma^2}{2}t+ \sigma W_t^2)$ where $r^d$ and $r^f$ are stochastic processes not independent of the Brownian motion $W$. The domestic risk-neutral measure is denoted by $\mathbb Q^d$.

The domestic and foreign bank accounts are $\beta^d$ and $\beta^f$ respectively. The domestic and foreign zero-coupon bond prices of maturity $T$ at time $t$ are respective $B_d(t,T)$ and $B_f(t,T)$.

The domestic bond follows the SDE

$$\frac{dB_d(t,T)}{B_d(t,T)} = r^d_t \ dt + \sigma(t,T) \ dW^1_t$$

with deterministic initial conditions $B_d(0,T)$. The drift and volatility functions in the SDEs are all deterministic functions and $W^1$ and $W^2$ are standard Brownian motions such that $\langle W^1, W^2\rangle_t =\rho \ dt$.

Now consider domestic $\tau$-forward measure $\mathbb Q^{d,\tau}$ $$\left. \frac{d\mathbb Q^{d,\tau}}{d\mathbb Q^d}\right|_{\mathcal F_t} = \frac{B_d(t,\tau)}{\beta_t^dB_d(0,\tau)} = \mathcal E_t \left( \int_0 ^. \sigma(s,\tau) \ dW^1_s\right)$$

and the $\mathbb Q^{\tau}$-Brownian motions $$W^{1,\tau}_. := W^1_. + \int_0 ^. \sigma(s,\tau) \ ds$$

$$W^{2,\tau}_. := W^2_. + \rho \int_0 ^. \sigma(s,\tau) \ ds$$

Question

I would like to calculate the non-deliverable FX forward rate. Since the fixing date $t_f$ is such that $t_f< T$, where $T$ is the settlement date, it implies to pass by the calculation following expectation: $$\mathbb E^{\mathbb Q^d} _t \left[ \exp(-\int_t^T r^d_s ~ds)\ X_{t_f}\right]$$

I can get to this point

$$\mathbb E^{\mathbb Q^d} _t \left[ \exp(-\int_t^T r^d_s ~ds)\ X_{t_f}\right]= B_d(t,t_f)\ \mathbb E^{\mathbb Q^{d,t_f}}_t\left[ B_b(t_f,T)X_{t_f}\right].$$

From that point I am struggling to get through all the calculations. Is there a smart way to compute the last expectation?

• Your problem formulation seems pretty weird to me. – Quantuple Jul 28 '16 at 8:15
• @Quantuple: Can you develope please? What particularly sounds weird for you? – Joe Jul 28 '16 at 8:20
• The Radon-Nikodym derivative characterising the domestic to domestic $T$-forward measure for instance. – Quantuple Jul 28 '16 at 8:41
• There is a typo, it should be $\tau$ instead of $T$. Is that what you mean ? – Joe Jul 28 '16 at 8:46
• For the SDE formulation you can assume a HJM setup. So you can have such a representation. – Joe Jul 28 '16 at 9:10

We consider the expectation \begin{align*} E^{Q_d^{t_f}} \Big(P_d(t_f, T) X_{t_f} \mid \mathcal{F}_t \Big), \end{align*} where $Q_d^{t_f}$ is the $t_f$-forward measure, and $P_d(t_f, T)$ is the price at $t_f$ of a domestic zero-coupon bond with maturity $T$. Note that $P_d(t_f, T) X_{t_f}$ is the value at time $t_f$ of the process \begin{align*} P_d(t, T) X_t \frac{P_f(t, t_f)}{P_d(t, t_f)}, \end{align*} where $P_f(t, t_f)$ is the price at $t$ of a foreign zero-coupon bond with maturity $t_f$. If we model the bond prices directly, then we need dynamics for the four processes $X_t$, $P_d(t, t_f)$, $P_d(t, T)$, and $P_f(t, t_f)$. For simplicity, we model the short rates based on the Hull-White interest rate model with corresponding correlated dynamics for $X_t$, $r_t^f$, and $r_t^d$.

Let $X_t$ be the instantaneous exchange rate from one unit foreign currency to units of domestic currency, and $r^d_t$ and $r^f_t$ be the domestic and the equity's denominated foreign short interest rates at time $t$. Moreover, let \begin{align*} \Xi= (\rho_{i, j})_{i,j=1}^3 \end{align*} be the correlation matrix of the driving Brownian motions of the 3$-$dimensional random process $\{(X_t, r^f_t, r^d_t),\, t \geq 0\}$, and let $$LL^T = \Xi,$$ where $L=(l_{i,j})_{i,j=1}^3$ is a lower triangular matrix and $l_{i, i} >0$, for $i=1, \ldots, 3$, be the Cholesky decomposition of $\Xi$.

We assume that, under the domestic risk-neutral probability measure $Q_d$, \begin{align*} dX_t &= X_t\Big[\big(r^d_t - r^f_t\big) dt + \sigma^X dW_t^1\Big], \\ dr^f_t &= \Big[\big( \theta_t^f - \lambda^f r_t^f \big) - \rho_{2, 1}\sigma^f \sigma^X\, \Big] dt + \sigma^f \sum_{i=1}^2 l_{2, i} d W_t^i,\\ dr^d_t &= \big( \theta_t^d - \lambda^d r_t^d \big) dt + \sigma^d\sum_{i=1}^3 l_{3, i} d W_t^i, \end{align*} where $\{W_t^1,\, t \ge 0\}, \ldots, \{W_t^3,\, t \ge 0\}$ are independent standard Brownian motions, $\theta_{t}^{a},$ are piece-wise constant functions, and $\lambda^{a}$ and $\sigma^{a}$ are positive constant, for $a=X$, $d$, or $f$. Here, $\lambda^d$ and $\lambda^f$ are the mean-reverting speed of the respective dynamic processes.

Note that, under the foreign risk-neutral probability measure $Q_f$, $\{\widehat{W}_t^1= W_t^1-\sigma^X t,\, t \ge 0\}$, $\{\widehat{W}_t^2=W_t^2,\, t \ge 0\}$, and $\{\widehat{W}_t^3=W_t^3,\, t \ge 0\}$ are independent standard Brownian motions. Moreover, \begin{align*} dX_t &= X_t\Big[\left(r^d_t - r^f_t + (\sigma^X)^2\right) dt + \sigma^X d\widehat{W}_t^1\Big], \\ dr^f_t &= \big( \theta_t^f - \lambda^f r_t^f \big) dt + \sigma_t^f \sum_{i=1}^2 l_{2, i} d \widehat{W}_t^i,\\ dr^d_t &= \Big[\big( \theta_t^d - \lambda^d r_t^d \big) + \rho_{3, 1}\sigma^d \sigma^X\,\Big] dt + \sigma^d\sum_{i=1}^3 l_{3, i} d \widehat{W}_t^i. \end{align*}

Let $P_d(t, T)$ and $P_f(t, T)$ denote the prices, at time $t$, of the domestic and foreign zero-coupon bonds with maturity $T$. From this question, \begin{align*} P_a(t, T) &= e^{A_a(t, T) - B_a(t, T) r_t^a}, \end{align*} for $a=d$ or $f$, where \begin{align*} \beta_a(t, T) &= \frac{1}{\lambda^a}\left(1-e^{-\lambda^a (T-t)} \right),\\ A_a(t, T) &= -\int_t^T \theta_s^a\beta_a(s, T) ds - \frac{(\sigma^a)^2}{2(\lambda^a)^2}(\beta_a(t, T)-T+t) - \frac{(\sigma^a)^2}{4\lambda^a}\beta_a(t, T)^2. \end{align*} Then, under the domestic risk-neutral measure, \begin{align*} \frac{dP_d(t, T)}{P_d(t, T)} &= r_t^d dt - \beta_d(t, T)\sigma^d \sum_{i=1}^3 l_{3, i} d W_t^i,\\ \frac{dP_f(t, T)}{P_f(t, T)} &= r_t^f dt - \beta_f(t, T)\sigma^f \sum_{i=1}^2 l_{2, i} d \widehat{W}_t^i\\ &=\left(r_t^f + \rho_{2,1}\beta_f(t, T)\sigma^f \sigma^X \right)dt - \beta_f(t, T)\sigma^f \sum_{i=1}^2 l_{2, i} d W_t^i. \end{align*}

Let $Q_d^{t_f}$ be the domestic $t_f$-forward measure. Moreover, let $B_d(t)=e^{\int_0^t r_s^d ds}$ be the domestic money market account value at time $t$. Then, \begin{align*} \frac{dQ_d^{t_f}}{dQ_d}\big|_t &= \frac{P_d(t, t_f)}{P_d(0, t_f) B_d(t)}\\ &=\exp\left(-\frac{1}{2}\int_0^t (\sigma^d \beta_d(s, t_f))^2ds - \int_0^t\sigma^d \beta_d(s, t_f) \sum_{i=1}^3 l_{3, i} d W_s^i\right). \end{align*} Then, $\{\widetilde{W}_t^1,\, 0 \le t \le t_f\}$, $\{\widetilde{W}_t^2,\, 0 \le t \le t_f\}$, and $\{\widetilde{W}_t^3,\, 0 \le t \le t_f\}$, where, for $i=1, \ldots, 3,$ \begin{align*} \widetilde{W}_t^i = W_t^i + \int_0^t l_{3, i} \sigma^d\beta_d(u, t_f) du, \end{align*} are independent standard Brownian motions.

Let $F_X(t, t_f)=X_t\frac{P_f(t, t_f)}{P_d(t, t_f)}$ be the forward exchange rate at time $t$ for maturity $t_f$. Then, \begin{align*} \frac{dF_X(t, t_f)}{F_X(t, t_f)} = \sigma^X d\widetilde{W}_t^1 + \beta_d(t, t_f)\sigma^d \sum_{i=1}^3 l_{3, i} d \widetilde{W}_t^i- \beta_f(t, t_f)\sigma^f \sum_{i=1}^2 l_{2, i} d \widetilde{W}_t^i. \end{align*} Moreover, let \begin{align*} M(t, t_f) &= -\frac{1}{2}\int_t^{t_f} \bigg((\sigma^X)^2 + (\beta_d(u, t_f)\sigma^d)^2 + (\beta_f(u, t_f)\sigma^f)^2\\ &\quad + 2 \rho_{1, 3}\sigma^X \sigma^d\beta_d(u, t_f)- 2 \rho_{1, 2}\sigma^X \sigma^f\beta_f(u, t_f) - 2 \rho_{2, 3}\sigma^d \sigma^f \beta_d(u, t_f)\beta_f(u, t_f)\bigg) du. \end{align*} Then, \begin{align*} X_{t_f} &= F_X(t_f, t_f)\\ &=F_X(t, t_f) \exp\bigg(M(t, t_f) \\ &\quad + \int_t^{t_f} \Big( \sigma^X d\widetilde{W}_u^1 + \beta_d(u, t_f)\sigma^d \sum_{i=1}^3 l_{3, i} d \widetilde{W}_u^i- \beta_f(u, t_f)\sigma^f \sum_{i=1}^2 l_{2, i} d \widetilde{W}_u^i\Big)\bigg). \end{align*} Furthermore, let \begin{align*} N(t, t_f) &= e^{-\lambda^d (t_f-t)} r_t + \int_t^{t_f} \theta_u^d e^{-\lambda^d(t_f-u)} du -\int_t^{t_f}(\sigma^d)^2 e^{-\lambda^d(t_f-u)}\beta_d(u, t_f) du. \end{align*} Then, \begin{align*} r_{t_f}^d &= e^{-\lambda^d (t_f-t)} r_t + \int_t^{t_f} \theta_u^d e^{-\lambda^d(t_f-u)} du + \int_t^{t_f} \sigma^d e^{-\lambda^d(t_f-u)} \sum_{i=1}^3 l_{3, i} d W_u^i\\ &= N(t, t_f)+ \int_t^{t_f} \sigma^d e^{-\lambda^d(t_f-u)} \sum_{i=1}^3 l_{3, i} d \widetilde{W}_u^i. \end{align*} That is, \begin{align*} P_d(t_f, T) X_{t_f} &= \exp\bigg(A_d(t_f, T) - B_d(t_f, T) r_{t_f}^d \bigg)X_{t_f}\\ &= F_X(t, t_f) \exp\bigg(A_d(t_f, T) - B_d(t_f, T)N(t, t_f) + M(t, t_f)\\ &\quad - B_d(t_f, T) \int_t^{t_f} \sigma^d e^{-\lambda^d(t_f-u)} \sum_{i=1}^3 l_{3, i} d \widetilde{W}_u^i \\ &\quad + \int_t^{t_f} \Big( \sigma^X d\widetilde{W}_u^1 + \beta_d(u, t_f)\sigma^d \sum_{i=1}^3 l_{3, i} d \widetilde{W}_u^i- \beta_f(u, t_f)\sigma^f \sum_{i=1}^2 l_{2, i} d \widetilde{W}_u^i\Big) \bigg). \end{align*} Let \begin{align*} V(t, t_f, T) &= \int_t^{t_f} \bigg((\sigma^X)^2 + \Big(\beta_d(u, t_f)\sigma^d - B_d(t_f, T)\sigma^d e^{-\lambda^d(t_f-u)} \Big)^2 + (\beta_f(u, t_f)\sigma^f)^2\\ &\quad + 2 \rho_{1, 3}\sigma^X \Big(\beta_d(u, t_f)\sigma^d - B_d(t_f, T)\sigma^d e^{-\lambda^d(t_f-u)} \Big)- 2 \rho_{1, 2}\sigma^X \sigma^f\beta_f(u, t_f) \\ &\quad - 2 \rho_{2, 3}\sigma^f \beta_f(u, t_f)\Big(\beta_d(u, t_f)\sigma^d - B_d(t_f, T)\sigma^d e^{-\lambda^d(t_f-u)} \Big)\bigg) du\\ &= -2M(t, t_f) + B_d(t_f, T)\int_t^{t_f}\bigg[ B_d(t_f, T)\Big( \sigma^d e^{-\lambda^d(t_f-u)} \Big)^2 \\ &\qquad\qquad\qquad\qquad\qquad\qquad - 2 (\sigma^d)^2\beta_d(u, t_f)e^{-\lambda^d(t_f-u)} -2 \rho_{1, 3}\sigma^X \sigma^d e^{-\lambda^d(t_f-u)}\\ &\qquad\qquad\qquad\qquad\qquad\qquad +2 \rho_{2, 3}\sigma^d \sigma^f \beta_f(u, t_f) e^{-\lambda^d(t_f-u)} \bigg]du. \end{align*} Moreover, let \begin{align*} V_0(t, t_f, T) &=B_d(t_f, T)\int_t^{t_f}\bigg[ B_d(t_f, T)\Big( \sigma^d e^{-\lambda^d(t_f-u)} \Big)^2 \\ &\qquad\qquad\qquad\qquad - 2 (\sigma^d)^2\beta_d(u, t_f)e^{-\lambda^d(t_f-u)} -2 \rho_{1, 3}\sigma^X \sigma^d e^{-\lambda^d(t_f-u)} \\ &\qquad\qquad\qquad\qquad +2 \rho_{2, 3}\sigma^d \sigma^f \beta_f(u, t_f) e^{-\lambda^d(t_f-u)} \bigg]du. \end{align*} Then \begin{align*} &\ E^{Q_d^{t_f}} \Big(P_d(t_f, T) X_{t_f} \mid \mathcal{F}_t \Big) \\ =&\ F_X(t, t_f) \exp\bigg(A_d(t_f, T) - B_d(t_f, T)N(t, t_f) + M(t, t_f) +\frac{1}{2} V(t, t_f, T) \bigg)\\ =&\ F_X(t, t_f) \exp\bigg(A_d(t_f, T) - B_d(t_f, T)N(t, t_f) + \frac{1}{2} V_0(t, t_f, T) \bigg). \end{align*}

• @Joe, any comments or feedback? – Gordon Aug 5 '16 at 16:40
• I hadn't seen this question. I think your solution is true. indeed, it is so nice (+1) – user16651 Aug 28 '16 at 20:45
• @Joe Your behavior is not fairly. – user16651 Aug 28 '16 at 20:52
• @BehrouzMaleki and Joe, generally, a poster should at least question and challenge the answer, so that we can improve and fine tune the answer together. – Gordon Aug 29 '16 at 12:01
• I do not assume that, but you can treat it as an approximation. – Gordon Apr 18 '19 at 16:27


text:
Table iteration error with non-perfect-square max

Just now when trying to produce equally spaced numbers, there's a warning message for

n = 3;
Mx = Sqrt[6];
Table[ j, {j, Mx/n, Mx, Mx/n}]

The desired list involving $\sqrt{3}$ is still produced, yet the warning message is complaining "... $MaxExtraPrecision was encountered ... upper estimate will be used for the number of iterations...", along with a small segment of internal code shows flooring. The warning message appears for$M_x$being multiples of 3. The same goes for$n=7$while$M_x$is a multiple of 7. So far it appears that as long as the max$M_x = \sqrt{k\, n}~$is not an integer (i.e.$kn$is not a perfect sqaure, there's still a square root ), even though it's algebraically exact, Mathematica cannot correctly deduce that the number of iteration is exactly$n$when the starting value$\frac{M_x}{n}$and ending value$M_x$is set like that. I haven't tried but it's likely that other forms of input (that are mathematically equivalent) will result in the same warning. It doesn't affect other things, but seems like a tiny bug? What's your opinion? Thank you. • Subdivide[Mx/n, Mx, n - 1] // Simplify gives no errors. – corey979 Nov 2 '16 at 11:26 1 Answer I would not call this a bug. You say, Mathematica cannot correctly deduce that the number of iteration but I guess you mean that it cannot deduce the exact result. The approximate result it produces happens to be correct. I get the following output: {Sqrt[2/3], 2 Sqrt[2/3], Sqrt[6]} Do you not get the correct result? The reason why this happens is made clear by the warning message. Mathematica computes the number of elements in the list as follows: Floor[(upperbound - lowerbound) / step + 1]  which in this case is Floor[(Mx - Mx/n)/(Mx/n) + 1]  and evaluates to Floor[1 + Sqrt[3/2] (-Sqrt[(2/3)] + Sqrt[6])]  Floor appears to use numerical methods to compute its result even for exact arguments. I assume (I may be wrong) that if its argument is not an explicit integer, then it simply computes it with sufficient precision to detect a deviation from an integer. In this case however, Sqrt[3/2] (-Sqrt[(2/3)] + Sqrt[6]) is an exact integer, so no matter how many digits we compute, we never get a deviation. Floor thus fails, and Table decides to use an approximate calculation instead of an exact one. The approximate calculation gets lucky and still gives the correct exact answer (not one less or one more). All this happens because of how things like Sqrt[6]/3 evaluate automatically to Sqrt[2/3]. I don't think this sort of thing is fully avoidable. It will always be possible to construct complicated expressions which are really exact integers in disguise. Symbolic methods won't work for everything, and they are also slow. So Floor doesn't even seem to attempt them, and resorts to numerics instead (side note: this allows Floor and similar functions to be very general and work with constants like these). And in these special cases numerical methods fails to produce an provably exact result. Of course this works: Floor[1 + Sqrt[3/2] (-Sqrt[(2/3)] + Sqrt[6])] // Simplify 3  But personally I think it was a good decision not to invoke functions like Simplify from Table. I think of Table (and even Floor) as something simple and predictable (especially performance-wise). Simplify is not predictable and may run even for several minutes in unlucky cases. To sum up: I would not call this a bug because it will always be possible to construct pathological expressions on which Floor would not work well. A possible workaround: Table[..., {, Subdivide[Mx/n, Mx, n - 1]}]  Subdivide is new in v10.1, but it is trivial to implement as Mx/n + (Mx - Mx/n)/(n - 1) Range[0, n - 1]. • Thanks for the discussion. It's a good point you made that "Symbolic methods won't work for everything, and they are also slow", and yes, maybe I was a bit careless in saying that Mathematica doesn't deduce the correct answer when it's not exact. Whether or not the "approximation gets lucky", indeed Mathematica is still doing to a good job in giving the algebraic answers involving$\sqrt{3}\$. – Lee David Chung Lin Nov 2 '16 at 12:03
• @LeeDavidChungLin Just to make it clear, what I wrote about whether this is a bug or not is my personal opinion only. – Szabolcs Nov 2 '16 at 12:03


text:
This paper presents the analytical solution for the effectiveness of a counterflow heat exchanger subjected to a uniformly distributed, external heat flux. The solution is verified against conventional $ε$-NTU relations in the limit of zero external heat flux. This situation is of interest in applications such as cryogenic and process engineering, and the analytical solution provides a convenient method for treating differential elements of a heat exchanger in a numerical model.

1.
Incropera
,
F. P.
, and
DeWitt
,
D. P.
, 2002,
Fundamentals of Heat and Mass Transfer
, 5th Edition,
Wiley
, New York.
2.
Chowdhury
,
K.
, and
Sarangi
,
S.
, 1984, “
Performance of Cryogenic Heat Exchangers With Heat Leak From the Surroundings
,”
,
29
, pp.
273
280
.
3.
Barron
,
R. F.
, 1984, “
Effect of Heat Transfer From Ambient on Cryogenic Heat Exchanger Performance
,”
,
29
, pp.
265
272
.
4.
Ameel
,
T. A.
, and
Hewavitharana
,
L.
, 1999, “
Countercurrent Heat Exchangers With Both Fluids Subjected to External Heating
,”
Heat Transfer Eng.
0145-7632,
20
(
3
), pp.
37
44
.
5.
Nellis
,
G. F.
, 2003, “
A Heat Exchanger Model That Includes Axial Conduction, Parasitic Heat Load, and Property Variations
,”
Cryogenics
0011-2275,
43
(
9
), pp.
523
538
.
6.
Nellis
,
G. F.
,
Pfotenhauer
,
J. M.
, and
Klein
,
S. A.
, 2004, “
Actively Cooled Current Leads for Superconducting Electronics Using Mixed-Gas Joule-Thomson Refrigeration
,” 2004 IMECE, ASME Paper No. IMECE2004-60284.
7.
Keppler
,
F.
,
Nellis
,
G.
, and
Klein
,
S. A.
, 2004, “
Optimization of the Composition of a Gas Mixture in a Joule-Thomson Cycle
,”
HVAC&R Res.
1078-9669,
10
(
2
), pp.
213
230
.
8.
Swift
,
W. L.
,
Zagarola
,
M. V.
,
Nellis
,
G. F.
,
McCormick
,
J. A.
,
Sixsmith
,
H.
, and
Gibbon
,
J. A.
, 1999, “
Developments in Turbo Brayton Technology for Low Temperature Applications
,”
Cryogenics
0011-2275,
35
, pp.
989
995
.