text:
Journal cover Journal topic
Annales Geophysicae An interactive open-access journal of the European Geosciences Union
Journal topic
Ann. Geophys., 37, 101-109, 2019
https://doi.org/10.5194/angeo-37-101-2019
Ann. Geophys., 37, 101-109, 2019
https://doi.org/10.5194/angeo-37-101-2019

Regular paper 05 Feb 2019

Regular paper | 05 Feb 2019

# Magnetodisc modelling in Jupiter's magnetosphere using Juno magnetic field data and the paraboloid magnetic field model

Analysis of Juno magnetic field data using paraboloid magnetospheric model
Ivan A. Pensionerov1, Elena S. Belenkaya1, Stanley W. H. Cowley2, Igor I. Alexeev1, Vladimir V. Kalegaev1, and David A. Parunakian1 Ivan A. Pensionerov et al.
• 1Federal State Budget Educational Institution of Higher Education M.V. Lomonosov Moscow State University, Skobeltsyn Institute of Nuclear Physics (SINP MSU), 1(2), Leninskie gory, GSP-1, Moscow 119991, Russian Federation
• 2Department of Physics & Astronomy, University of Leicester, Leicester LE1 7RH, UK
Abstract

One of the main features of Jupiter's magnetosphere is its equatorial magnetodisc, which significantly increases the field strength and size of the magnetosphere. Analysis of Juno measurements of the magnetic field during the first 10 orbits covering the dawn to pre-dawn sector of the magnetosphere (03:30–06:00 local time) has allowed us to determine optimal parameters of the magnetodisc using the paraboloid magnetospheric magnetic field model, which employs analytic expressions for the magnetospheric current systems. Specifically, within the model we determine the size of the Jovian magnetodisc and the magnetic field strength at its outer edge.

1 Introduction

In this paper we consider magnetic field measurements made by the Juno spacecraft in Jupiter's magnetosphere, paying particular attention to the middle magnetosphere measurements where Jupiter's magnetodisc field plays a major role. The structure and properties of the Jovian magnetodisc have been described in many papers, starting from the first spacecraft flybys of Jupiter, discussed for example by and references therein. In particular, the empirical magnetodisc model presented by , derived from Voyager-1 and -2 and Pioneer-10 observations, has been employed as a basis in numerous subsequent studies, including predictions for the Juno mission by . Detailed physical models have also been constructed by , who derived a steady-state MHD magnetodisc model in which both centrifugal and plasma pressure (assumed isotropic) forces were included, and by , who incorporated a self-consistent plasma angular velocity model. have also included the effects of plasma pressure anisotropy, as observed in Voyager and Galileo particle measurements, which redistributes the azimuthal currents in the magnetodisc, changing its thickness.

Here we model the magnetic field observations during Juno's first 10 orbits for which both inbound and outbound passes are presently available, corresponding to perijoves (PJs) 0 to 9, using the semi-empirical global paraboloid Jovian magnetospheric magnetic field model derived by . We focus on the middle magnetosphere, observed on these orbits in the dawn to pre-dawn sector of the magnetosphere (03:30–06:00 local time, LT), for which the magnetodisc provides the main contribution to the magnetospheric magnetic field. In the model, in which the field contributions are calculated using parameterised analytic equations, the magnetodisc is described by a simple thin plane disc lying in the planetary magnetic equatorial plane. We thus search the paraboloid model magnetodisc input parameters to determine the best fit to the Juno measurements. We note that the magnetodisc may be regarded as the most important source of magnetic field in Jupiter's magnetosphere, with a magnetic moment in the model derived by using Ulysses inbound data, for example, which is 2.6 times the planetary dipole moment. Consequently, the magnetodisc plays a major role in determining the size of the system in its interaction with the solar wind and is thus an appropriate focus of a study using Juno magnetic field data.

Figure 1In (a) we show a schematic of Jupiter's magnetosphere in the magnetic equatorial plane, showing various parameters of the paraboloid model. In (b) we show the definition of the planetary magnetic dipole angle Ψ in the JSM system, where XJSM points towards the Sun and the planetary dipole is contained in the XJSMZJSM plane.

2 The Jupiter paraboloid model

The paraboloid magnetospheric magnetic field model was developed for Jupiter by , based on the terrestrial paraboloid model of and . It contains the internal planetary field, Bi, calculated from the full order-4 VIP4 model of ; the magnetodisc field, BMD; the field of the magnetopause shielding currents, Bsi and BsMD, which screen the planetary and magnetodisc fields, respectively; the field of the magnetotail current system, BTS; and the penetrating part of the interplanetary magnetic field (IMF), kBIMF, where k is the IMF penetration coefficient. The magnetopause is described by a paraboloid of revolution in Jovian solar magnetospheric (JSM) coordinates with the origin at Jupiter's centre:

$\begin{array}{}\text{(1)}& \frac{x}{{R}_{\mathrm{ss}}}=\mathrm{1}-\frac{{y}^{\mathrm{2}}+{z}^{\mathrm{2}}}{\mathrm{2}{R}_{\mathrm{ss}}^{\mathrm{2}}},\end{array}$

where x is directed towards the Sun, the xz plane contains the planet's magnetic moment, and y completes the right-hand orthogonal set pointing towards dusk. Rss is the distance to the subsolar magnetopause, where y=0 and z=0. The magnetospheric magnetic field, Bm, is then the sum of the fields created by all these current systems:

$\begin{array}{ll}& {\mathbit{B}}_{\mathrm{m}}={\mathbit{B}}_{\mathrm{i}}\left(\mathrm{\Psi }\right)+{\mathbit{B}}_{\mathrm{TS}}\left(\mathrm{\Psi },{R}_{\mathrm{ss}},{R}_{\mathrm{2}},{B}_{\mathrm{t}}\right)\\ & +{\mathbit{B}}_{\mathrm{MD}}\left(\mathrm{\Psi },{B}_{\mathrm{DC}},{R}_{\mathrm{DC}\mathrm{1}},{R}_{\mathrm{DC}\mathrm{2}}\right)+{\mathbit{B}}_{\mathrm{si}}\left(\mathrm{\Psi },{R}_{\mathrm{ss}}\right)\\ \text{(2)}& & +{\mathbit{B}}_{\mathrm{sMD}}\left(\mathrm{\Psi },{R}_{\mathrm{ss}},{B}_{\mathrm{DC}},{R}_{\mathrm{DC}\mathrm{1}},{R}_{\mathrm{DC}\mathrm{2}}\right)+k{\mathbit{B}}_{\mathrm{IMF}},\end{array}$

where Ψ is Jupiter's dipole tilt angle relative to the z axis. The magnetodisc is approximated as a thin disc with outer and inner radii RDC1 and RDC2, respectively. BDC is the magnetodisc field at the outer boundary, while the azimuthal currents in the disc are assumed to decrease as r−2. R2 is the distance to the inner edge of the tail current sheet, and Bt is the tail current magnetic field there. The magnetospheric current systems are thus described by nine input parameters, determining the physical size of the current systems, and their magnetic field (current) strength (Ψ, Rss, R2, RDC1, RDC2, Bt, BDC, k, BIMF). In Fig. 1 we show sketches illustrating the parameters of the model. On the left we show a view in the magnetospheric equatorial plane, where we note that in the physical system, the overlapping model magnetodisc and tail current sheets merge together on the nightside. On the right we show the planetary magnetic dipole axis at angle Ψ in the JSM system. As shown by , the magnetic moment of the model current disc is given by

$\begin{array}{}\text{(3)}& {M}_{\mathrm{MD}}=\frac{{B}_{\mathrm{DC}}}{\mathrm{2}}{R}_{\mathrm{DC}\mathrm{1}}^{\mathrm{3}}\left(\mathrm{1}-\frac{{R}_{\mathrm{DC}\mathrm{2}}}{{R}_{\mathrm{DC}\mathrm{1}}}\right).\end{array}$

and determined model parameters which approximated the magnetic field along the Ulysses inbound trajectory rather well. These parameters are Rss=100RJ, R2=65RJ, ${B}_{\mathrm{t}}=-\mathrm{2.5}$nT, RDC1=92  RJ, RDC2=18.4RJ, and BDC=2.5nT. This set of parameters is used in the present paper as a starting point for fitting parameters to the Juno data. The dipole tilt angle Ψ changes during the observations and is calculated as a function of time in the paraboloid model.

3 Magnetic field calculations for the first 10 Juno orbits

As indicated above, field calculations have been made using the paraboloid model for comparison with the data from the first 10 Juno orbits for which data are presently available for study. The orbits were closely polar, with large eccentricity, and with apoapsis initially located south of the equator in the dawn magnetosphere (e.g. Connerney et al.2017). In Fig. 2 we show the perijove 1 trajectory versus time (in day of year (DOY) 2016) in JSM Cartesian coordinates, specifically showing the cylindrical and spherical radial distances ${\mathit{\rho }}_{\mathrm{JSM}}=\sqrt{{x}^{\mathrm{2}}+{y}^{\mathrm{2}}}$ and r, ZJSM, and the LT. The vertical dashed line shows the time of periapsis. On later orbits apoapsis moved towards the nightside, reaching 03:30 LT by perijove 9, and also rotated further into the Southern Hemisphere.

Figure 2Juno perijove 1 trajectory in JSM Cartesian coordinates plotted versus time in DOY 2016, where the vertical dashed line shows the time of periapsis.

In this paper we confine our attention to the middle magnetosphere, where, as we now show, the magnetic field is dominated by the magnetodisc and the planetary field. In the outer magnetosphere the field becomes strongly influenced by external conditions in the solar wind, and although in some circumstances these can be reasonably well predicted by MHD models initialised using data obtained near Earth's orbit (e.g. Tao et al.2005; Zieger and Hansen2008), they will typically vary strongly on the timescale of the Juno orbit (Fig. 2), and with them too the outer magnetospheric field. In Figs. 3 and 4, for example, we show the magnitudes of the modelled field from different sources along the inbound (a) and outbound (b) passes of perijoves 1 and 9, respectively, plotted versus radial distance. The red lines in these figures show the internal JRM09 (“Juno reference model through perijove 9”) planetary field derived by , which employs the well-determined degree and order 10 coefficients from an overall degree 20 spherical harmonic fit to the data (plus disc model field) from the first nine Juno orbits. The black lines show the field of the various magnetospheric current systems in the paraboloid model as marked, where the model parameters employed are those derived from Ulysses inbound data by , as outlined in Sect. 2. It can be seen from Figs. 3 and 4 that for r<60RJ the contributions to the magnetospheric field from the magnetopause and tail current systems (which are oppositely directed near the dawn–dusk meridian) are negligible compared with the magnetodisc field, being less than 10 % for perijove 1 and less than 16 % for perijove 9, and may thus be treated approximately inside this distance. For related reasons we also neglect the penetrating IMF term in Eq. (2), which is unknown when Juno is inside the magnetosphere, highly variable in direction with time, and typically of magnitude ∼0.1–1 nT . This field too, with penetration coefficient k<1, is therefore similarly negligible in the r<60RJ middle magnetosphere studied here.

Figure 3Magnitude of the model magnetic fields for the Juno perijove 1 inbound (a) and outbound (b) passes, due to the internal planetary field (JRM09, in red), and the various model magnetospheric currents as marked (magnetopause, tail, and magnetodisc, in black).

Figure 4As for Fig. 3, but for perijove 9.

As a consequence of these considerations, here we employ the JRM09 model of the internal field and fit only the magnetodisc parameters to the middle magnetosphere data. For the small fields contributed by the magnetopause and tail current systems in this regime, we simply use the Ulysses parameters from and as sufficient approximations, i.e. Rss=100RJ, R2=65RJ, and ${B}_{\mathrm{t}}=-\mathrm{2.5}$nT. However, use of the Ulysses magnetodisc parameters is found to lead, for example, to a systematic underestimation of the field along the perijove 1 trajectory, and thus needs to be modified. Thus only three parameters, RDC1, RDC2, and BDC, need to be fitted.

Table 1Magnetodisc parameters derived for the Ulysses inbound pass and the first 10 Juno orbits, together with the estimated errors and the minimum inbound and outbound radial distances available in the Juno passes.

To optimise the model we choose the approach of minimising function S given by

$\begin{array}{}\text{(4)}& S\left({B}_{\mathrm{DC}},{R}_{\mathrm{DC}\mathrm{1}},{R}_{\mathrm{DC}\mathrm{2}}\right)=\sqrt{\frac{\mathrm{1}}{N}\sum _{n=\mathrm{1}}^{N}\frac{{\left|{\mathbit{B}}_{\mathrm{mod}}^{\left(n\right)}-{\mathbit{B}}_{\mathrm{obs}}^{\left(n\right)}\right|}^{\mathrm{2}}}{{\left|{\mathbit{B}}_{\mathrm{obs}}^{\left(n\right)}\right|}^{\mathrm{2}}}},\end{array}$

where ${\mathbit{B}}_{\mathrm{mod}}^{\left(n\right)}$ is the modelled field vector due to the current systems, ${\mathbit{B}}_{\mathrm{obs}}^{\left(n\right)}$ is the observed residual field following subtraction of the JRM09 internal field model, n is the index number of the data point along the trajectory, and the total number of points is N. S represents a root-mean-square relative deviation of the modelled magnetic field from the observed field vectors. We used a relative deviation instead of an absolute value to equalise the influence of all the data points, noting that the magnetic field varies in magnitude significantly along the part of the trajectory examined here (see Figs. 3 and 4). Use of the absolute deviation gives good results in the region closer to the planet where the field magnitude is greater, but a poorer fit in other parts of the trajectory.

Figure 5Observed (black) and modelled (red) residual fields in JSM cylindrical components, together with the residual field magnitude, for Juno perijove 1. The residual field is the observed field with the JRM09 internal field subtracted. The fields are plotted versus spherical radial distance with inbound data shown on the left and outbound data on the right. The same model field is used for both.

Figure 6As for Fig. 5, but for perijove 6.

With regard to the choice of interval employed to minimise S, we note that use of data from the innermost region is not optimal. The JRM09 internal planetary field model differs from observations at periapsis (1.06 RJ) by 0.3×105nT , which is reasonable accuracy for describing an observed field of magnitude $\sim \mathrm{8}×{\mathrm{10}}^{\mathrm{5}}$nT, but does not allow us to distinguish the magnetodisc field of order 100 nT on this background. We thus restricted the inner border of the interval to consider r>5RJ only. However, on most passes examined here, the inner radial limit is set instead at somewhat larger radii by the data that are presently available for study. A further limitation on the region of calculation of S in the outer magnetosphere arises from the fact that the paraboloid model does not display regions of low field strength during intersections with the magnetodisc, as is observed in the field at larger distances, due to the use of the infinitely thin disc approximation (see Sect. 4). It is thus necessary to avoid these regions by excluding parts of the trajectory where the spacecraft is closer than 4 RJ from the magnetic equator.

We thus minimise S in the inbound and outbound radial ranges between Rmin and Rmax on each pass to determine the best-fit magnetodisc parameters. The minimisation was undertaken using the trust region reflective procedure . The best-fit values are given, together with the estimated error values and the radial ranges employed, in Table 1, where we also compare with the values derived by from Ulysses inbound data. We estimated parameter errors by choosing several different starting points for the algorithm in parameter space and running it with a more generous termination condition in comparison with the normal runs. Specifically, we stopped the calculation when dS<0.1S, where dS is the change of function S in the algorithm step. We then estimated the error as (PmaxPmin)∕2, where Pmax and Pmin are the maximum and minimum parameter values obtained in these runs. For all the Juno fits we found that the best-fit outer disc radius RDC1 was the maximum value of 95 RJ allowed in the fitting process, set by requiring that the disc radius should be less than the subsolar magnetopause radius (100 RJ) by a few RJ. This indicates that the current density in the model disc, varying as r−2, decreases somewhat too quickly with distance. The values of the inner disc radius RDC2 lie between 12.5 and 18.7 RJ, usually smaller than the value of 18.4 RJ, derived from the Ulysses data, while the field strength parameter BDC varies between 2.6 and 3.1 nT, larger than the Ulysses value of 2.5 nT.

In Figs. 5 and 6 we provide comparisons of the observed (black) and modelled (red) residual fields for Juno perijoves 1 and 6, respectively, from which the JRM09 planetary field has been subtracted. Specifically we show the JSM cylindrical field components together with the residual field magnitude plotted versus radial distance, where the same model applies to both inbound (left side) and outbound (right side) data. As can be seen, the fitted models are generally in good accordance with the observations for the Bρ and Bz components, while the Bϕ component is not adequately described, because the model does not include radial currents in the magnetodisc and their closure current via the ionosphere. It is also seen in Fig. 5 that the field magnitude is underestimated inside of ∼10RJ, again probably related to the too-steep radial dependence of the azimuthal current. As the distance from Jupiter decreases, a sharp increase in the residual field is observed in the inner region to >100nT, while the model field plateaus at several tens of nanoteslas (nT). At the closest distances from the planet the increase is probably due to inaccuracy of the JRM09 model of the internal field, noting that the model represents only the degree and order 10 terms from an overall degree 20 fit .

Figure 7Comparison of the observed residual field (black) and best-fit magnetodisc model field (blue) in a similar format to Fig. 5. We also show the best-fit paraboloid model (red) as in Fig. 5.

4 Approaches for future improvement of the Jupiter paraboloid model

We first compare the fits derived here with those obtained using the magnetodisc model derived by from Voyager-1 and -2 and Pioneer-10 field data, but now fitted to Juno perijove 1 data. In this model the current flows in a planet-centred annular disc of full thickness 5 RJ, with inner (R0) and outer (R1) radii at 5 and ∼50RJ, respectively. The azimuthal current in the disc is taken to vary as I0ρ, where ρ is the perpendicular distance from the planetary dipole magnetic axis. We optimised this model for Juno perijove 1 using the same method as outlined above, to find best-fit parameters ${I}_{\mathrm{0}}=\mathrm{21}×{\mathrm{10}}^{\mathrm{6}}$$A{R}_{\mathrm{J}}^{-\mathrm{1}}$ (${\mathit{\mu }}_{\mathrm{0}}{I}_{\mathrm{0}}/\mathrm{2}\approx \mathrm{185}$ nT), R0=6RJ, and R1=67RJ. Figure 7 shows a comparison of the observed residual fields (black) with the best-fit Connerney et al. model (blue) in a similar format to Figs. 5 and 6, where we also show the best-fit paraboloid model (red) from Fig. 5. One important difference between the model results is the fact that the model reflects well the observed periodic sharp drops of magnetic field strength during spacecraft intersections with the disc. The magnetodisc radial magnetic field component reverses sign above and below the disc, and at its centre becomes equal to zero. As indicated in Sect. 3, the paraboloid model with an infinitely thin disc certainly cannot reproduce this feature and should thus be improved by use of a disc current of finite thickness. The Connerney et al. model demonstrates reasonable coincidence with observations near Jupiter, but at greater distances overestimates the magnetic field strength, which indicates that at these distances the current density variation as ρ−1 is too slow.

As indicated above, neither of the magnetodisc models considered here describe the azimuthal field well at medium and large distances, which shows short-term modulations of the field between positive and negative values related to crossings of the current sheet near the planetary rotation period (see for example the inbound data in Fig. 6). This points to the well-known existence of radial currents in the magnetodisc associated with sweepback of the field into a “lagging” configuration (e.g. Hill1979). Neither of models considered here, the model and the paraboloid model of , include these currents, but only the azimuthal current in the magnetodisc. Such radial currents have been included in the models by and , and could be a useful addition to the paraboloid model, together with their field-aligned and ionospheric closure currents.

5 Discussion and conclusions

As shown in Figs. 3 and 4, in the middle part of the Jovian magnetosphere selected for study here, the main contribution to the field due to the magnetospheric current systems is the equatorial magnetodisc. Here we have refined the magnetodisc parameters within the Jovian paraboloid model to best fit the Juno data from the first 10 orbits in this region, for which both inbound and outbound data are presently available. Analysis of the field at very close radial distances requires better knowledge of the internal planetary field, while the field at large distances is strongly influenced by the solar wind, whose simultaneous parameters remain unknown and are generally varying rapidly with time on the scale of the Juno passes.

As the simplest approximation we took magnetopause and tail current parameters derived using the Ulysses mission data and changed only the radial and field strength parameters of the magnetodisc. We found that the best-fit model consistently had a large outer radius comparable with the subsolar magnetopause distance (taken to be 100 RJ from the Ulysses model), an inner radius usually between ∼12 and 14 RJ smaller than the Ulysses model (∼18RJ), and a comparable field strength parameter (at the outer edge of the disc) of ∼2.5 nT.

To further refine the Jovian paraboloid magnetospheric model, it will be necessary to take into account the finite thickness of the magnetodisc current, and also to accurately determine its dependence on the radial distance from the planet. The existence of radial currents in the disc, as well as their closure via field-aligned currents in the planetary ionosphere, should also be incorporated.

Code availability
Code availability.

Those who would like to work with the paraboloid model may contact Igor I. Alexeev at alexeev@dec1.sinp.msu.ru.

Author contributions
Author contributions.

IAP – Formal analysis, Visualization, Writing – original draft; ESB – Supervision, Writing – original draft, Writing – review and editing; SWHC – Supervision, Writing – review and editing; IIA – Methodology, Software; VVK – Methodology, Software; DAP – Software, Data curation.

Competing interests
Competing interests.

The authors declare that they have no conflict of interest.

Acknowledgements
Acknowledgements.

Work at the Federal State Budget Educational Institution of Higher Education M.V. Lomonosov Moscow State University, Skobeltsyn Institute of Nuclear Physics (SINP MSU), was partially supported by the Ministry of Education and Science of the Russian Federation (grant RFMEFI61617X0084). Work at the University of Leicester was supported by STFC grant ST/N000749/1. The Juno magnetometer data were obtained from the Planetary Data System (PDS). We are grateful to the Juno team for making the magnetic field data available (FGM instrument scientist John E. P. Connerney; principal investigator of Juno mission Scott J. Bolton).

Edited by: Elias Roussos
Reviewed by: two anonymous referees

References

Alexeev, I. I.: The penetration of interplanetary magnetic and electric fields into the magnetosphere, J. Geomagn. Geoelectr., 38, 1199–1221, https://doi.org/10.5636/jgg.38.1199, 1986. a

Alexeev, I. I. and Belenkaya, E. S.: Modeling of the Jovian Magnetosphere, Ann. Geophys., 23, 809–826, https://doi.org/10.5194/angeo-23-809-2005, 2005. a, b, c, d, e, f, g, h, i, j

Alexeev, I. I., Belenkaya, E. S., Kalegaev, V. V., and Lyutov, Y. G.: Electric fields and field-aligned current generation in the magnetosphere, J. Geophys. Res.-Space, 98, 4041–4051, https://doi.org/10.1029/92ja01520, 1993. a

Barbosa, D. D., Gurnett, D. A., Kurth, W. S., and Scarf, F. L.: Structure and properties of Jupiter's magnetoplasmadisc, Geophys. Res. Lett., 6, 785–788, https://doi.org/10.1029/gl006i010p00785, 1979. a

Belenkaya, E. S.: The Jovian magnetospheric magnetic and electric fields: Effects of the interplanetary magnetic field, Planet. Space Sci., 52, 499–511, https://doi.org/10.1016/j.pss.2003.06.008, 2004. a, b, c

Branch, M. A., Coleman, T. F., and Li, Y.: A Subspace, Interior, and Conjugate Gradient Method for Large-Scale Bound-Constrained Minimization Problems, SIAM J. Sci. Comput., 21, 1–23, https://doi.org/10.1137/s1064827595289108, 1999. a

Caudal, G.: A self-consistent model of Jupiter's magnetodisc including the effects of centrifugal force and pressure, J. Geophys. Res., 91, 4201, https://doi.org/10.1029/ja091ia04p04201, 1986. a

Connerney, J. E. P., Acuña, M. H., and Ness, N. F.: Modeling the Jovian current sheet and inner magnetosphere, J. Geophys. Res.-Space, 86, 8370–8384, https://doi.org/10.1029/ja086ia10p08370, 1981. a, b, c, d, e

Connerney, J. E. P., Acuña, M. H., Ness, N. F., and Satoh, T.: New models of Jupiter's magnetic field constrained by the Io flux tube footprint, J. Geophys. Res.-Space, 103, 11929–11939, https://doi.org/10.1029/97ja03726, 1998. a

Connerney, J. E. P., Adriani, A., Allegrini, F., Bagenal, F., Bolton, S. J., Bonfond, B., Cowley, S. W. H., Gerard, J.-C., Gladstone, G. R., Grodent, D., Hospodarsky, G., Jorgensen, J. L., Kurth, W. S., Levin, S. M., Mauk, B., McComas, D. J., Mura, A., Paranicas, C., Smith, E. J., Thorne, R. M., Valek, P., and Waite, J.: Jupiter's magnetosphere and aurorae observed by the Juno spacecraft during its first polar orbits, Science, 356, 826–832, https://doi.org/10.1126/science.aam5928, 2017. a

Connerney, J. E. P., Kotsiaros, S., Oliversen, R. J., Espley, J. R., Joergensen, J. L., Joergensen, P. S., Merayo, J. M. G., Herceg, M., Bloxham, J., Moore, K. M., Bolton, S. J., and Levin, S. M.: A New Model of Jupiter's Magnetic Field From Juno's First Nine Orbits, Geophys. Res. Lett., 45, 2590–2596, https://doi.org/10.1002/2018gl077312, 2018. a, b, c

Cowley, S. W. H., Deason, A. J., and Bunce, E. J.: Axi-symmetric models of auroral current systems in Jupiter′s magnetosphere with predictions for the Juno mission, Ann. Geophys., 26, 4051–4074, https://doi.org/10.5194/angeo-26-4051-2008, 2008. a, b

Cowley, S. W. H., Provan, G., Bunce, E. J., and Nichols, J. D.: Magnetosphere-ionosphere coupling at Jupiter: Expectations for Juno Perijove 1 from a steady state axisymmetric physical model, Geophys. Res. Lett., 44, 4497–4505, https://doi.org/10.1002/2017gl073129, 2017. a, b

Hill, T. W.: Inertial limit on corotation, J. Geophys. Res., 84, 6554, https://doi.org/10.1029/ja084ia11p06554, 1979. a

Khurana, K. K.: Euler potential models of Jupiter's magnetospheric field, J. Geophys. Res.-Space, 102, 11295–11306, https://doi.org/10.1029/97ja00563, 1997. a

Nichols, J. D.: Magnetosphere-ionosphere coupling in Jupiter's middle magnetosphere: Computations including a self-consistent current sheet magnetic field model, J. Geophys. Res.-Space, 116, A10232, https://doi.org/10.1029/2011ja016922, 2011. a

Nichols, J. D., Cowley, S. W. H., and McComas, D. J.: Magnetopause reconnection rate estimates for Jupiter's magnetosphere based on interplanetary measurements at ∼5 AU, Ann. Geophys., 24, 393–406, https://doi.org/10.5194/angeo-24-393-2006, 2006. a

Nichols, J. D., Achilleos, N., and Cowley, S. W. H.: A model of force balance in Jupiter's magnetodisc including hot plasma pressure anisotropy, J. Geophys. Res.-Space, 120, 10185–10206, https://doi.org/10.1002/2015ja021807, 2015. a

Nichols, J. D., Badman, S. V., Bagenal, F., Bolton, S. J., Bonfond, B., Bunce, E. J., Clarke, J. T., Connerney, J. E. P., Cowley, S. W. H., Ebert, R. W., Fujimoto, M., Gérard, J.-C., Gladstone, G. R., Grodent, D., Kimura, T., Kurth, W. S., Mauk, B. H., Murakami, G., McComas, D. J., Orton, G. S., Radioti, A., Stallard, T. S., Tao, C., Valek, P. W., Wilson, R. J., Yamazaki, A., and Yoshikawa, I.: Response of Jupiter's auroras to conditions in the interplanetary medium as measured by the Hubble Space Telescope and Juno, Geophys. Res. Lett., 44, 7643–7652, https://doi.org/10.1002/2017gl073029, 2017.  a

Tao, C., Kataoka, R., Fukunishi, H., Takahashi, Y., and Yokoyama, T.: Magnetic field variations in the Jovian magnetotail induced by solar wind dynamic pressure enhancements, J. Geophys. Res., 110, A11208, https://doi.org/10.1029/2004ja010959, 2005. a

Zieger, B. and Hansen, K. C.: Statistical validation of a solar wind propagation model from 1 to 10 AU, J. Geophys. Res.-Space, 113, A08107, https://doi.org/10.1029/2008ja013046, 2008. a


text:
# multiple definition's

This topic is 4802 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello, i am using the nehe basecode(i think) with devc++, i tryed to add some OOP code to it, so that i can create objects and whatnot(Using one of the articles that i cant find anymore :P ) Anyway, so i have 2 new files, zoomer.h and zoomer.cpp, along with the functions CZoomer* NewCZoomer(); DeleteAllCZoomer(); RenderCZoomer(); UpdateCZoomer(); All in the .h along with the class, then I have all the method functions inside the .cpp but my problem is, I want use the functions inside the .h and .cpp in main.cpp(were main loop is) but the problem is when i add #include "zoomer.h" it gives an error saying its allready defined...and if i remove the line it says the functions arent defined...any ideas?

##### Share on other sites
Try to put this in your zoomer.h file BEFORE any other code:
#IFNDEF __ZOOMER_H__
#DEFINE __ZOOMER_H__

And this AFTER all other code:

#ENDIF

That should make sure that the code is only defined in memory once.
Hope it helps...

##### Share on other sites
Quote:
 Original post by LeoncoeurTry to put this in your zoomer.h file BEFORE any other code:#IFNDEF __ZOOMER_H__#DEFINE __ZOOMER_H__And this AFTER all other code:#ENDIFThat should make sure that the code is only defined in memory once.Hope it helps...

In file included from main.cpp:19:
zoomer.h:2:2: invalid preprocessing directive #IFNDEF
zoomer.h:3:2: invalid preprocessing directive #DEFINE
zoomer.h:25:2: invalid preprocessing directive #ENDIF

Hmm...dont seem to work :S...thanks for your help

##### Share on other sites
try making the prprocessor directives all lowercase:

#ifndef
#define
#endif

##### Share on other sites
now its back to

multiple definition of firstCZoomer'

:S

##### Share on other sites
try posting some code that has firstCZoomer so we can see how it's declared

##### Share on other sites
umm ok, heres the files
kc.mindcasterstudios.com/files/zoomer.cpp
and
kc.mindcasterstudios.com/files/zoomer.h

##### Share on other sites
In the .h file,
Change
CZoomer * firstCZoomer =NULL;CZoomer * lastCZoomer =NULL;

to
extern CZoomer * firstCZoomer;extern CZoomer * lastCZoomer;

and put
CZoomer * firstCZoomer =NULL;CZoomer * lastCZoomer =NULL;

into the .cpp file.

Generally, if you want to share variables over the project, do not put them into the header, put them into the implementation (cpp) file and use an extern declaration like above in the header file.

##### Share on other sites
I'd actually go further than that. The article that you're working from is using "C with objects" rather than C++ and is not truely object-oriented. This is a common mistake made by people moving from C to C++. There's nothing inherently wrong with it, but you must recognise that you are missing out on a lot of the benefits that C++ and object-oriented programming bring.

It looks like you're trying to write a class which provides a linked list of particles which can be updated rendered and deleted. The problems with it as written are that you can only have one particle system going at a time, you can create particles which are not part of the particle system without it being clear that that is what you are doing and it is very easy to leak particles. Grab your favourite C++ reference and I'll give you a whistle-stop tour of how I would write such a class:
Particle.h:
// replace UNIQUE and IDENTIFIER with something likely to be unique to you, like your initials// do not use double underscores or an underscore followed by a capital// letter because such names are reserved for your compiler writers.// I prefer #if !defined to #ifndef since it more closely mimics the C/C++ if#if !defined(iUNIQUE_iIDENTIFIER_cPARTICLE)	#define iUNIQUE_iIDENTIFIER_cPARTICLE// name your classes appropriately.  Don't prefix classes with 'C'.// The user should not need to know whether he is using a class, a typedef or a builtin type.class Particle{	public:		Particle(float size, float zoom);		bool dead() const;		void render() const; // be const correct		void update();	// encapsulate data.  External code should not care _HOW_ Particle does what it does, only that it does it.	private:		// append underscores to member variables to identify them.		// This allows you to have easily named accessor functions, if required.		bool dead_;		float size_;		float zoom_;};#endif

ParticleSystem.h:
#if !defined(iUNIQUE_iIDENTIFIER_cPARTICLE_cSYSTEM)	#define iUNIQUE_iIDENTIFIER_cPARTICLE_cSYSTEM	// use the standard c++ list class	#include <list>	#include "Particle.h"class ParticleSystem{	public:		// use typedefs		typedef std::list< Particle >::size_type size_type;		void addParticle(Particle particle);		size_type count() const;		void render() const;		void update();	private:		std::list< Particle > particles_;};#endif

Particle.cpp:
#include "Particle.h"#include <windows.h>#include <GL/gl.h>Particle::Particle(float size, float zoom)	:	dead_(false),	size_(size),	zoom_(zoom){}bool Particle::dead() const{	return dead_;}void Particle::render() const{	glColor3f(1.0f,0.0f,0.0f);	glEnable(GL_TEXTURE_2D);	//glBindTexture(GL_TEXTURE_2D,::BlankTxt);	//glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );	float width;	float height;	width = zoom_;	height = zoom_;	glBegin(GL_QUADS);		glTexCoord2f(0,0);		glVertex2f(-width,-height);		glTexCoord2f(1,0);		glVertex2f(+width,-height);		glTexCoord2f(1,1);		glVertex2f(+width,+height);			glTexCoord2f(0,1);		glVertex2f(-width,+height);			glEnd();	glDisable(GL_TEXTURE_2D);}void Particle::update(){	//Add your code here	//This is where you define the behaviour of your Particles}

ParticleSystem.cpp:
#include "ParticleSystem.h"#include <algorithm>#include <functional>void ParticleSystem::addParticle(Particle particle){	particles_.push_back(particle);}ParticleSystem::size_type ParticleSystem::count() const{	// trivial implementation compared to CountCZoomer	return particles_.size();}void ParticleSystem::render() const{	// prefer std::for_each to explicit loops	// call the render function of the Particle class for every particle in the system	// trivial implementation compared to RenderCZoomer	std::for_each(particles_.begin(), particles_.end(), std::mem_fun_ref(&Particle::render));}void ParticleSystem::update(){	// call the update function of the Particle class for every particle in the system	std::for_each(particles_.begin(), particles_.end(), std::mem_fun_ref(&Particle::update));	// remove all dead particles	particles_.remove_if(std::mem_fun_ref(&Particle::dead));}

Note that there is no need for a DeleteAllCZoomer equivalent. Each ParticleSystem will clean itself up automatically when it is destructed thanks to the use of std::list.

Enigma

##### Share on other sites
okays,thanks for your help. well i got everything working fine, but for some reason using your particle system brings the FPS down to around 20 (from about 2000 without it) but olny when it render from the Particle system object...like here is my render function

void Draw (DWORD milliseconds){	glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	glLoadIdentity ();		//glTranslatef(Winwidth/2,Winheight/2,0);		//RenderCZoomer();	if(g_keys->keyDown [VK_SPACE])       PS.render();                 glColor3f(1.0f,0.0f,0.0f);	float width;	float height;	width = 100;	height = 100;	glBegin(GL_QUADS);		glTexCoord2f(0,0);		glVertex2f(-width,-height);		glTexCoord2f(1,0);		glVertex2f(+width,-height);		glTexCoord2f(1,1);		glVertex2f(+width,+height);			glTexCoord2f(0,1);		glVertex2f(-width,+height);			glEnd();    	glFlush ();}`

I have one particle in the system...but as soon as i press space it drops the fps down ALOT...why is this? it stays up at 2000 normaly when space isent pressed....any ideas as to why this is?(and if i remove the if space is down check, it does lag. so its not that)

1. 1
Rutin
22
2. 2
3. 3
4. 4
5. 5

• 9
• 9
• 9
• 14
• 12
• ### Forum Statistics

• Total Topics
633308
• Total Posts
3011294
• ### Who's Online (See full list)

There are no registered users currently online

×

format: plain


text:
# What is the average area of the shadow of a convex shape taken over all possible orientations?

If we take a sphere, its surface area is exactly 4 times the area of its shadow. How can it be generalised for any convex shape?

• Average measure of convex projections are proportional to their intrinsic (quermaß) volumes: see §7.4 “The mean projection formula” in Klain & Rota's delightful little book Introduction to Geometric Probability. – Gro-Tsen Apr 18 at 14:20
• In particular, yes, for a convex solid in $\mathbb{R}^3$, it is true that the surface area (which is essentially the $2$-dimensional intrinsic volume) is proportional to the area of the projection over all plane directions. – Gro-Tsen Apr 18 at 14:23
• Thank you but I guess I'm not ready to understand this §7.4, isn't there any other way to explain the at least the intuition? (I will read that book from the very beginning after all) – Betydlig Apr 18 at 14:42
• Then you had probably better ask on math.stackexchange.com instead (but remember to link to this post also, for completeness) — MathOverflow is for mathematicians to ask each other questions about their research. – Gro-Tsen Apr 18 at 14:47


text:
### Theory:

Now, let us discuss what happens to the food in different parts of the digestive tract. The food enters the digestive system after it has been broken down into smaller particles. Let us understand how food enters into each compartment of the digestive tract.
Mouth and buccal cavity
Food is ingested in the body through the mouth. Digestion of the food starts in the mouth as soon as we eat the food. Mouth, tongue, teeth and salivary glands are present in the buccal cavity. Salivary glands secretes a fluid called saliva, which is a digestive juice, which consists of a enzyme known as salivary amylase. This enzyme in the saliva breaks down the starch into sugar.  All these are the process of ingestion.

Teeth:

We chew the food with the teeth, which breaks down the ingested food mechanically. The teeth cut the food into small pieces, which helps in chewing and grinding the food. Each tooth is rooted in separate sockets or pockets in the gums. Teeth vary in appearance and performs different functions. There are $$4$$ types of teeth,
• Incisor
• Canine
• Premolar
• Molar.
Types of teeth

Parts of the tooth:
• Root -  Anchors the teeth and allows the blood and nerve supply to enter the teeth.
• Neck - Joint between the gums and crown region of the tooth.
• Crown - Allows for the breakdown of food and protected by the enamel.
The white and hard outer covering of a tooth is called the enamel and is made up of  calcium phosphate.
Tooth anatomy

There are two sets of teeth in our lifetime. These include:
1. Temporary teeth or milk teeth
2. Permanent teeth
Temporary teeth or milk teeth:

There are $$20$$ milk teeth. These develop in a child from $$5$$ to $$6$$ months till about $$2$$ years of age. Milk teeth fall off between the age of $$6$$ to $$8$$ years.

Permanent teeth:

There are $$32$$ permanent teeth - $$16$$ in each of the jaw. The number of each of the different types of teeth and their function is given below:

 Teeth type Milk teeth Permanent teeth Function Incisors $$8$$ $$8$$ Cutting and biting food Canines $$4$$ $$4$$ Piercing and tearing the food Premolars $$0$$ $$8$$ Crushing and grinding the food Molars $$8$$ $$12$$ Effective grinding of food Total $$20$$ $$32$$

Tooth decay:

Normally there is presence of bacteria in the mouth. If we do not clean them regularly and properly after eating, harmful bacteria begin to grow, and tooth decay occurs.
Tooth decay is when the tooth becomes rotten due to the formation of cavities inside the tooth.
Tooth decay

The bacteria act on the sugar present in the leftover food particles to form acids. The acid eats up the tooth's enamel and dentine, which makes a cavity in the tooth. When not treated properly, it causes severe toothache and, in severe cases, cause tooth loss.

Process of tooth decay

Excessive use of sugar-containing foods such as chocolates, sweets, ice cream, toffees and soft drinks cause tooth decay.

How to prevent tooth decay?

1. Rinse the mouth thoroughly with clean water after every meal.

2. Brushing teeth twice a day with a brush and toothpaste.

3. Dental floss must be used to remove the trapped food particles. Dental floss is a thread that is moved between two teeth to remove trapped food particles.

4. Avoid using dirty fingers or unwashed objects in the mouth.

Tongue:
The tongue is a thick muscular organ that is covered with mucous membrane and completely fills the mouth when jaws are closed. It is attached at the back to the buccal cavity floor and is free at the other end.
Tongue has many taste buds, which helps in identifying the taste of the food. The position of some of the taste buds of the tongue are given below:

Regions of tongue for different tastes

It is also helpful in the process of ingestion. The tongue rolls and pushes the food into the pharynx. It mixes the saliva with the food and also helps us in speaking. In the next theory, we will look into the salivary glands and its role in digestion.
Reference:
https://commons.wikimedia.org/wiki/File:3D_Medical_Animation_Still_Showing_Types_of_Teeth.jpg
https://commons.wikimedia.org/wiki/File:2409_Tooth.jpg
https://commons.wikimedia.org/wiki/File:Diagram_of_tooth_erosion.png
https://commons.wikimedia.org/wiki/File:Process_of_tooth_decay.jpg


text:
# Better way to code these deeply nested / multiple if/else statements

I have coded this mess of JavaScript and a bit of jQuery. Everything here works perfect as intended, however it is a real mess. What would be the best way to clean this up with best practices and such?

$.getJSON("People.json", function(data) {$.each(data.People, function(i, PersonObj) {
var Person = PersonObj[Object.keys(PersonObj)[0]];

content = '
';
content += '
';
content += '' + Person.Op + ' 	';

// if the person has swiped off but not back on and one hour has elapsed
if (Person.DifHours > 1 && Person.ON === false) {
content += '' + Person.Name;
} else if (Person.OUT !== false) {
content += '' + Person.Name;
// If the person has swiped back on from dinner set to lime
} else if (Person.ON !== false) {
content += '' + Person.Name;
// If the person has swipped of for dinner but 1 hour has not elapsed set to yellow
} else if (Person.OFF !== false) {
content += '' + Person.Name;
} else if (Person.Clock !== false) {
// If the person has clocked on set to lime
content += '' + Person.Name;
} else {
content += '' + Person.Name;
}
// putting values in to the table without formatting

content += '' + Person.WorkHours + ' 	';
content += '' + Person.Start + ' 	';
content += '' + Person.End + ' 	';

// if the person has not clocked in set the text to white
if (Person.Clock === false) {
content += '' + Person.Clock;
}
// if the person is late by 10 mins set to cyan
else if (Person.Late > 10) {
content += '' + Person.Clock;
// if the person is early by 10 mins set to orange
} else if (Person.Late < -10) {
content += '' + Person.Clock;
// Setting text color based on conditions
} else {
content += '' + Person.Clock + ' 	';
}
// Setting text color based on conditions
if (Person.OFF === false) {
content += '' + Person.OFF;
} else {
content += '' + Person.OFF + ' 	';

}// Setting text color based on conditions
if (Person.ON === false) {
content += '' + Person.ON;
} else {
content += '' + Person.ON + ' 	';

}

if (Person.Clock == false){
content += '' + Person.OUT;
}else if (Person.DifHours > 1 && Person.ON == false && Person.HomeEarly > 10){
content += '' + Person.OFF;
}else if (Person.DifHours > 1 && Person.ON == false && Person.HomeEarly < - 10){
content += '' + Person.OFF;
}else if(Person.DifHours > 1 && Person.ON == false){
content += '' + Person.OFF;
}else if (Person.OUT === false) {
content += '' + Person.OUT;
}
//Setting home colum formatting based on if they are in or out and if they locked early or late
else if (Person.Home > 10) {
content += '' + Person.OUT;
} else if (Person.Home < -10) {
content += '' + Person.OUT;
}else {
content += '' + Person.OUT + ' 	';
}

content += '
';
content += '
';
content += '
';
$(content).appendTo("tbody"); }); });  - Could you please describe this code a bit? – Jamal Aug 20 '14 at 18:10 No HTML escaping? I suppose it's guaranteed that Person.Name won't have a < in it (it isn't user input)? – Brilliand Aug 20 '14 at 20:06 @JoshKirkpatrick Although it isn't a security problem in this case, I'd still recommend not treating data as HTML if it isn't meant to be HTML (in this case, construct the td element and then set its text, rather than concatenating the text into an HTML string). – Brilliand Aug 20 '14 at 20:39 Since you are building a lot of the HTML, you could check out a templating library like Mustache.js or Handlebars.js. These libraries have their own way of dealing with conditionals and might simplify a big chunk of this process. – Jonny Sooter Aug 20 '14 at 21:46 ## 8 Answers There are a few good practices that will help this code out. ### Close the HTML tags that you open - generate valid HTML Newer browsers will probably render your content properly, but older browsers may not. You may also get strange formatting errors that are hard to debug. Save yourself the headache and always close your tags in the reverse order that you open them.

....

  You may also want to put the
 tags outside of your foreach loop, as there should be one
 for the overall table, not one per row. You can also use the W3C official HTML validator to make sure that the output you generate is valid HTML, and adjust your JavaScript to match. ### Set a variable in the if block; construct the content only once This makes it easier to update if you later decide to change how the raw HTML is built (like moving from tables to divs and spans). ### Avoid CSS shorthands if you are not using all of the properties Using background: XYZcolor; means that any other CSS background properties (background-image, background-repeat, background-attachment, background-position) already set are being wiped out. If this is your intention, keep it. If not, be more precise with your styles and use only background-color: XYZcolor;. This may not affect you now, but is a good habit to keep to avoid surprises later. ### Use CSS classes; avoid using the style= attribute This allows you to: 1. Give meaningful names indicating why the cell is colored a particular way (so you can debug using "view source" in the browser) 2. Adjust the styles independently of your JavaScript (so that you don't need to involve a JavaScript developer if the client wants the red cells to be just a bit redder) 3. Avoid the problems mentioned in this SO question: What's so bad about in-line CSS? Combining with the earlier suggestions gives us: var swipeStatus; // if the person has swiped off but not back on and one hour has elapsed if (Person.DifHours > 1 && Person.ON === false) { swipeStatus = "lateByOneHour"; } else if (Person.OUT !== false) { swipeStatus = "notOutYet"; // If the person has swiped back on from dinner set to lime } else if (Person.ON !== false) { swipeStatus = "backFromDinner"; // If the person has swiped of for dinner but 1 hour has not elapsed set to yellow } else if (Person.OFF !== false) { swipeStatus = "outForDinner"; } else if (Person.Clock !== false) { // If the person has clocked on set to lime swipeStatus = "inNormally"; } else { swipeStatus = "defaultStatus"; } content += '' + Person.Name + '	';  With the appropriate CSS: .lateByOneHour { background-color: red; } .notOutYet { background-color: red; } .backFromDinner { background-color: lime; } .outForDinner { background-color: yellow; } .inNormally { background-color: lime; } .defaultStatus { background-color: red; }  A similar strategy can be applied to the other logic blocks of your code. You can also add multiple CSS classes to a single tag . Sometimes that is useful in simplifying if/else logic, but doesn't appear to be the case here. Good to keep in your back pocket though. ### For better performance, call appendTo() outside of the loop The jQuery site itself has a page about why append() is slow in loops, but the gist of it is that it is expensive to touch the DOM, as append() and appendTo() do. Appending a giant chunk of HTML (your whole table) once at the end of the loop will perform faster than appending little bits of HTML (just a row) in each iteration of the loop. - I want to note that it is entirely valid to leave certain tags unclosed, depending on the context. For example,
,
 and  never need to be explicitly closed; they are automatically closed when either their containing element (
,
, or
, respectively) is closed, or when a suitable alternative (like
, another
, or , respectively) is opened. – Schism Aug 20 '14 at 18:01 It wouldn't pass the Html validator right? – TopinFrassi Aug 20 '14 at 18:12 While it's true that you don't need to close such tags it is probably better as a novice to err on the side of caution. If as a matter of habit you always close a block tag explicitly you don't have to remember which ones are automatically closed. – Alfred Armstrong Aug 20 '14 at 19:01 @TopinFrassi, the following passes W3C's validator: <!DOCTYPE html>   <title>Title</title>

  – Dancrumb Aug 20 '14 at 19:15 Does it get any realler than this: w3.org/html/wg/drafts/html/master/syntax.html#the-doctype? – Dancrumb Aug 20 '14 at 20:55 That's a big mess of conditionals. Hopefully they all match the comments near them, though given typical code that's likely not the case. You are repeating a lot of HTML code that could be addressed using variables as @V31 demonstrated. If this is the entirety of the code I would probably stop there, but as this system grows you may want to generalize the conditionals and how they apply. First, you can create short functions to help ensure the comments match the conditionals and are clear to future maintainers, reduce the code duplication (DRY), and possibly allow reuse in other areas. The very first conditional provides a good example. // if the person has swiped off but not back on and one hour has elapsed if (Person.DifHours > 1 && Person.ON === false) {  I see no reference to Person.OFF. Is this a bug or intentional? Does the system ensure that Person.ON === false forces Person.OFF to be true? Assuming the code is correct we can define function hasBeenOutForLongerThanOneHour(person) { return !person.ON && person.DifHours > 1; }  Applying this to the rest of the conditions in the first set yields function isOut(person) { return person.OUT; } function isBackFromDinner(person) { return person.ON; } function hasBeenOnBreakLessThanOneHour(person) { return person.OFF; } function hasClockedOn(person) { return person.Clock; }  I used your comments for the function names, but as you can probably see some are more descriptive than others and some appear to be underspecified. For example, isBackFromDinner looks only at Person.ON, but won't someone who just arrived at work also be on? You wouldn't call this person "back from dinner" if they haven't gone to dinner yet. And calling it a "break" is more-widely applicable than "dinner". Armed with these functions, you can now replace those conditional chains with data tables. Each table will map the functions to the style and value to use for building the cell. • All of the styles boil down to two variations: hide the cell with white-on-white or apply a background color. Let's indicate the first option using the color hide. • The cell value itself varies in the 2nd and 3rd blocks, but let's add it to every table for consistency. Here's the table that drives the Name cell: var NAME_STYLE_FILTERS = [ // filter function, field name, style to apply [hasBeenOutForLongerThanOneHour, 'Name', 'red'], [isOut, 'Name', 'red'], [isBackFromDinner, 'Name', 'lime'], [hasBeenOnBreakLessThanOneHour, 'Name', 'yellow'], [hasClockedOn, 'Name', 'lime'], [null, 'Name', 'red'], ];  Note: I chose arrays since there are only three elements each, but using objects may make it clearer what's going on. Since you'll be using this table format with each conditional block, we'll create a function to build the table cell using the data tables and person. function buildStyledCell(person, filters) { var match, text, style; filters.some(function (filter) { if (!style[0] || style[0](person) { match = filter; return true; } }; text = person[match[1]]; style = match[2] == 'hide' ? 'background-color: white; color: white' : 'background-color: ' + match[2]; return '' + text + '	'; }  Put it all together and you have this: var content = '
' content += '
'; content += '' + Person.Op + '	'; content += buildStyledCell(Person, NAME_STYLE_FILTERS); content += '' + Person.WorkHours + ' 	'; content += '' + Person.Start + ' 	'; content += '' + Person.End + ' 	'; content += buildStyledCell(Person, CLOCK_STYLE_FILTERS); content += buildStyledCell(Person, OFF_OUT_STYLE_FILTERS); content += '
'; content += '
'; content += '
';$(content).appendTo("tbody");

BTW, what's with your tags here? This doesn't look valid:

             <-- why? only one per table
...
...

                <-- out of order with
, but again not needed

• As long as you're using Object.keys you may as well use Array.prototype.forEach which is also from ES5. Be aware that it will fail if data.People is null or undefined--just like $.each. data.People.forEach(function (PersonObj) { ... }); • When I read if (Person.OUT !== false)  I immediately ask myself, "What other values besides true and false can Person.OUT take on, and what do they mean? Does null mean we don't know if they are out, or will it be undefined if they haven't clocked in yet today?" It's more likely that ON, OFF, and OUT will always contain boolean values, and using === and !== only complicates the code. That you use Person.ON == false later on exacerbates the reader's confusion. Simplify these to if (Person.OUT)  and if (... && !Person.ON && ...)  if you can, which read more like prose than code. • You're not closing the  elements inside the conditionals. • You can drop this super-helpful comment that appears several times: // Setting text color based on conditions  - Couple of nits: $.each will iterate over a non-Array object just fine. It just passes the key to the callback instead of the index. More importantly, you should never depend upon an absolute index into the array returned by Object.keys(), because ordering is not guaranteed. It is guaranteed to be the same as for..in ordering, but neither should be expected to be in any particular order. – codelahoma Aug 21 '14 at 1:00
Don't simply concatenate data into HTML. You're not doing any escaping... Use .text() instead. – Brad Aug 21 '14 at 3:03
@codelahoma I suspect data.People is an array instead of an object since the OP chose i as the key/index instead of key and ignores it in the callback. As for using Object.keys(PersonObj)[0], this is what the OP used. Without example JSON, we are left to guess at the intent. – David Harkness Aug 21 '14 at 9:39
@Brad It would be interesting to see the performance cost of building the table DOM elements detached from the document to be able to use .text() in lieu of DOM-free escaping functions. – David Harkness Aug 21 '14 at 9:42
@DavidHarkness Oh it's definitely slower, but what's your point? Your code here is plainly incorrect and will fail as soon as someone puts in a string in one of those variables with HTML in it. Plus, you don't want someone putting  in for their user name. – Brad Aug 21 '14 at 12:56

The first if block can be narrowed by using a color variable; something like this:

var color = "red";
// if the person has swiped off but not back on and one hour has elapsed
if (Person.DifHours > 1 && (Person.ON === false || Person.OUT !==false)) {
color = "red";
// If the person has swiped back on from dinner set to lime
} else if (Person.ON !== false || Person.Clock !== false) {
color = "lime";
// If the person has swiped off for dinner but 1 hour has not elapsed set to yellow
} else if (Person.OFF !== false) {
color = "yellow";
}
content += "" + Person.OUT;

You can do the same thing for the rest of your if blocks. If you combine conditions that result in the same color with && and ||, you can reduce code length while making it more readable.

-
The fallback is resulting to a background red, which in this case Person.DifHours<=1 and Person.OUT === false will result in red. Just check the default value of the variable color. It is red. So default (fallback value) is red in this case – V31 Aug 20 '14 at 16:31
Wanted to say that the OP can club if statements with and/or as in the color code can be the same for some conditions can elaborate the answe if required – V31 Aug 20 '14 at 16:38
@Schism, the author did write something like this, it is great you point out bugs, but -1 seems harsh – konijn Aug 20 '14 at 16:41
@konijn If a review changes the logic of the code I think it's deserving of a -1. Buuut, I had missed the first line; I made a relatively minor edit so that I'd be able to change my vote to a +1. – Schism Aug 20 '14 at 16:45
@Schism: Yep that was the actual meaning what I wanted to convey :) – V31 Aug 20 '14 at 16:45

As usual, I'm a day late and a dollar short. :)

You actually have a good case for using a view model. All of the ifs would be methods in your view model to return the proper CSS class for your  tags. This has a couple benefits:

1. The view logic is now its own component and can be tested using any of the JavaScript unit testing frameworks out there
2. The code for concatenating the HTML becomes much leaner and cleaner.

Furthermore, you can get a slight speed boost by appending strings to an Array instead of continually doing string concatenation.

EmployeeStatusViewModel.js

function EmployeeStatusViewModel(person) {
this.person = person || null;
}

EmployeeStatusViewModel.prototype = {

person: null,

constructor: EmployeeStatusViewModel,

getOffStatus: function() {
return this.person.OFF ? "out" : "";
},

getOnStatus: function() {
return this.person.ON ? "on" : "";
},

getSwipeStatus: function() {
var swipeStatus = "defaultStatus";

// if the person has swiped off but not back on and one hour has elapsed
if (this.person.DifHours > 1 && !this.person.ON) {
swipeStatus = "lateByOneHour";
} else if (this.person.OUT) {
swipeStatus = "notOutYet";
// If the this.person has swiped back on from dinner set to lime
} else if (this.person.ON) {
swipeStatus = "backFromDinner";
// If the this.person has swiped of for dinner but 1 hour has not elapsed set to yellow
} else if (this.person.OFF) {
swipeStatus = "outForDinner";
// If the person has clocked on set to lime
} else if (this.person.Clock) {
swipeStatus = "inNormally";
}

return swipeStatus;
}
};

Your call to get the data and then build HTML could use an Array instead of concatenating a larger and larger string. Second of all, you only need one call to appendTo:

$.getJSON("People.json", function(data) { // The "view model" encapsulating view logic var model = new EmployeeStatusViewModel(), // The Array to which we append HTML content = [];$.each(data.People, function(i, peopleObj) {
var person = model.person = peopleObj[Object.keys(peopleObj)[0]];

content.push(
'
',
'' + person.Op + '	',
'' + person.Name + '	',
'' + person.WorkHours + ' 	',
'' + person.Start + ' 	',
'' + person.End + ' 	',
'' + person.Clock + '	',
'' + person.OFF + '	',
'' + person.ON + '	',
// build the rest of your columns...
'
'
);
});

// Join the Array on an empty string and append to a
 only once
$(content.join("")).appendTo("tbody"); });  Note: I didn't completely flesh out this code example, leaving some of it for you. Stylistic Changes Given that I see property names beginning with a capital letter, you may be using .NET on the server? In JavaScript, only Constructor Functions begin with a capital letter, e.g. XMLHttpRequest, Array, Object. Local variables should begin with a lower case letter. Really, property names should also begin with a lower case letter, but if you are using .NET and serializing an object into JSON, it translates the property names literally, and using PascalCase in .NET for property names is the prevailing pattern, so not much you can do in this regard. - Going off what @Matt Giltaji said, I have removed all the HTML styling and moved it into CSS. I then moved the $(content).appendTo("tbody"); outside of the loop to help performance. Then I threw it through the HTML validator after I tweaked a couple things and it all seems to check out.

$.getJSON("People.json", function (data) { content = '
'; content += '
';$.each(data.People, function (i, PersonObj) {
var Person = PersonObj[Object.keys(PersonObj)[0]];

content += '' + Person.Op + ' 	';

// if the person has swiped off but not back on and one hour has elapsed
var swipeStatus;
// if the person has swiped off but not back on and one hour has elapsed
if (Person.DifHours > 1 && Person.ON === false) {
swipeStatus = "lateByOneHour";
} else if (Person.OUT !== false) {
swipeStatus = "notOutYet";
// If the person has swiped back on from dinner set to lime
} else if (Person.ON !== false) {
swipeStatus = "backFromDinner";
// If the person has swiped of for dinner but 1 hour has not elapsed set to yellow
} else if (Person.OFF !== false) {
swipeStatus = "outForDinner";
} else if (Person.Clock !== false) {
// If the person has clocked on set to lime
swipeStatus = "inNormally";
} else {
swipeStatus = "defaultStatus";
}
//putting the vales in the table with the swipe status and the infomation
content += '' + Person.Name + '	';
// putting values in to the table without formatting
content += '' + Person.WorkHours + ' 	';
content += '' + Person.Start + ' 	';
content += '' + Person.End + ' 	';
// if the person has not clocked in set the text to white
if (Person.Clock === false) {
swipeStatus = "NoClock";
}
// if the person is late by 10 mins set to cyan
else if (Person.Late > 10) {
swipeStatus = "ClockLate";
// if the person is early by 10 mins set to orange
} else if (Person.Late < -10) {
swipeStatus = "ClockEarly";
//if they are ontime with +-10 mins set to lime
} else {
swipeStatus = "ClockOntime";
}
//put the infomation in to colum
content += '' + Person.Clock + '	';
//if the person has notswiped off set cell to hidden
if (Person.OFF === false) {
swipeStatus = "NoClock";
//else set to a misleading rule name (no css styling plain cell)
} else {
swipeStatus = "Blank";
}
//put the infomation in to colum
content += '' + Person.OFF + '	';
// if the person has no swipe back on infomation after swipping off set cell to blank
if (Person.ON === false) {
swipeStatus = "NoClock";
// else set the cell to the same unstyled cell
} else {
swipeStatus = "Blank";
}
//put the infomation in to colum
content += '' + Person.ON + '	';

// this if statment hides the pertentially undeeded could just put another logic block at the bottom to black every cell in each row if there is
//no clock info insted of blanking each cell of the logic blocks
if (Person.Clock === false) {
swipeStatus = "NoClock";
content += '' + Person.OFF + '	';
//If the person goes home with only have 2 out of the standard 4 swiped through the day and there second swipse is 10 mins less than there assgined home time set to Cyan
} else if (Person.DifHours > 1 && Person.ON === false && Person.HomeEarly > 10) {
swipeStatus = "ClockEarly";
content += '' + Person.OFF + '	';
//same as above but 10 mins or over home time
} else if (Person.DifHours > 1 && Person.ON === false && Person.HomeEarly < -10) {
swipeStatus = "ClockLate";
content += '' + Person.OFF + '	';
//same as above but with the 10 mins either side
} else if (Person.DifHours > 1 && Person.ON === false) {
swipeStatus = "ClockOntime";
content += '' + Person.OFF + '	';
} // if they didn't go home early and they don't have an out swipe yet then they are still there so just hide the cell
else if (Person.OUT === false) {
swipeStatus = "NoClock";
content += '' + Person.OFF + '	';
}
//if the person doesn't fit the critria above then they must have 4 swipes and a Person.Home time which is a value that shows how many mins thay are over or under there
//offical home times they are, the formatting is alittle stange but if it's > than 10 they have gone 10 miniets or over early
else if (Person.Home > 10) {
swipeStatus = "ClockEarly";
content += '' + Person.OUT + '	';
//same as above but gone late
} else if (Person.Home < -10) {
swipeStatus = "Clocklate";
content += '' + Person.OUT + '	';
//if non of that is true they have been good people and gone when they should!
} else {
swipeStatus = "ClockOntime";
content += '' + Person.OUT + '	';
}

content += '
';

});
content += '
';
content += '
';
\$(content).appendTo("tbody");
});

-

One trick I enjoy is to separate the information (knowledge) from the decision logic. So without changing your code much:

// What we know
var isOut = Person.OUT !== false;
var hasSwipedBack = Person.ON !== false;
var hasSwipedOff = Person.OFF !== false;
var hasClockedOn = Person.Clock !== false;
var hasNotSwipedBackInOneHour = Person.DifHours > 1 && Person.ON === false;

// What we will do
if (hasNotSwipedBackInOneHour) {
content += '' + Person.Name;
} else if (isOut) {
content += '' + Person.Name;
} else if (hasSwipedBack) {
content += '' + Person.Name;
} else if (hasSwipedOff) {
content += '' + Person.Name;
} else if (hasClockedOn) {
content += '' + Person.Name;
} else {
content += '' + Person.Name;
}

This can reduce the need for comments, separates some of the concerns, and can make the code more readable.

Disadvantages: If the determination of knowledge is processor-intensive, and some knowledge is not always used, then calculating it all at the top is inefficient.

We can also reduce a lot of duplication in your code, in keeping with the DRY principle:

// What we will do
var newColor = 'red';
if (hasNotSwipedBackInOneHour) {
// keep "out" color
} else if (isOut) {
// keep "out" color
} else if (hasSwipedBack) {
newColor = 'lime';
} else if (hasSwipedOff) {
newColor = 'yellow';
} else if (hasClockedOn) {
newColor = 'lime';
} else {
// keep "out" color
}

content += '' + Person.Name;

This would be advantageous if at some later point you decide you wanted to set (or just experiment with) background-color or perhaps border instead of the background property.

Finally the above can be represented by a single expression:

// Don't repeat color values, in case we want to change them in future
// Define them just once instead
var IN_COLOR  = 'lime';
var OUT_COLOR = 'red';

// What we will do
var newColor = isOut || hasNotSwipedBackInOneHour ? OUT_COLOR
: hasSwipedBack                    ? IN_COLOR
: hasSwipedOff                     ? 'yellow'
: hasClockedOn                     ? IN_COLOR
:                                    OUT_COLOR;

-

I'd suggest starting by using switch statements.

Whenever I see deeply nested / or that many if's I look to see if the language supports a case or switch statement and javascript does.

switch(expression) {
case n:
code block
break;
case n:
code block
break;
default:
default code block
}

http://www.w3schools.com/js/js_switch.asp

-
switch and all it's equivalents are discouraged as hard to read. Therefore many languages just don't have this concept. – ElmoVanKielmo Aug 21 '14 at 13:11
Like most languages, JavaScript's switch accepts a value for each case, not another expression. – David Harkness Aug 22 '14 at 5:43

You could also start from results and go back to arguments. Then you'll see that there are only 3 outcomes, with "red" color could be easily assumed as default one, which gives us only 2 (!) outcomes and default "in all other cases". I used C syntax (it is pretty much the same with Java and JavaScript, I belive), where you could say "blah != false" as just "blah", and "||" means logical "or". Hopefully the language you're using is also not such complex and allow such expressions.

if (Person.ON || Person.Clock) { //swipped back from dinner or clocked
content += '' + Person.Name;
} else if (Person.OFF) { //swipped off for dinner
content += '' + Person.Name;
} else { // all other cases - very wrong person
content += '' + Person.Name;
}

This is only a first part of your code, consider it like an example of approach.

I also encourage you to use css instead of direct writing of html tags from code. This is that I call "separation of concerns" and it will help you in future to deal with big projects, since you would be able to switch your brain from task to task and wouldn't required to hold a big picture in your brain every time, just a small piece of it. Brains do like it.

-


text:
# American Institute of Mathematical Sciences

March  2008, 1(1): 71-82. doi: 10.3934/dcdss.2008.1.71

## On radial solutions of semi-relativistic Hartree equations

 1 Department of Mathematics, and Institute of Pure and Applied Mathematics, Chonbuk National University, Jeonju 561-756, South Korea 2 Department of Mathematics, Hokkaido University, Sapporo 060-0810

Received  July 2006 Revised  August 2007 Published  December 2007

We consider the semi-relativistic Hartree type equation with nonlocal nonlinearity $F(u) = \lambda (|x|^{-\gamma} * |u|^2)u, 0 < \gamma < n, n \ge 1$. In [2, 3], the global well-posedness (GWP) was shown for the value of $\gamma \in (0, \frac{2n}{n+1}), n \ge 2$ with large data and $\gamma \in (2, n), n \ge 3$ with small data. In this paper, we extend the previous GWP result to the case for $\gamma \in (1, \frac{2n-1}n), n \ge 2$ with radially symmetric large data. Solutions in a weighted Sobolev space are also studied.
Citation: Yonggeun Cho, Tohru Ozawa. On radial solutions of semi-relativistic Hartree equations. Discrete & Continuous Dynamical Systems - S, 2008, 1 (1) : 71-82. doi: 10.3934/dcdss.2008.1.71
 [1] Myeongju Chae, Soonsik Kwon. Global well-posedness for the $L^2$-critical Hartree equation on $\mathbb{R}^n$, $n\ge 3$. Communications on Pure & Applied Analysis, 2009, 8 (6) : 1725-1743. doi: 10.3934/cpaa.2009.8.1725 [2] Van Duong Dinh. On the Cauchy problem for the nonlinear semi-relativistic equation in Sobolev spaces. Discrete & Continuous Dynamical Systems - A, 2018, 38 (3) : 1127-1143. doi: 10.3934/dcds.2018047 [3] Ming Wang. Sharp global well-posedness of the BBM equation in $L^p$ type Sobolev spaces. Discrete & Continuous Dynamical Systems - A, 2016, 36 (10) : 5763-5788. doi: 10.3934/dcds.2016053 [4] Takamori Kato. Global well-posedness for the Kawahara equation with low regularity. Communications on Pure & Applied Analysis, 2013, 12 (3) : 1321-1339. doi: 10.3934/cpaa.2013.12.1321 [5] Zhaoyang Yin. Well-posedness, blowup, and global existence for an integrable shallow water equation. Discrete & Continuous Dynamical Systems - A, 2004, 11 (2&3) : 393-411. doi: 10.3934/dcds.2004.11.393 [6] Hideo Takaoka. Global well-posedness for the Kadomtsev-Petviashvili II equation. Discrete & Continuous Dynamical Systems - A, 2000, 6 (2) : 483-499. doi: 10.3934/dcds.2000.6.483 [7] Seung-Yeal Ha, Jinyeong Park, Xiongtao Zhang. A global well-posedness and asymptotic dynamics of the kinetic Winfree equation. Discrete & Continuous Dynamical Systems - B, 2020, 25 (4) : 1317-1344. doi: 10.3934/dcdsb.2019229 [8] Thomas Y. Hou, Congming Li. Global well-posedness of the viscous Boussinesq equations. Discrete & Continuous Dynamical Systems - A, 2005, 12 (1) : 1-12. doi: 10.3934/dcds.2005.12.1 [9] Changxing Miao, Bo Zhang. Global well-posedness of the Cauchy problem for nonlinear Schrödinger-type equations. Discrete & Continuous Dynamical Systems - A, 2007, 17 (1) : 181-200. doi: 10.3934/dcds.2007.17.181 [10] Tarek Saanouni. Global well-posedness of some high-order semilinear wave and Schrödinger type equations with exponential nonlinearity. Communications on Pure & Applied Analysis, 2014, 13 (1) : 273-291. doi: 10.3934/cpaa.2014.13.273 [11] Nobu Kishimoto, Minjie Shan, Yoshio Tsutsumi. Global well-posedness and existence of the global attractor for the Kadomtsev-Petviashvili Ⅱ equation in the anisotropic Sobolev space. Discrete & Continuous Dynamical Systems - A, 2020, 40 (3) : 1283-1307. doi: 10.3934/dcds.2020078 [12] Jean-Daniel Djida, Arran Fernandez, Iván Area. Well-posedness results for fractional semi-linear wave equations. Discrete & Continuous Dynamical Systems - B, 2020, 25 (2) : 569-597. doi: 10.3934/dcdsb.2019255 [13] Boris Kolev. Local well-posedness of the EPDiff equation: A survey. Journal of Geometric Mechanics, 2017, 9 (2) : 167-189. doi: 10.3934/jgm.2017007 [14] Jerry Bona, Nikolay Tzvetkov. Sharp well-posedness results for the BBM equation. Discrete & Continuous Dynamical Systems - A, 2009, 23 (4) : 1241-1252. doi: 10.3934/dcds.2009.23.1241 [15] Lin Shen, Shu Wang, Yongxin Wang. The well-posedness and regularity of a rotating blades equation. Electronic Research Archive, 2020, 28 (2) : 691-719. doi: 10.3934/era.2020036 [16] A. Alexandrou Himonas, Curtis Holliman. On well-posedness of the Degasperis-Procesi equation. Discrete & Continuous Dynamical Systems - A, 2011, 31 (2) : 469-488. doi: 10.3934/dcds.2011.31.469 [17] Nils Strunk. Well-posedness for the supercritical gKdV equation. Communications on Pure & Applied Analysis, 2014, 13 (2) : 527-542. doi: 10.3934/cpaa.2014.13.527 [18] Haydi Israel. Well-posedness and long time behavior of an Allen-Cahn type equation. Communications on Pure & Applied Analysis, 2013, 12 (6) : 2811-2827. doi: 10.3934/cpaa.2013.12.2811 [19] Jun-ichi Segata. Well-posedness and existence of standing waves for the fourth order nonlinear Schrödinger type equation. Discrete & Continuous Dynamical Systems - A, 2010, 27 (3) : 1093-1105. doi: 10.3934/dcds.2010.27.1093 [20] Sergey Zelik, Jon Pennant. Global well-posedness in uniformly local spaces for the Cahn-Hilliard equation in $\mathbb{R}^3$. Communications on Pure & Applied Analysis, 2013, 12 (1) : 461-480. doi: 10.3934/cpaa.2013.12.461

2019 Impact Factor: 1.233


text:
# Module 2, Chapter 5 (Insurance Principles)

+1 vote
64 views

Exercises for 6.2.1 Insurance companies

Ex.6.6

LifeAssure is a proprietary insurance company specialising in life assurance. Their financial year runs from 1 February to 31 January. In the year ending on 31 January 2013, they had the following results: Total premium income R550 million Total claims paid out R200 million Total expenses R50 million The total money needed to be put aside for future claims is R150 million. The directors decide to distribute 80% of the profits to shareholders as dividends. There are 6 million shares in issue, priced at R285.40 per share. Using an assumption of a 5% p.a. dividend growth and a rate of interest of 12.5% p.a., calculate the share price immediately after this dividend payment is made. Ignore tax.

+1 vote
answered Jun 23, 2017 by (520 points)
selected Jun 26, 2017

The question wants you to price the share immediately after the last dividend payment. In order to do this we need to find the value of the last divided paid, $$D_0$$ (or the value of the next dividend), since we have been given the dividend growth rate. The information at the start of the question tells us how to calculate $$D_0$$:

First we need to profit

$$Profit = totalPremium Income - total Claims Paid - total Expenses Paid - required Reserve$$

$$Profit=550m-200m-50m-150m=150m$$

Then we need to total amount of dividends paid:

$$totalDividends=150m \times0.8=120m$$

Then we need the dividend per shareholder:

$$dividendsPerShareholder=120m/6m=R 20$$

Now we have $$D_0=20$$ , $$i=0.0125$$ and $$g=0.05$$ so we can price the share as we did in previous sections.


text:
# Why is a projection matrix symmetric?

I am looking for an intuitive reason for a projection matrix of an orthogonal projection to be symmetric. The algebraic proof is straightforward yet somewhat unsatisfactory.

Take for example another property: $P=P^2$. It's clear that applying the projection one more time shouldn't change anything and hence the equality.

So what's the reason behind $P^T=P$?

• In general, a projection matrix has $P^2=P$. However, only orthogonal projection matrices are symmetric. – robjohn Jul 31 '13 at 13:03

In general, if $P = P^2$, then $P$ is the projection onto $\operatorname{im}(P)$ along $\operatorname{ker}(P)$, so that $$\mathbb{R}^n = \operatorname{im}(P) \oplus \operatorname{ker}(P),$$ but $\operatorname{im}(P)$ and $\operatorname{ker}(P)$ need not be orthogonal subspaces. Given that $P = P^2$, you can check that $\operatorname{im}(P) \perp \operatorname{ker}(P)$ if and only if $P = P^T$, justifying the terminology "orthogonal projection."

There are some nice and succinct answers already. If you'd like even more intuition with as little math and higher level linear algebra concepts as possible, consider two arbitrary vectors $$v$$ and $$w$$.

Take the dot product of one vector with the projection of the other vector. $$(P v) \cdot w$$ $$v \cdot (P w)$$

In both dot products above, one of the terms ($$P v$$ or $$P w$$) lies entirely in the subspace you project onto. Therefore, both dot products ignore every vector component that is not in this subspace - they consider only components in the subspace. This means both dot products are equal to each other, and are in fact equal to: $$(P v) \cdot (P w)$$

Since $$(P v) \cdot w = v \cdot (P w)$$, it doesn't matter whether we apply the projection matrix to the first or second argument of the dot product operation. Some simple identities then imply $$P = P^T$$, so $$P$$ is symmetric (See step 2 below if you aren't familiar with this property).

If the above explanation isn't intuitive, we can use a little more math.

# Step 1.

First, prove that the two dot products above are equal.

Decompose $$v$$ and $$w$$: $$v = v_p + v_n$$ $$w = w_p + w_n$$

The projection of a vector lies in a subspace. The dot product of anything in this subspace with anything orthogonal to this subspace is zero. We use this fact on the dot product of one vector with the projection of the other vector: $$(P v) \cdot w \hspace{1cm} v \cdot (P w)$$ $$v_p \cdot w \hspace{1cm} v \cdot w_p$$ $$v_p \cdot (w_p + w_n) \hspace{1cm} (v_p + v_n) \cdot w_p$$ $$v_p \cdot w_p + v_p \cdot w_n \hspace{1cm} v_p \cdot w_p + v_n \cdot w_p$$ $$v_p \cdot w_p \hspace{1cm} v_p \cdot w_p$$ Therefore $$(Pv) \cdot w = v \cdot (Pw)$$

# Step 2.

Next, we can show that a consequence of this equality is that the projection matrix P must be symmetric. Here we begin by expressing the dot product in terms of transposes and matrix multiplication (using the identity $$x \cdot y = x^T y$$ ): $$(P v) \cdot w = v \cdot (P w)$$ $$(P v)^T w = v^T (P w)$$ $$v^T P^T w = v^T P w$$ Since v and w can be any vectors, the above equality implies: $$P^T = P$$

• Great answer. This also provides a intuition for a way to see adjoint in terms of projections instead of arbitrary linear operations – Rahul Deora Aug 12 '19 at 7:27

You can also directly verify this by definition of self-adjointness:

Let $U$ be a subspace of $V$, let $P$ be the orthogonal projection that projects onto $U$; let $x, y \in V$, and we can decompose them as $x=u_x+v_x, y=u_y+v_y$, with $u_x, u_y \in U, v_x, v_y \in U^\perp$, so $\langle u_x, v_y \rangle = \langle v_x, u_y \rangle = 0$. By definition of $P$, $P x = u_x, P y = u_y$.

Then $$\langle Px, y \rangle = \langle u_x,u_y+v_y \rangle = \langle u_x,u_y \rangle = \langle u_x + v_x, u_y \rangle = \langle x, Py \rangle$$ it follows $P$ is self-adjoint and its matrix is Hermitian (i.e. symmetric when $V$ is real).

UPDATE: I just read your question again; here's a more intuitive explanation.

Remember:

1. $\forall A \in \mathbb{R}^{n\times n}$, $\operatorname{null}(A)$ and $\operatorname{row}(A)$ are always orthogonal complements of each other in $\mathbb{R}^n$
2. when $A$ describes a projection, $A^2=A$, $\mathbb{R}^n = \operatorname{null}(A) \oplus \operatorname{col}(A)$

Now when $A$ describes an orthogonal projection, we also have $\operatorname{null}(A) \perp \operatorname{col}(A)$, so $\operatorname{null}(A)$ and $\operatorname{col}(A)$ are orthogonal complements of each other in $\mathbb{R}^n$; this happens iff $A$ is symmetric, so that $\operatorname{row}(A) = \operatorname{col}(A)$.

In the simple case where $P$ is projection onto a line with unit vector $\vec{e}$, you can look at it like this: if $\theta$ is the angle between $x$ and $\vec{e}$, and $\varphi$ is the angle between $y$ and $\vec e$, we have:

$$\langle Px,y \rangle = \langle \|x\| \cos{\theta \vec{e}},y \rangle = \|x\|\cos{\theta}\langle \vec{e},y \rangle = \|x\|\cos{\theta}\|y\|\cos{\varphi} \\ \langle x, Py \rangle = \langle x,\|y\|\cos{\varphi}\vec{e}\rangle = \|y\| \cos {\varphi} \langle x,\vec{e} \rangle = \|y\|\cos{\varphi}\|x\| \cos{\theta}.$$

(Recall that $P$ is symmetric iff $\langle Px, y \rangle = \langle x, Py \rangle$ for all $x,y \in V$.)

Another reason: Given a projection (orthogonal or not), we can describe it as the projection onto $A$ along $B$ (or $\rho_{A,B}$), where $A$ and $B$ are complementary subspaces. That is, if $V = A \oplus B$, take a basis for the vector space passing through the subspaces $A$ and $B$. Then the action of $P = \rho_{A,B}$ is to set the $B$-coordinates equal to zero, and leave the $A$ coordinates untouched. Every projection is of this form, and knowing $A$ and $B$ completely characterizes the projection. A projection is orthogonal iff $B = A^\perp$.

It is an exercise in the algebra of inner products to show that if $P = \rho_{A,B}$, then $P^T = \rho_{B^{\perp}, A^{\perp}}$ (no matter if $P$ is orthogonal or not). So if $P$ is an orthogonal projection and $A = B^{\perp}$, we can see that $\rho_{B^{\perp}, A^{\perp}} = \rho_{A,B}$, and $P$ is symmetric.


text:
# Path loss effect on BER

Does including log distance path loss to a communication system cause a drastic difference to the BER of the system?

In other words, if I have a simulation for a communication system without path loss, does the BER vs SNR curve differ drastically when I add path loss or should both the BER vs SNR curves(with and without path loss) look similar?

• If I normalize my receiver power at the receiver to unity and then calculate the noise power (based on SNR) and the BER performance, does it ensures that performance is independent of the path loss?? – user18288 Nov 15 '15 at 14:31
• If you have a new question, please ask it by clicking the Ask Question button. Include a link to this question if it helps provide context. - From Review – JRE Nov 16 '15 at 12:11

Generally speaking, the BER only depends on the SNR. If the received signal power $P_\mathrm{S}$ is reduced due to path loss, while the noise power $P_\mathrm{N}$ remains constant, then the SNR will be reduced, because the SNR is defined as $$\gamma = \frac{P_\mathrm{S}}{P_\mathrm{N}}$$ Consequently, the BER will be increased and the answer to your first question is: yes. However, this should not influence your BER vs SNR curves. Thus the answer to your second question is: no.
If your simulation behaves differently, i.e. if introducing a path loss "shifts" your BER curves, then the SNR is probably not calculated correctly. I suggest that you estimate the received signal power $\hat P_\mathrm{S}$ at the receiver (just before the sampler). Then the power of the additive noise should be calculated by $$P_\mathrm{N}=\frac{\hat P_\mathrm{S}}{\gamma}.$$ Then add noise with mean power $P_\mathrm{N}$ to the received signal. With this setup, your BER/SNR curves should be independent of path loss.


text:
# Unbreakable Ciphertext using hill cipher [closed]

Can anyone help me out by solving this ciphertext using m =2

TUNAISYPLUKUDDDPOOCZZLLCUDVDCYXJEKYIKORRPVAIYPGUUC

## closed as off-topic by yyyyyyy, kelalaka, Ella Rose♦Mar 17 at 15:24

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

• Welcome to Cryptography. If unbreakable then how do you expect one to solve? Is this homework or CTF. Either way, 2 is small, you have $26^4$. You can first check that the determinant is non-zero so that the matrix is invertible, then check that the result contains some valid strings from the target language. – kelalaka Mar 17 at 13:10
• It's a 2*2 matrix and m=2 there is no change in that. It is unbreakable ciphertext for me not in general. Anyways thanks for the suggestion. – Adi Mar 18 at 7:06


text:
On the barycentric subdivision of a poset - MathOverflow most recent 30 from http://mathoverflow.net 2013-05-22T04:33:32Z http://mathoverflow.net/feeds/question/57684 http://www.creativecommons.org/licenses/by-nc/2.5/rdf http://mathoverflow.net/questions/57684/on-the-barycentric-subdivision-of-a-poset On the barycentric subdivision of a poset Giacomo d'Antonio 2011-03-07T15:43:48Z 2011-03-07T16:47:25Z
Hi everybody,

I'm interested in the barycentric subdivision of a poset $P$, defined as the face poset of the corresponding order complex $\mathcal F(\Delta(P))$ (or alternatively, the poset of chains in $P$ ordered by inclusion). Actually, I'm interested in the subdivision of small categories, but I'm also happy understanding the poset case.

I was wondering if the functor $sd:\mbox{Poset} \to \mbox{Poset}$ has a right adjoint. I am aware of the Ex functor, which is right adjoint to the corresponding functor of simplicial sets. Can one define a similar object for posets?
 http://mathoverflow.net/questions/57684/on-the-barycentric-subdivision-of-a-poset/57694#57694 Answer by Karol Szumiło for On the barycentric subdivision of a poset Karol Szumiło 2011-03-07T16:47:25Z 2011-03-07T16:47:25Z
This functor has no right adjoint, since it doesn't preserve colimits. Let $[m]$ denote the linearly ordered set $\{0,\ldots,m\}$ and consider the pushout of $[0]\overset{0}{\to}[1]$ and $[0]\overset{1}{\to}[1]$, which can be identified with $[2]$. Now $\mathrm{sd}[2]$ is the poset of chains in $[2]$, but the pushout of $\mathrm{sd}[1]\leftarrow\mathrm{sd}[0]\to\mathrm{sd}[1]$ has only five elements, in fact it can be identified with the subset of $\mathrm{sd}[2]$ consisting of chains $\{0\},\{1\},\{2\},\{0,1\},\{1,2\}$.


text:
# What happens to the mean, median and mode for the data shown if the outlier is eliminated

###### Question:

What happens to the mean, median and mode for the data shown if the outlier is eliminated? 38 33 38 32 33 6b 30

#### Similar Solved Questions

##### Ning is suggested by Match the Meaning Synony toward the river For coch item below. choose...
ning is suggested by Match the Meaning Synony toward the river For coch item below. choose the word whose meaning is sugges the clue given. Then write the word in the space provided. d. haul For each it meaning on the lir 1. A forest fire made the frightened herd a demonstrate be stampede c. pledge ...
##### A solid disk, spinning counter-clockwise, has a mass of 4 kg and a radius of 7 m. If a point on the edge of the disk is moving at 8 m/s in the direction perpendicular to the disk's radius, what is the disk's angular momentum and velocity?
A solid disk, spinning counter-clockwise, has a mass of 4 kg and a radius of 7 m. If a point on the edge of the disk is moving at 8 m/s in the direction perpendicular to the disk's radius, what is the disk's angular momentum and velocity?...
##### Z?y? da R is the region bounded by the ellipse 9x2 + 4y2 = 36
z?y? da R is the region bounded by the ellipse 9x2 + 4y2 = 36...
##### What are the three requirements for a solution to the critical-section problem? Consider the following solution...
What are the three requirements for a solution to the critical-section problem? Consider the following solution to the dining-philosophers' problem. // Global variables. Shared among threads int state [5]; semaphore mutex; I/ Initially set to 1 semaphore s [5] I Initially s[i] is set to 0 for al...
##### Write 2 or more paragraphs : discuss the many different ways that communication impairment professionals improve...
write 2 or more paragraphs : discuss the many different ways that communication impairment professionals improve the quality of life for their patients, then discuss which communication profession is most appealing to you and why....
##### Morgan balance sheet 2019- x + =922967 W Questions at three transaction cycles exist in all...
morgan balance sheet 2019- x + =922967 W Questions at three transaction cycles exist in all nesses? me the major subsystems of the expenditure cle. entify and distinguish between the physical ad financial components of the expenditure cle. Hame the major subsystems of the conversion cycle Name the m...
##### Question 2. (24 points. Recall that in Assignment 1, we developed recursive algorithms for implementing the...
Question 2. (24 points. Recall that in Assignment 1, we developed recursive algorithms for implementing the specification Given a non-decreasing array Aſ1..n], and given a value v, return a number r such that • ifr=0 then v does not occur in A[1..n] • ifr #0 then 1 <r<n and A[r]...
##### Thought experiment . I came to class today with a deadly strain of the flu! If...
Thought experiment . I came to class today with a deadly strain of the flu! If nothing is done, I can spread my infection to up half of the class. • Luckily, I have 20 doses of a vaccine that will prevent those who sa receive it from becoming sick. move on • How should we allocate the dose...
##### MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answer the question 1) Define kine...
MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answer the question 1) Define kinetic energy A) energy associated with the temperature of an object B) energy associated with the motion of an object C) energy associated with the force of an object D) energy associated...
##### What is the complete predicate and the simple predicate in this sentence, the tiny mosquito landed on my arm
what is the complete predicate and the simple predicate in this sentence, the tiny mosquito landed on my arm...
##### I added the figures. im having problems understanding! 24, 2020 online lecture ork. Due in 2...
i added the figures. im having problems understanding! 24, 2020 online lecture ork. Due in 2 days 4/6 answered orion allows was exchange Shell Chorion Yolk sac contains nutrients Albumen provides water suiequo Amnion Allantois contains waste Fig 32.9 Amniotic eggs: 1) Help keep the embryo from dryi...


text:
## Chemistry 10th Edition

(a) $[OH^-] = 3.0 \times 10^{-5}M$ and $pH = 9.48$ (b) $[OH^-] = 6.8 \times 10^{-6}M$ and $pH = 8.83$
(a) 1. Since $N{H_4}^+$ is the conjugate acid of $NH_3$ , we can calculate its kb by using this equation: $K_b * K_a = K_w = 10^{-14}$ $1.8\times 10^{- 5} * K_a = 10^{-14}$ $K_a = \frac{10^{-14}}{ 1.8\times 10^{- 5}}$ $K_a = 5.556\times 10^{- 10}$ 2. Calculate the pKa Value $pKa = -log(Ka)$ $pKa = -log( 5.556 \times 10^{- 10})$ $pKa = 9.255$ 3. Check if the ratio is between 0.1 and 10: - $\frac{[Base]}{[Acid]} = \frac{0.25}{0.15}$ - 1.667: It is. 4. Check if the compounds exceed the $K_a$ by 100 times or more: - $\frac{0.25}{ 5.56 \times 10^{-10}} = 4.5\times 10^{8}$ - $\frac{0.15}{ 5.56 \times 10^{-10}} = 2.7\times 10^{8}$ 5. Using the Henderson–Hasselbalch equation: $pH = pKa + log(\frac{[Base]}{[Acid]})$ $pH = 9.255 + log(\frac{0.25}{0.15})$ $pH = 9.255 + 0.2218$ $pH = 9.477$ 6. Calculate the hydroxide concentration: pH + pOH = 14 9.477 + pOH = 14 pOH = 4.523 $[OH^-] = 10^{-pOH}$ $[OH^-] = 10^{- 4.523}$ $[OH^-] = 2.999 \times 10^{- 5}$ (b) 1 and 2. We've already calculated the $pK_a$ value for $N{H_4}^+$ 3. Che ** $(NH_4)_2SO_4 = 0.20M$; therefore: $N{H_4}^+ = 0.40M$ ck if the ratio is between 0.1 and 10: - $\frac{[Base]}{[Acid]} = \frac{0.15}{0.4}$ - 0.375: It is. 4. Check if the compounds exceed the $K_a$ by 100 times or more: - $\frac{0.15}{5.556 \times 10^{-10}} = 2.7\times 10^{8}$ - $\frac{0.4}{5.556 \times 10^{-10}} = 7.2\times 10^{8}$ 5. Using the Henderson–Hasselbalch equation: $pH = pKa + log(\frac{[Base]}{[Acid]})$ $pH = 9.255 + log(\frac{0.15}{0.4})$ $pH = 9.255 + -0.4259$ $pH = 8.829$ 6. Calculate the $[OH^-]$ pH + pOH = 14 8.829 + pOH = 14 pOH = 5.171 $[OH^-] = 10^{-pOH}$ $[OH^-] = 10^{- 5.171}$ $[OH^-] = 6.745 \times 10^{- 6}$


text:
Remark 7.20.5. Let $u : \mathcal{C} \to \mathcal{D}$ be a functor between categories. Given morphisms $g : u(U) \to V$ and $f : W \to V$ in $\mathcal{D}$ we can consider the functor

$\mathcal{C}^{opp} \longrightarrow \textit{Sets},\quad T \longmapsto \mathop{Mor}\nolimits _\mathcal {C}(T, U) \times _{\mathop{Mor}\nolimits _\mathcal {D}(u(T), V)} \mathop{Mor}\nolimits _\mathcal {D}(u(T), W)$

If this functor is representable, denote $U \times _{g, V, f} W$ the corresponding object of $\mathcal{C}$. Assume that $\mathcal{C}$ and $\mathcal{D}$ are sites. Consider the property $P$: for every covering $\{ f_ j : V_ j \to V\}$ of $\mathcal{D}$ and any morphism $g : u(U) \to V$ we have

1. $U \times _{g, V, f_ i} V_ i$ exists for all $i$, and

2. $\{ U \times _{g, V, f_ i} V_ i \to U\}$ is a covering of $\mathcal{C}$.

Please note the similarity with the definition of continuous functors. If $u$ has $P$ then $u$ is cocontinuous (details omitted). Many of the cocontinuous functors we will encounter satisfy $P$.

There are also:

• 5 comment(s) on Section 7.20: Cocontinuous functors

In your comment you can use Markdown and LaTeX style mathematics (enclose it like $\pi$). A preview option is available if you wish to see how it works out (just click on the eye in the toolbar).


text:
Bug973

Synopsis

# Documentation

Arguments

 :: forall a b. (Show a, Read b) => a this gets turned into a string... -> b ...from which this is read

Arguments

 :: forall b a. (Show a, Read b) => a this gets turned into a string... -> b ...from which this is read

Same as showRead, but with type variable order flipped