## Setting a complex DataRange for a defined function

Hello i am relatively new to mathematica and i have a a problem regading my model.
I have following function:

P(t_) := P(t) = P(t – 1) + a* (df(t – 1) + dc(t – 1));

(df & dc are defined and not so important for this question.)

Now i want to restrict this function following the expression:

P(t)(1-i) < P(t+1) < P(t)(1+i)

i is supposed to go from 0 up to 0.13 for each period t.

For context, this function is supposed to represent prices in a market and i want to set up a price restriction.

## Extract substrings with defined length from a string

I have a string like this one

``````str = "this and that but also thit and that";
``````

Now I want to extract, the first 3 letters before and after ” and ” so that the outcome is

``````{his and tha, hit and tha}
``````

I tried it with

``````StringCases[str,
x__ ~~ " and " ~~ y__ :> {StringTake[x, -3], StringTake[y, 3]}]
``````

but this extracts only the second substring `{{"hit", "tha"}}`. And using `StringCases[str, _ ~~ " and " ~~ _]` extracts only one letter `{"s and t", "t and t"}`. So is there a way to define a `Blank` with a particular length?

## Do we have an option to change/override the drupalsettings variable which is defined by some other module through our custom module?

Do we have an option to change/override the drupalsettings variable which is defined by some other module through our custom module ?

Here: by `drupalsettings`, I am asking about the Drupal behaviors variable.

## err_too_many_redirects wordpress if not defined siteurl in wp-config

I’m currently facing a lot of issues with my wordpress+woocommerce, php-fpm processes are using roughly the 90% of the CPU of my VPS, so i started to investigate what could be happening.

I’m right now a bit desperate because i don’t find the cause of this errors so i thought it could be that the page is trying to redirect itself so many times it’s collapsing the server (i’m getting a 502 each time someone adds something to the cart) so changing some of the .htacess configurations and the wp-config options i found that if i remove the define(‘WP_HOME’, “mysite”); and define(‘WP_SITEURL’, “mysite”); even if i’ve defined both options in the database and are still the same damn value the website throws a err_too_many_redirects.

Do someone know what may be causing this error?

Further info; i’ve this rule in my .htacess:

``````<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php\$ - (L)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php (L)
</IfModule>
``````

## t sql – User-defined function returns first character only although RETURN VARCHAR(10) is defined?

Everyone,

I cannot figure out what is missing in the below user-defined function:

``````CREATE OR ALTER FUNCTION ufn_GetSalaryLevel(@Salary money)
RETURNS VARCHAR(10)
AS
BEGIN
IF (@Salary < 30000) RETURN 'Low';
ELSE IF (@Salary <= 50000) RETURN 'Average';
ELSE RETURN 'High';
RETURN '';
END;

SELECT dbo.ufn_GetSalaryLevel(100440)
``````

The output is including only the first character of the ‘Low”https://dba.stackexchange.com/”Average”https://dba.stackexchange.com/”High’ return values:

``````-----------------------------------------------------------------------
H

(1 row affected)
``````

Why is MS SQL Server Management Studio not taking the VARCHAR(10) into account?

P.s. Please find my output below – I cannot figure out why it does not work as expected?

P.s.2: the function has a single parameter, I seem not to find another function with the same name…

## pandas – PYTHON Matplotlib : hatched marker in legend appears in different color than defined

I have defined 3 different markers including 1 hatched.
For the hatched marker I understood from the internet that separating the color of the hatch bar and the edge marker is confusing so I went the easy way and defined edgecolor = black.

Later on I call my legends and place them in order using plt.legend, however the hatched marker in graph appears with black hatch, and in the legend with white hatch, any idea why ?

Here is a selection of my code when I call them:

``````p1 = plt.scatter(x= df4_activite('To be'),
y= df4_activite('Priorité'),
s= 300,
edgecolors='black',
color='#8f1d28',
alpha=1, label="Ressources",
zorder = 5)

p2 = plt.scatter(x= df4_activite('Ressources'),
y= df4_activite('Priorité'),
s= 300,
edgecolors='black',
color='#399432',
alpha=1, label="Ressources",
zorder = 5)

# hatched marker for the outlier:
p3 = plt.scatter(value_max-0.19,6,
s =300,
marker="o",
hatch=5*"https://stackoverflow.com/",
edgecolors='black',
facecolor='#399432',
#label="outlier: {}".format(round(df4_activite(('Ressources','To be')).max().max(),1)),
zorder = 5)

plt.legend((p1,p2,p3),
("marker 1", "marker 2", "marker 3"),
prop={'size': legendlabel},
bbox_to_anchor=(1.4,0.96))
``````

The result with the marker issue looks like this:

## python – NameError: name ‘PlayerIG’ is not defined

I have just started learning Python and decided to get extra practice and followed an youtube tutorial on how to create an adventure text-based game. Because the video was old, I made a few changes for Python 3.8 and added a few extra options for better navigation.

The current issue I’m running is `NameError: name 'PlayerIG' is not defined`. In the tutorial, the programmer made that variable global.
That didn’t work, so I passed as a parameter and it was working fine until a few other errors started to occur: EAttack was getting the same error `(NameError: name not defined)`, but I made it global and that seemed to work until it didn’t.
I tried to pass PlayerIG into all functions that used it, but that didn’t solve the problem either.
PlayerIG is essential for the fighting system, please help me understand why it is not being recognized anymore.

Another issue is that in @property, the variable attack is not updating self.base_attack inside the Player class why is that happening if I used return?
I have shared all the code bellow.
This is the tutorial I was following //
This is the original code shared by the owner of the tutorial

``````import sys
import os
import random
import pickle

weapons = {"Great Sword":40}

class Player:
os.system('clear')
def __init__(self, name):
self.name = name
self. maxhealth = 100
self.health = self.maxhealth
self.base_attack = 10
self.gold = 0
self.pots = 0
self.weap = ("Rusty Sword")
self.curweap = ("Rusty Sword")

@property
def attack(self, base_attack):
attack = self.base_attack
if self.curweap == {"Rusty Sword"}:
attack += 5

elif self.curweap == {"Great Sword"}:
attack += 15

return attack

class Goblin:
os.system('clear')
def __init__(self, name):
self.name = name
self. maxhealth = 50
self.health = self.maxhealth
self.attack = 5
self.goldgain = 10
self.pots = 1
GoblinIG = Goblin("Goblin")

class Zombie:
os.system('clear')
def __init__(self, name):
self.name = name
self. maxhealth = 70
self.health = self.maxhealth
self.attack = 7
self.goldgain = 15
self.pots = 2
ZombieIG = Zombie("Zombie")

def main():
os.system('clear')
print("Welcome to my game!n")
print("1.) Start")
print("3.) Exit")

option = input("--> ")
if option == "1":
start()
elif option == "2":
if os.path.exists("savefile") == True:
os.system('clear')
with open('savefile', 'rb') as f:
option = input("--> ")
start1(PlayerIG)
else:
print("You have no save file for this game.")
option = input("--> ")
main()
elif option == "3":
sys.exit()
else:
main()

def start():
os.system('clear')
option = input("--> ")
PlayerIG = Player(option)
start1(PlayerIG)

def start1(PlayerIG):
os.system('clear')
print("Name: %s" % PlayerIG.name)
print("Attack: %i" % PlayerIG.base_attack)
print("Current Weapons: %s" % PlayerIG.curweap)
print("Health: %i/%i" % (PlayerIG.health, PlayerIG.maxhealth))
print("Gold: %i" % PlayerIG.gold)
print("Pots: %i" % PlayerIG.pots)
print("1.) Fight")
print("2.) Store")
print("3.) Inventory")
print("4.) Save")
print("5.) Exit")
option = input("--> ")
if option == "1":
prefight()
elif option == "2":
store()
elif option == "3":
inventory()
elif option == "4":
os.system('clear')
with open('savefile', 'wb') as f:
pickle.dump(PlayerIG, f)
print("nGame has been saved!n")
option = input(' ')
start1(PlayerIG)
elif option == "5":
sys.exit()
else:
start1(PlayerIG)

def inventory():
os.system('clear')
print("What do you want to do?")
print("1.) Equip Weapon")
print("2.) Drink a potion")
print("b.) Go back")
option = input(">>> ")
if option == "1":
equip()
elif option == "2":
drinkpot()
elif option == 'b':
start1(PlayerIG)

def equip():
os.system('clear')
print("What do you want to equip?")
for weapon in PlayerIG.weap:
print(weapon)
print("(b) to go back")
option = input(">>> ")
if option == PlayerIG.curweap:
print("You already have that weapon equipped")
option = input("--> ")
equip()
elif option == "b":
inventory()
elif option in PlayerIG.weap:
PlayerIG.curweap = option
print ("You have equipped %s." % option)
option = input("--> ")
equip()
else:
print("You don't have %s in your inventory" % option)
start1(PlayerIG)

def prefight():
os.system('clear')
global enemy
enemynum = random.randint(1, 2)
if enemynum == 1:
enemy = GoblinIG
else:
enemy = ZombieIG
fight(PlayerIG)

def fight(PlayerIG):
os.system('clear')
print("%s        VS        %s" % (PlayerIG.name, enemy.name))
print("%s's Health: %d/%d  %s's Health: %i/%i" % (PlayerIG.name, PlayerIG.health, PlayerIG.maxhealth, enemy.name, enemy.health, enemy.maxhealth))
print("Potions %i" % PlayerIG.pots)
print("1.) Attack")
print("2.) Drink potion")
print("3.) Run")
option = input("--> ")
if option == "1":
attack()
elif option == "2":
drinkpot()
elif option == "3":
run()
else:
fight(PlayerIG)

def attack():
os.system('clear')
PAttack = random.uniform(PlayerIG.base_attack / 2, PlayerIG.base_attack)
global EAttack
EAttack = random.uniform(enemy.attack / 2, enemy.attack)
if PAttack == PlayerIG.base_attack / 2:
print("You miss!")
else:
enemy.health -= PAttack
print("You deal %i damage!" % PAttack)
option = input("--> Press Enter.")
if enemy.health <= 0:
win()
os.system('clear')
if EAttack == enemy.attack/2:
print("Enemy missed.")
else:
PlayerIG.health -= EAttack
print("The enemy deals %i damage!" % EAttack)
option = input("--> Press Enter. ")
if PlayerIG.health <= 0:
else:
fight(PlayerIG)

def drinkpot():
os.system('clear')
if PlayerIG.pots == 0:
print("You don't have any potion!")
fight(PlayerIG)
else:
PlayerIG.health += 50
if PlayerIG.health > PlayerIG.maxhealth:
PlayerIG.health = PlayerIG.maxhealth
PlayerIG.pots -= 1
print("You drank a potion!")
print("1.) Go to fight")
option = input("--> ")
if option == "1":
fight(PlayerIG)
elif option == "2":
start1(PlayerIG)

def run ():
os.system('clear')
runnum = random.randint(1, 3)
if runnum == 1:
print("You have successfully ran away!")
option = input("--> ")
start1(PlayerIG)
else:
print("You failed to get away!")
option = input("--> ")
os.system('clear')
if EAttack == enemy.attack/2:
print("Enemy missed.")
else:
PlayerIG.health -= EAttack
print("The enemy deals %i damage!" % EAttack)
option = input("--> ")
if PlayerIG.health <= 0:
else:
fight(PlayerIG)

def win():
os.system('clear')
enemy.health = enemy.maxhealth
PlayerIG.gold += enemy.goldgain
PlayerIG.pots += enemy.pots
print("You have defeated the %s!" % enemy.name)
print("You gained %i gold!" % enemy.goldgain)
print("You gained %i potion!" % enemy.pots)
option = input("--> ")
start1(PlayerIG)

os.system('clear')
print("You have died!")
os.system('clear')
start1(PlayerIG)

def store():
os.system('clear')
print("Welcome to the shop!")
print("nWhat would you like to buy?n")
print("1.) Great Sword")
print("back")
print(" ")
option = input("--> ")

if option in weapons:
if PlayerIG.gold >= weapons(option):
os.system('clear')
PlayerIG.gold -= weapons(option)
PlayerIG.weap.append(option)
print("You have bought %s" % option)
option = input("-->  ")
store()

else:
os.system('clear')
print("You don't have enough gold")
option = input("--> ")
store()

elif option == "back":
start1(PlayerIG)

else:
os.system('clear')
print("That item does not exist")
option = input("--> ")
store()

main()
``````

## notation – What does it mean when a variable is defined with a subscript but used without one in equations? (and other questions)

defines $$x_i ,i=1,dots,n$$ where $$x$$ has a subscript. However succeeding the definition, the formula contains only $$x$$.

How am I supposed to interpret this generic notation in terms of math?

My next question about the article is that in step 2 and 3 of LLoyd’s algorithm it uses $$x_j$$ but that is not explicitly defined. How can I reconcile the notation with the definition of $$x_i$$?

Lastly, in step 2 of Lloyd’s algorithm, $$l$$ according to my understanding is not a fixed variable, that is, it is iterating. How can we define $$l$$ in that case like we have defined $$j=1,dots,n$$?

## Defining a function comprising other defined functions

In the finite element method $$x$$$$y$$ space is represented in terms of an isoparametric $$xi$$$$eta$$ space using shape functions $$N_{i}$$ as interpolants of nodal coordinates $$(x_{i},y_{i})$$ where

$$x=sum_{i=1}^{n}N_{i}x_{i}$$

and in this case $$n=5$$.

I am trying to create $$x$$ as a function of $$xi$$ and $$eta$$ and display the function as well as a simplified version of the function. See the code below.

``````(* Interpolatnts *)
N1((Xi)_, (Eta)_) := -1/4 (Xi) (1 - (Xi)) (1 - (Eta));
N2((Xi)_, (Eta)_) := 1/2 (1 - (Xi)) (1 + (Xi)) (1 - (Eta));
N3((Xi)_, (Eta)_) := 1/4 (Xi) (1 + (Xi)) (1 - (Eta));
N4((Xi)_, (Eta)_) := 1/4 (1 + (Xi)) (1 + (Eta));
N5((Xi)_, (Eta)_) := 1/4 (1 - (Xi)) (1 + (Eta));
(* Nodal Positions *)
X1 = 0; Y1 = 0;
X2 = 1/2; Y2 = 1/8;
X3 = 1; Y3 = 1/2;
X4 = 1; Y4 = 1;
X5 = 0; Y5 = 1;
x((Xi)_, (Eta)_) := N1 X1 + N2 X2 + N3 X3 + N4 X4 + N5 X5;
Print(x((Xi), (Eta)));
Print(Simplify(x((Xi), (Eta))));
``````

Which produces the output

``````N2/2+N3+N4
N2/2+N3+N4
``````

which is not in terms of $$xi$$ and $$eta$$. Once this is working I would also like to print out $$y(xi,eta)$$ which is calculated in a similar manner.

Any help would be appreciated.

## nt.number theory – On the \$mathsf{LCM}\$ of a set of integers defined by moduli of powers

For integers $$a,b,t$$ define $$mathcal R_t(a,b)={qinmathbb Zcap(1,min(a^t,b^t)): a^tequiv b^tbmod q}$$ and $$mathsf{LCM}(mathcal R_t(a,b))$$ to be $$mathsf{LCM}$$ of all entries in $$mathcal R_t(a,b)$$.

Similar reasoning to On \$mathsf{LCM}\$ of a set of integers gives $$mathsf{LCM}(mathcal R_t(a,b))leqmathsf{LCM}(T_t(a,b))$$ where $$T_t(a,b)$$ is defined as $$T_t(a,b)=Big{qinmathbb Zcap(1,infty):q|Big((a-b)sum_{i=0}^{t-1}a^{t-1-i}b^iBig)Big}.$$

So $$mathsf{LCM}(mathcal R_t(a,b))=mathsf{LCM}(T_t(a,b))$$ holds.

If $$a,binbig(frac r2,rbig)$$ hold and are coprime then what is the probability $$mathsf{LCM}(mathcal R_t(a,b)) at some $$alphain(0,t)$$ and $$beta>0$$?