I have a list of polynomial expressions, (in my case obtained as the output of a Groebner basis computation), that I would like to view. I am using Jupyter, and I have started off with
import sympy as sy
sy.init_printing()
This causes an individual expression to be given nicely typeset. For a non-Groebner example:
sy.var('x')
fs = sy.factor_list(x**99-1)
fs2 = [x[0] for x in fs[1]]
fs2
The result is a nice list of LaTeX-typeset expressions. But how do I print these expressions one at a time; or rather; one per line? I've tried:
for f in fs2:
sy.pprint(f)
but this produces ascii pretty printing, not LaTeX. In general the expressions I have tend to be long, and I really do want to look at them individually. I can of course do
fs2[0]
fs2[1]
fs2[2]
and so on, but this is tiresome, and hardly useful for a long list. Any ideas or advice? Thanks!
Jupyter (through IPython) has a convenience function called display which works well with SymPy:
import sympy as sy
sy.init_printing()
sy.var('x')
fs = sy.factor_list(x**99-1)
fs2 = [x[0] for x in fs[1]]
for f in fs2:
display(f)
Output:
You can also get the latex code for each of these polynomials by using the latex function:
import sympy as sy
from sympy.printing.latex import latex
sy.init_printing()
sy.var('x')
fs = sy.factor_list(x**99-1)
fs2 = [x[0] for x in fs[1]]
for f in fs2:
print(latex(f))
Output:
x - 1
x^{2} + x + 1
x^{6} + x^{3} + 1
x^{10} + x^{9} + x^{8} + x^{7} + x^{6} + x^{5} + x^{4} + x^{3} + x^{2} + x + 1
x^{20} - x^{19} + x^{17} - x^{16} + x^{14} - x^{13} + x^{11} - x^{10} + x^{9} - x^{7} + x^{6} - x^{4} + x^{3} - x + 1
x^{60} - x^{57} + x^{51} - x^{48} + x^{42} - x^{39} + x^{33} - x^{30} + x^{27} - x^{21} + x^{18} - x^{12} + x^{9} - x^{3} + 1
I want to write the If statement below in a Google Sheet:
If today's date is greater than the payment deadline, then return the overdue payment amount. Otherwise, return 0.
I did this:
=if(F11<"=TODAY()",C11,0) + if(F12<"=TODAY()",C12,0) + if(F13<"=TODAY()",C13,0) + if(F14<"=TODAY()",C14,0) + if(F15<"=TODAY()",C15,0) + if(F16<"=TODAY()",C16,0) + if(F17<"=TODAY()",C17,0)
The values in column F are dates written the date format month/day/year. All of the dates in column F are greater than today's date.
The values in column C are dollar amounts with decimals.
First Attempt:
=if(F11<"=TODAY()",C11,0) + if(F12<"=TODAY()",C12,0) + if(F13<"=TODAY()",C13,0) + if(F14<"=TODAY()",C14,0) + if(F15<"=TODAY()",C15,0) + if(F16<"=TODAY()",C16,0) + if(F17<"=TODAY()",C17,0)
Second Attempt:
=if(F11<"TODAY()",C11,0) + if(F12<"TODAY()",C12,0) + if(F13<"TODAY()",C13,0) + if(F14<"TODAY()",C14,0) + if(F15<"TODAY()",C15,0) + if(F16<"TODAY()",C16,0) + if(F17<"TODAY()",C17,0)
Third Attempt:
=if(DATEVALUE(F11)<"TODAY()",C11,0) + if(DATEVALUE(F12)<"TODAY()",C12,0) + if(DATEVALUE(F13)<"TODAY()",C13,0) + if(DATEVALUE(F14)<"TODAY()",C14,0) + if(DATEVALUE(F15)<"TODAY()",C15,0) + if(DATEVALUE(F16)<"TODAY()",C16,0) + if(DATEVALUE(F16)<"TODAY()",C17,0)
I expect to get 0 overdue payments as all the payment deadlines are greater than today's day. Could you please help me?
your formula should be:
=IF(F11<TODAY(), C11, 0) +
IF(F12<TODAY(), C12, 0) +
IF(F13<TODAY(), C13, 0) +
IF(F14<TODAY(), C14, 0) +
IF(F15<TODAY(), C15, 0) +
IF(F16<TODAY(), C16, 0) +
IF(F17<TODAY(), C17, 0)
next level formula would be:
=ARRAYFORMULA(SUM(IF(F11:F17<TODAY(), C11:C17, 0)))
or shorter:
=SUMIF(F11:F17, "<"&TODAY(), C11:C17)
I have a sql Statement with multiple cases now I have to write the statement in Dax
I tried using switch but the output is not same
the sql statement :
CASE WHEN #STRIKER!='' OR #NONSTRIKER!='' THEN (RUNS + (CASE WHEN BYES = 0 AND LEGBYES = 0 THEN OVERTHROW ELSE 0 END))
WHEN #BOWLER!='' THEN (RUNS + WIDE+ (CASE WHEN BALL.NOBALL > 0 AND (BALL.BYES > 0 OR BALL.LEGBYES > 0) THEN BALL.BYES + BALL.NOBALL + BALL.LEGBYES
WHEN BALL.NOBALL > 0 AND BALL.BYES = 0 AND BALL.LEGBYES = 0 THEN BALL.NOBALL
ELSE 0 END) + (CASE WHEN BYES = 0 AND LEGBYES = 0 THEN OVERTHROW ELSE 0 END))
ELSE GRANDTOTAL END ) AS RUNS
First, I would simplify the case statement,
I assume you have the case statements because NULLS can exist in your result? you could simply try
RUNS +
WIDE +
ISNULL(BALL.NOBALL,0) +
ISNULL(BALL.BYES,0) +
ISNULL(BALL.LEGBYES,0) +
ISNULL(OVERTHROW,0)
But if you've already got the model in PowerBI with those columns listed, you could simply add a calculated column that would sum all the columns which would ignore the nulls...
Total = RUNS + WIDE + NOBALL + BYES + LEGBYES + OVERTHROW
? but without the schema, its really hard to know what the solution might be.
good luck!
Can I check china or not given lat, lon GPS Data?
If user stay in china then
STEP1. check lat/lon in offline func
If true
request googleGeocoding API for china
like this..
var chinaGoogleGeocoding="http://maps.google.cn/maps/api/geocode/json?language=en&latlng=" + pos.coords.latitude + "," + pos.coords.longitude + "&key=" + Google_API_Key;
else
var googleGeocoding="https://maps.googleapis.com/maps/api/geocode/json?language=en&latlng=" + pos.coords.latitude + "," + pos.coords.longitude + "&key=" + Google_API_Key;
Could you advising me?
I check http://maps.google.cn is working fine other country..but I want use it only user stay in china.
http://www.latlong.net
I think china's lat is start 37, end 47 and lon is start 123, end 110
so...
if((pos.coords.latitude>=37 && pos.coords.latitude<=47)&& (pos.coords.latitude>=110 && pos.coords.latitude<=123))
{
//china
var chinaGoogleGeocoding="http://maps.google.cn/maps/api/geocode/json?language=en&latlng=" + pos.coords.latitude + "," + pos.coords.longitude + "&key=" + Google_API_Key;
}else {
var googleGeocoding="https://maps.googleapis.com/maps/api/geocode/json?language=en&latlng=" + pos.coords.latitude + "," + pos.coords.longitude + "&key=" + Google_API_Key;
}
Is it right?
Usually a country region can be defined by something like GeoJson
Once you have a defined region to work with, you can compute if the coordinate you have received is inside the defined region for China.
How can I select 30 days less (before) date from today in imacro?
TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:ReportAll.aspx ATTR=ID:ContentPlaceHolderMiddle_TxtFromDate CONTENT={{!NOW:dd/mm/yyyy}}
Play this and apply to your macro:
SET D "var d = new Date();"
' 30 days before
ADD D "d.setDate(d.getDate() - 30);"
' or 1 month before
'ADD D "d.setMonth(d.getMonth() - 1);"
ADD D "d = ('0' + d.getDate()).slice(-2) + '/' + ('0' + (d.getMonth() + 1)).slice(-2) + '/' + d.getFullYear();"
SET dateBefore EVAL("eval('{{D}}'); d;")
PROMPT {{dateBefore}}