How to reproduce this tensor calculation with Mathematica

The tensor operation shown in the red box is used in the textbook to prove that there are only 9 independent constants for orthotropic materials:

enter image description here

I want to use MMA to reproduce the operation of $ C_{pqmn}=l_{ip}\;l_{jq}\;l_{km}\;l_{ln}\;C_{ijkl}$ (Where $ C_{ijkl}$ is the stiffness tensor), but at present, I have no specific idea. I will continue to update the details to make it perfect.

Additional details:

Details are being added…

Improving binary recursion calculation

I am trying to write a program in Python for the infamous egg drop puzzle using recursion. In case you do not know the problem statement, here it is:

One solution to this puzzle would be to use a recursive function that returns the maximum floors of a building that would be allow for $ Solvable(F, D, B)$ to be true, represented as such, as function $ f$ :

$ f(D, B)$ $ =$ $ 1$ $ +$ $ f(D – 1, $ $ B – 1)$ $ +$ $ f(D – 1$ , $ B)$

… where $ D$ is the number of drops left, and $ B$ is the number of breaks allowed. This solution makes use of how an egg can either break on $ f(D – 1, $ $ B – 1)$ floors below, and $ f(D – 1$ , $ B)$ floors above.

As you can see, this results in the formation of a binary recursive function as shown above. Combined with the fact that we know that $ f(1, B)$ $ =$ $ 1$ for all values of $ B$ , and how $ f(D, 1)$ $ =$ $ D$ for all values of $ D$ , this problem should be no problem to solve for a program that can handle recursion very well. However, Python has a knack for being unable to handle recursion as well as some other languages.

As such I would like to know whether the maximum floors returned by function $ f$ can be determined for a set of values where $ 1<=D, B<=200,000,000$ in Python.

Here is a list of the techniques I have tried so far, to little avail:
1. Memoisation (Caching values of $ f(D, B)$ )
2. Since we know that $ f(d, b)$ for $ d <= b$ is equal to $ f(d, b)$ where $ d = b$ , with $ d$ held constant, we can reduce the number of cached pairs of $ d$ and $ b$
3. When $ d = b$ , $ f(d, b)$ is equivalent to $ 2^d – 1$ , thus removing the need for the binary recursion for $ d = b$

How to speed up the calculation of the number of 4 * 4 Young tableaux

I find the problem of calculating n * n Young tableaux from here. I can get the number of 3*3 Young tableaux by violent enumeration is 42:

Partition[#, 3] & /@    Select[Permutations[     Range[9]], ((#[[2]] > #[[1]]) && (#[[3]] > #[[2]]) && (#[[5]] > \ #[[4]]) && (#[[6]] > #[[5]]) && (#[[8]] > #[[7]]) && (#[[9]] > \ #[[8]]) && (#[[1]] < #[[4]]) && (#[[1]] < #[[4]]) && (#[[4]] < \ #[[7]]) && (#[[2]] < #[[5]]) && (#[[5]] < #[[8]]) && (#[[3]] < \ #[[6]]) && (#[[6]] < #[[9]])) &] // Length 

But in the case of 4 * 4, the calculation speed of my algorithm below is very slow. How can I modify it to improve the calculation speed?

Needs["Combinatorica`"] s = {}; k = 0; rule = ((#[[1]] < #[[2]]) && (#[[2]] < #[[3]]) && (#[[3]] < #[[4]]) \ && (#[[5]] < #[[6]]) && (#[[6]] < #[[7]]) && (#[[7]] < #[[8]]) && \ (#[[9]] < #[[10]]) && (#[[10]] < #[[11]]) && (#[[11]] < #[[12]]) && \ (#[[13]] < #[[14]]) && (#[[14]] < #[[15]]) && (#[[15]] < #[[16]]) && \ (#[[1]] < #[[5]]) && (#[[5]] < #[[9]]) && (#[[9]] < #[[13]]) && \ (#[[2]] < #[[6]]) && (#[[6]] < #[[10]]) && (#[[10]] < #[[14]]) && \ (#[[3]] < #[[7]]) && (#[[7]] < #[[11]]) && (#[[11]] < #[[15]]) && \ (#[[4]] < #[[8]]) && (#[[8]] < #[[12]]) && (#[[12]] < #[[16]])) &;  For[i = 1, i <= 16! - 1, i++,   If[MatchQ[Combinatorica`NthPermutation[i, Range[16]], _?(rule)],    k++;]] k 

A Thri-Kreen wielding two long swords two handedly, damage bonus calculation

A Thri Kreen has multiple limbs according to page 15 of the expanded psionics handbook:

Multiple Limbs thri-kreen have four arms and thus can take the Multiweapon Fighting feat page 304 of the Monster Manual instead of the Two-Weapon Fighting feat. Thri-kreen can also take the Multiattack feat these feats are not bonus feats.

The multiweapon fighting feat is described thus:

Multiweapon Fighting penalties for fighting with multiple weapons are reduced by 2 with the primary hand and reduced by 6 with off hands. Normally a creature without this feat takes a -6 penalty on attacks made with its primary hand and a -10 penalty on attacks made with its off hands. It has one primary hand and all the others are off hands.

If a thri-kreen uses two long swords in a two handed grip what happens? According to page 134 of the player’s handbook, we can see:

Strength Bonus: When you hit with a melee or thrown weapon, including a sling, add your Strength modifier to the damage result. A Strength penalty, but not a bonus, applies on attacks made with a bow that is not a composite bow.

Off-Hand Weapon: When you deal damage with a weapon in your off hand, you add only 1/2 your Strength bonus.

Wielding a Weapon Two-Handed: When you deal damage with a weapon that you are wielding two-handed, you add 1-1/2 times your Strength bonus. However, you don’t get this higher Strength bonus when using a light weapon with two hands (see Light, One-Handed, and Two-Handed Melee Weapons, page 113).

So the question is, on the off hand long sword wielded two handedly does the thri-kreen add only half his strength bonus with the off hand long sword or does he add 1-1/2 times his strength bonus or does he add 0.75 his strength bonus, or some other calculation?

Thri-Kreen multi-attack total attack bonus calculation

Would you mind casting an eye over this and check my understanding is correct?

This question refers to an NPC I’m modelling from AD&D Pegasus magazine #8. It’s a 5th level Thri Kreen fighter and its base attack bonus is +7 it has +5 from its fighter levels and +2 from its hit dice. It has the Multiweapon Fighting feat. It has an 18 strength (+4). Therefore its total attack modifier is +11

Multiweapon Fighting penalties for fighting with multiple weapons are reduced by 2 with the primary hand and reduced by 6 with off hands. Normally a creature without this feat takes a -6 penalty on attacks made with its primary hand and a -10 penalty on attacks made with its off hands. It has one primary hand and all the others are off hands.

And the multi-attack feat.

Multi-attack the creature’s secondary attacks with natural weapons take only a -2 penalty. Without this feat the creature’s secondary attacks with natural weapons take a -5 penalty.

It’s using a Gythka and a longsword (actually rather than a long sword it’s a chain blade from Bastion Press’ Torn Asunder 3rd party rule system, but for simplicity of this question let’s assume it’s a longsword)

The Gythka is being used as a double weapon:

Gythka: This two-handed exotic melee weapon is a polearm with a blade at each end. You can fi ght with it as if fighting with two weapons, but if you do, you incur all the normal attack penalties associated with fighting with two weapons, just as if you were using a one-handed weapon and a light weapon. A thri-kreen can wield two gythkas at once as double weapons due to its four arms, but takes penalties as if its off-hand weapon were a one-handed weapon, not a light weapon.

Therefore full attack bonuses would look like this:

+7 / +7 gythka, +7 longsword and two secondary with natural weapons +9 claw and +9 bite.

-4 penalty is imposed upon the manufactured weapons because although the thri kreen is using a double weapon (normally treated as a one handed and a light weapon therefore imposing a -2 penalty on manufactured weapon attacks with multi weapon fighting feat) he is also using a longsword which is a one handed weapon and instead a -4 penalty is imposed on ALL manufactured weapon attacks. The claw and the bite have a -2 penalty instead of -5 due to the Multi-attack feat.

Is my understanding of the total attack bonus with the respective weapons correct?

Also because it’s part of the same question in the Expanded Psionics handbook on page 15 gives an example of a thri kreen fighting with 3 shortswords and seems to be implying the thri-kreen can only take a bite OR a claw as a secondary attack. I believe this is incorrect.

Natural Attacks: Thri-kreen can attack with four claws and a bite. The claws deal 1d4 points of damage, and the bite is a secondary attack that also deals 1d4 points of damage. A thri-kreen can attack with a weapon (or multiple weapons) at its normal attack bonus, and make either a bite or claw attack as a secondary attack. For example, a thri-kreen ranger with the Multiweapon Fighting feat who is armed with three short swords could attack with all three swords at a –2 penalty (the normal penalty for fighting with multiple weapons while using light weapons in its off hands) and also make a bite attack at a –5 penalty.

Because, however this is not the case when we consult the entry for thri-kreen on page 213 of the same book.

Full Attack: 4 claws +3 melee (1d4+1) and bite –2 melee (1d4 plus poison); or longspear +3 melee (1d8+1/×3) and 2 claws –2 melee (1d4) and bite –2 melee (1d4 plus poison); or javelin +4 ranged (1d6+1)

Wherein it takes a primary attack with the longspear, 2 claw attacks AND a bite attack.

Error messages generated in a table calculation prevent “good” elements of that table being accessed

If I make a batch fitting routine, something like:

FitResultsData =      Table[              SpectrumData = Import[SpectrumList[[i]]];                SpectrumFit = NonlinearModelFit[SpectrumData, Model, {a, b, c}, x];                  aFitOut = a /. SpectrumFit["BestFitParameters"];                  bFitOut = b /. SpectrumFit["BestFitParameters"];                     cFitOut = c /. SpectrumFit["BestFitParameters"];               {i, aFitOut , bFitOut, cFitOut},              {i, 1, Length[SpectrumList]}             ] 

and a fit fails completely, e.g. I get a Power::infy: Infinite expression 1/0.^2 encountered. error or something, I find that when it comes to going on to use FitResultsData after all Table[..] has finished fitting and executing no matter which row I select for example FitResultsData[[1]] the error Power::infy: Infinite expression 1/0.^2 encountered. will be returned. This happens even say the original source of the error was in spectrum i = 99.

Is there a method of escaping such errors, such that even though one spectrum fit might be bad, it doesn’t stop be accessing the 99% successful

Can you benefit from the Defense fighting style while not using armor AC calculation?

Let’s assume a Lizardfolk fighter, with the Defense fighting style, wearing leather armor. Lizardfolk, per Volo’s p. 113, get Natural Armor:

You have tough, scaly skin. When you aren’t wearing armor, your AC is 13 + your Dexterity modifier. You can use your natural armor to determine your AC if the armor you wear would leave you with a lower AC. A shield’s benefits apply as normal while you use your natural armor.

Emphasis mine. Leather armor gives a DC of 11+Dex but, according to the above rule, I am allowed to use my superior Natural Armor DC of 13+Dex (this is different from mage armor and Draconic Resilience and which I almost asked about, but they specifically disallow wearing armor).

Now, at the same time, I’m wearing armor, which should qualify me for my chosen Fighting Style, Defense (PHB p. 72):

Defense: While you are wearing armor, you gain a +1 bonus to AC.

Emphasis, again, mine – it doesn’t say anything about actually using the armor’s AC.

Could I combine the two to claim an AC of 14+Dex?

Argon2id key derivation rate calculation question

Just wanted to know if this was an accurate way of determining how long it would take someone with an 8GB GPU do derive 1 million keys using some assumed parameters below:

Time per derivation...........: 3.5 seconds Memory required per derivation: 128MB GPU Max Memory................: 8GB 

So, 128MB = 0.125GB. Max derivations that could be happening at any given time = 8/0.125 = 64.

Each derivation takes 3.5 seconds, so derivations per second = 64/3.5 = ~18.3

So, 1 million key derivations would take (1000000×18.3)/3600 = ~15 hours.

Does this seem accurate, or am I unknowingly making too many assumptions? Thanks.

Should weight of PC itself counts at weight capacity calculation?

Imagine dwarf Alice (200 pounds) and gnome Bob (40 pounds). Both characters have 10 Strength.

So, as PHB says, both of them are able to carry 10 × 15 = 150 pounds.

Does it mean that Bob’s effective capacity is 150 – 40 = 110 pounds and Alice’s effective capacity is 150 – 200 = -50, which means she has problems with carying her own body?

Or maybe character weight does not count for capacity calculation purposes?