text:
# Tag Info

5

Given that policies are probability distributions, in principle, you can use any metric or measure of distance that can be used to compare two probability distributions. (Note that notions of distance are not necessarily metrics in a mathematical sense). A common measure is the Kullback–Leibler divergence (which is not a metric, in a mathematical sense, ...

2

I don't have a definite answer, but only a suspicion/idea: Looking at Figure 1 from the WGAN paper, we clear see that the JS divergence on the right is not continuous at $0$, hence not differentiable at $0$. However, the EM plot on the left is continuous also at $0$. You could now argue that we have a kink there, so it should not be differentiable there ...

2

This question is very general in the sense that the reason may differ depending on the area of ML you are considering. Below are two different areas of ML where the KL-divergence is a natural consequence: Classification: maximizing the log-likelihood (or minimizing the negative log-likelihood) is equivalent to minimizing KL divergence as typical used in DL-...

1

In ML we always deal with unknown probability distributions from which the data comes. The most common way to calculate the distance between real and model distribution is $KL$ divergence. Why Kullback–Leibler divergence? Although there are other loss functions (e.g. MSE, MAE), $KL$ divergence is natural when we are dealing with probability distributions. It ...

Only top voted, non community-wiki answers of a minimum length are eligible


text:
# Matlab filter design,through group delay

I have the measurements of a filter’s Group delay and S-parameters. The S-parameters are of the following form, presented in a touchstone file.

!Agilent Technologies,N5242A,MY49421489,A.09.33.09
!Agilent N5242A: A.09.33.09
Date: Thursday, March 22, 2012 19:50:06
!Correction: S11(Full 2 Port(1,2))
!S21(Full 2 Port(1,2))
!S12(Full 2 Port(1,2))
!S22(Full 2 Port(1,2))
!S2P File: Measurements: S11, S21, S12, S22: Hz S dB R 50
1450000000 -0.44925556 132.79056 -43.664959 42.970737 -43.609634 45.291161 -0.41757283 131.60133

The filter’s Group delay data are like those demonstrated below:

!CSV A.01.01 !Date: Thursday March 22
!Source: Standard
BEGIN CH1_DATA
Freq(Hz) S21 Delay(s)
1.45E+09 -2.02E-08
1.45E+09 -1.32E-08
1.45E+09 -1.77E-08
1.45E+09 -1.70E-08
1.45E+09 -1.56E-08
1.45E+09 -1.36E-08
1.45E+09 -1.20E-08

What I want to do is simulate the impact that the group delay will have on a particular waveform using MATLAB. I tried to use the fdesign.arbgrpdelay in order to insert my group delay data and somehow observe how that would impact on a waveform but I am getting the following errors:

Error using fdesign.abstracttype/superdesign (line 96) Design options must be specified as a structure or as parameter-value pairs.

Error in fdesign.abstracttype/design (line 11) varargout{1} = superdesign(this, varargin{:});

Error in allpassfilterarbitrarygrpdly (line 413) Hgd = design(hgd,'iirlpnorm','Weights','MaxPoleRadius',0.95);

I also tried to use fdatool but I couldn't find a way of designing a filter by changing its group delay. The group delay was flat in all the available designs.

Does anyone knows how I can use the Group delay measurements in matlab to simulate a filter through its group delay?

• Your question seems unclear. What exactly are you trying to measure? Do you have group delays of the filter with respect to frequency of the signal? – Hephaestus Sep 1 '12 at 22:01
• Exactly,I have the group delays in respect with frequency(as they are illustrated in the two columns Freq(Hz) S21 Delay(s)).I want to see the impact that they have in a waveform after this waveform been filtered by a filter having that group delay response. – Rizias Sep 1 '12 at 23:07

## 2 Answers

The Solution finally was to match the input vectors in the group delay simulating Matlab functions.That means that the frequencies and the group delay Vectors given as input in Matlab should be SHORT and not as long as i had to give,and exactly on the same length (which makes sense).The most tricky part is to find which length was that would fit in and run the simulation.

• Can you add the code in your answer that solves the problem? – Naveen May 9 '15 at 19:30
• That was some years ago,I dont know even if i have the code. – Rizias May 11 '15 at 9:15
• Can you give this answer the check mark? Just trying to get more old questions to have accepted answers! :-) – Peter K. Dec 5 '15 at 3:23

Have a look at fdesign.arbgrpdelay.

The example there is:

Create an arbitrary group delay filter that delays the higher–frequency wave packet by approximately 100 samples.

And they give the code:

N = 18;
f = 0:.1:1;
gd = ones(size(f));
% Delay pi/2 radians/sample by 100 samples
gd(6) = 100;
d = fdesign.arbgrpdelay(N,f,gd);
Hd = design(d,'iirlpnorm','MaxPoleRadius',0.9);
% Visualize the group delay
fvtool(Hd,'analysis','grpdelay');

format: plain


text:
Tag Info

0

There appears to be a problem with version 10.1 compared to version 10.0 Your direct integration implies that your Fourier parameters are {-1, 1} \$Version "10.0 for Mac OS X x86 (64-bit) (December 4, 2014)" F[w_] = 1/(1 - I*w); f[t_] = InverseFourierTransform[F[w], w, t, FourierParameters -> {-1, 1}] (2*Pi*HeavisideTheta[t])/E^t F[w] == ...

4

The functions Fourier, FourierTransform, InverseFourier, and InverseFourierTransform (possibly others that I am not aware of) all accept a parameter called FourierParameters to determine the flavor of transform performed. By default, the value of FourierParameters is {0, 1}, which gives the results you've observed. To run a 'traditional' Fourier transform, ...

9

InverseLaplaceTransform[(2 s^2 + s + 13)/((s - 1) ((s + 1)^2 + 4)), s, t] 2*E^t + (3/4)IE^((-1 - 2*I)t) (-1 + E^(4*I*t)) % // ComplexExpand // Simplify 2*E^t - (3*Cos[t]*Sin[t])/E^t % // TrigReduce ((1/2)*(4*E^(2*t) - 3*Sin[2*t]))/E^t In "one" step InverseLaplaceTransform[(2 s^2 + s + 13)/((s - 1) ((s + 1)^2 + 4)), s, t] // ...

4

Update First I'd like to mention that after checking the definition of bilateral Laplace transform and Fourier transform carefully, I'm sure currently the formula for the relationship between them on the wikipedia page is wrong, the correct one should be: $$\mathcal{B}\{f(t)\}(s) = \sqrt{2\pi}\mathcal{F}\{f(t)\}(is)$$ Then we can use the internal function ...

Top 50 recent answers are included


text:
# Cleaning Old Soda Off Of A Circuit Board?

P

#### phaeton

Jan 1, 1970
0
Hey y'all. Been awhile since I've been here. I've missed the joint.

I might be picking up an old SS Fender bass amp from a guy at work for
dirt cheap. Like buy him a case of beer and it's mine, cheap.

Anyways, I don't know the details, but at some point in its
illustrious history, it was laying on its back, and a Wild Cherry
Pepsi got dumped onto it. Supposedly the speaker is fine, but the
soda seeped into the front panel of the amp, into all the pots and the
eq sliders, and most likely down onto the circuit board.

The good news is, it still works, it just sounds like shit. They say
it's kinda distorted, makes noises, and the volume fluctuates
constantly while you're playing. It can go from normal, to whisper,
to OMFGTHEWALLSARECRACKINGLOUD (in true Fender style) on whatever whim
it wants. Sounds like dirty/gummy pots to me. I fixed this on my old
Peavey Pacer many years ago with a $10 can of Contact Cleaner/ Lubricant from Radio Shack. (No soda in that case, just age and dirt). The other good news is that shortly after this happened, the guy and his brother took it all apart and tried cleaning it up with Isoprophyl Rubbing Alcohol. Hopefully this means that it hasn't had a lot of soda on the circuit board for the last few years. However, something tells me that the water content and lack of lubricant could seize the pots. I still have most of a can of that Contact Lubricant, and I'll happily buy more if necessary. It'll probably work on the pots and sliders if I treat them several times. If not, I could always replace them all. Do you think it will also do any good (or harm) on the rest of the circuit board? At this point, I almost wonder if gently agitating the board in warm distilled water for awhile would do any harm, and/or maybe some good. I don't have it here yet, so I haven't taken it out to look at it. It's very possible that the whole thing is a wreck, and if that's the case I at least have a cabinet and (hopefully) a good speaker. I might pick it up this weekend so I'll take a look then. Thoughts? J #### [email protected] Jan 1, 1970 0 Hey y'all. Been awhile since I've been here. I've missed the joint. I might be picking up an old SS Fender bass amp from a guy at work for dirt cheap. Like buy him a case of beer and it's mine, cheap. Anyways, I don't know the details, but at some point in its illustrious history, it was laying on its back, and a Wild Cherry Pepsi got dumped onto it. Supposedly the speaker is fine, but the soda seeped into the front panel of the amp, into all the pots and the eq sliders, and most likely down onto the circuit board. The good news is, it still works, it just sounds like shit. They say it's kinda distorted, makes noises, and the volume fluctuates constantly while you're playing. It can go from normal, to whisper, to OMFGTHEWALLSARECRACKINGLOUD (in true Fender style) on whatever whim it wants. Sounds like dirty/gummy pots to me. I fixed this on my old Peavey Pacer many years ago with a$10 can of Contact Cleaner/
Lubricant from Radio Shack. (No soda in that case, just age and
dirt).

The other good news is that shortly after this happened, the guy and
his brother took it all apart and tried cleaning it up with Isoprophyl
Rubbing Alcohol. Hopefully this means that it hasn't had a lot of
soda on the circuit board for the last few years. However, something
tells me that the water content and lack of lubricant could seize the
pots.

I still have most of a can of that Contact Lubricant, and I'll happily
buy more if necessary. It'll probably work on the pots and sliders if
I treat them several times. If not, I could always replace them all.
Do you think it will also do any good (or harm) on the rest of the
circuit board? At this point, I almost wonder if gently agitating the
board in warm distilled water for awhile would do any harm, and/or
maybe some good.

I don't have it here yet, so I haven't taken it out to look at it.
It's very possible that the whole thing is a wreck, and if that's the
case I at least have a cabinet and (hopefully) a good speaker. I
might pick it up this weekend so I'll take a look then.

Thoughts?

With dirty equipment I've found over the years that fancy alchohols
and degreasers are a waste of time and money. The most effective
cleaning method is to be brutal and use a mix of really, really hot
water and washing up liquid dispensed by a pressure sprayer (one of
those pump up things). Particularly bad patches attended to by use of
a paintbrush.
It's essential that a thorough rinse in clean hot water is given
afterwards (pressure sprayer again), followed by drying at a high
temperature (say 40degC) for as long a time as possible.
Dishwashers can be even easier if the parts will fit in.

L

#### Lionel

Jan 1, 1970
0
The good news is, it still works, it just sounds like shit. They say
it's kinda distorted, makes noises, and the volume fluctuates
constantly while you're playing. It can go from normal, to whisper,
to OMFGTHEWALLSARECRACKINGLOUD (in true Fender style) on whatever whim
it wants. Sounds like dirty/gummy pots to me. I fixed this on my old
Peavey Pacer many years ago with a $10 can of Contact Cleaner/ Lubricant from Radio Shack. (No soda in that case, just age and dirt). The other good news is that shortly after this happened, the guy and his brother took it all apart and tried cleaning it up with Isoprophyl Rubbing Alcohol. That's a big plus. I've fixed lots of equipment that's suffered drink spills (coffee, coke, wine, beer, etc), & the single biggest factor that determines whether it survives is how fast the power is removed & the gunk washed out. Hopefully this means that it hasn't had a lot of soda on the circuit board for the last few years. However, something tells me that the water content and lack of lubricant could seize the pots. Yes, absolutely. I still have most of a can of that Contact Lubricant, and I'll happily buy more if necessary. It'll probably work on the pots and sliders if I treat them several times. If not, I could always replace them all. Do you think it will also do any good (or harm) on the rest of the circuit board? At this point, I almost wonder if gently agitating the board in warm distilled water for awhile would do any harm, and/or maybe some good. If you're careful, it's a good idea. After you wash the board, you also need to wash in alcohol. The important thing is make sure that it's 100% dried out (gently!) before you next apply power. I put boards on a folded towel & sit them in a dry, warm (30-40c or so) place for at least 3 days to make sure that all the crevices (like under chips) are totally free of moisture. The alcohol helps a lot with this. I don't have it here yet, so I haven't taken it out to look at it. It's very possible that the whole thing is a wreck, and if that's the case I at least have a cabinet and (hopefully) a good speaker. I might pick it up this weekend so I'll take a look then. Thoughts? Go ahead. But you may need to replace the pots anyway. H #### Homer J Simpson Jan 1, 1970 0 I still have most of a can of that Contact Lubricant, and I'll happily buy more if necessary. It'll probably work on the pots and sliders if I treat them several times. If not, I could always replace them all. Do you think it will also do any good (or harm) on the rest of the circuit board? At this point, I almost wonder if gently agitating the board in warm distilled water for awhile would do any harm, and/or maybe some good. Use clean water with baking soda dissolved in it. Rinse off and let dry for a week. P #### Phil Allison Jan 1, 1970 0 With dirty equipment I've found over the years that fancy alchohols and degreasers are a waste of time and money. The most effective cleaning method is to be brutal and use a mix of really, really hot water and washing up liquid dispensed by a pressure sprayer (one of those pump up things). Particularly bad patches attended to by use of a paintbrush. It's essential that a thorough rinse in clean hot water is given afterwards (pressure sprayer again), followed by drying at a high temperature (say 40degC) for as long a time as possible. ** That is the EXACT method I have been using with 100% success for many years to clean PCBs and heatsink modules contaminated by drink spills or just accumulated grime blown in by a fan. Dishwashers can be even easier if the parts will fit in. ** Ain't got one of them. Be neat to dump a whole power amp in one .... ........ Phil M #### MassiveProng Jan 1, 1970 0 Hey y'all. Been awhile since I've been here. I've missed the joint. I might be picking up an old SS Fender bass amp from a guy at work for dirt cheap. Like buy him a case of beer and it's mine, cheap. Anyways, I don't know the details, but at some point in its illustrious history, it was laying on its back, and a Wild Cherry Pepsi got dumped onto it. Supposedly the speaker is fine, but the soda seeped into the front panel of the amp, into all the pots and the eq sliders, and most likely down onto the circuit board. The good news is, it still works, it just sounds like shit. They say it's kinda distorted, makes noises, and the volume fluctuates constantly while you're playing. It can go from normal, to whisper, to OMFGTHEWALLSARECRACKINGLOUD (in true Fender style) on whatever whim it wants. Sounds like dirty/gummy pots to me. I fixed this on my old Peavey Pacer many years ago with a$10 can of Contact Cleaner/
Lubricant from Radio Shack. (No soda in that case, just age and
dirt).

The other good news is that shortly after this happened, the guy and
his brother took it all apart and tried cleaning it up with Isoprophyl
Rubbing Alcohol. Hopefully this means that it hasn't had a lot of
soda on the circuit board for the last few years. However, something
tells me that the water content and lack of lubricant could seize the
pots.

I still have most of a can of that Contact Lubricant, and I'll happily
buy more if necessary. It'll probably work on the pots and sliders if
I treat them several times. If not, I could always replace them all.
Do you think it will also do any good (or harm) on the rest of the
circuit board? At this point, I almost wonder if gently agitating the
board in warm distilled water for awhile would do any harm, and/or
maybe some good.

I don't have it here yet, so I haven't taken it out to look at it.
It's very possible that the whole thing is a wreck, and if that's the
case I at least have a cabinet and (hopefully) a good speaker. I
might pick it up this weekend so I'll take a look then.

Microwave some 99% IPA up and give it a good hot alcohol bath.

Not assembled. Break it down into subassemblies, like the panel,
etc.

Being hot, the IPS should dislodge the soda remnants and surupy
slurry.

Then a good bake out in a 60C oven (140F). THEN, add the contact
spray, which might have some dry lube in it for the pot shafts.

Otherwise, replacing the pots that are sluggish to turn would be a
good step.

If you hot dip the PCB assy., keep from dipping any transformers or
inductors as the tapes used will have their adhesive backings
released, and the bake step above needs to be about a half hour, for a
PCB where you did get a transformer "wet", it would need an hour bake.

M

#### MassiveProng

Jan 1, 1970
0
Use clean water with baking soda dissolved in it. Rinse off and let dry for
a week.
Bake for an hour at 60C.

J

#### JeffM

Jan 1, 1970
0
That's going to make it fun.
From further down in the thread:
Phil Allison wrote:
#Be neat to dump a whole power amp in [a dishwasher]
#
Seems like that's what it might take
--if cleaning would work on all the bits.
I'd brace myself for the probability
that the panel-mounted parts will have to be replaced.
[email protected] jjdesigns.fsnet.co.uk said:
The most effective cleaning method is to be brutal
and use a mix of really, really hot water and washing up liquid
dispensed by a pressure sprayer (one of those pump up things).
I agree with everything you have said
....except one detail:
Particularly bad patches attended to by use of a paintbrush.
A paintbrush has soft bristles. An *acid* brush
http://www.solobrushes.com/pictures/pseries_lg.jpg
with the business end trimmed short for even more stiffness
is the tool.
Any place that sells industrial supplies (pastes) has them.

R

#### Rich Grise

Jan 1, 1970
0
Hey y'all. Been awhile since I've been here. I've missed the joint.

I might be picking up an old SS Fender bass amp from a guy at work for
dirt cheap. Like buy him a case of beer and it's mine, cheap.

Anyways, I don't know the details, but at some point in its
illustrious history, it was laying on its back, and a Wild Cherry
Pepsi got dumped onto it. Supposedly the speaker is fine, but the
soda seeped into the front panel of the amp, into all the pots and the
eq sliders, and most likely down onto the circuit board.

Wash it with carbonated water (club soda). That will get the water-
soluble sugars off of it, which is what gums things up. The contact
cleaner things are usually non-polar solvents, and sugar will just
shrug that off. And blow it dry, don't bake it dry - baking leaves
crud behind. With dry clean compressed air, the liquid water gets
blown away and takes the crud with it.

I used to fix video games and pinballs that were located in bars -
it's amazing what kinds of crud can get on boards in that kind of
venue.

Of course, it's nothing like cleaning medical devices that have been
dropped in a bedpan. =:-O

Good luck!
Rich

M

#### MassiveProng

Jan 1, 1970
0
Wash it with carbonated water (club soda). That will get the water-
soluble sugars off of it, which is what gums things up. The contact
cleaner things are usually non-polar solvents, and sugar will just
shrug that off. And blow it dry, don't bake it dry - baking leaves
crud behind. With dry clean compressed air, the liquid water gets
blown away and takes the crud with it.

Blowing on it does remove any (most) solids as the water/solvent gets
pushed off, but baking is STILL required. Especially for a water
/"club soda" wash, as PCBs are hygroscopic.

Get a clue, grisetard.

M

#### MassiveProng

Jan 1, 1970
0
I used to fix video games and pinballs that were located in bars -
it's amazing what kinds of crud can get on boards in that kind of
venue.

Funny, since the "boards" on a pinball are in the cabinet behind the
backglass.
Of course, it's nothing like cleaning medical devices that have been
dropped in a bedpan. =:-O

Funny, since practically all "medical devices" are immersible.

L

#### Lionel

Jan 1, 1970
0
Funny, since the "boards" on a pinball are in the cabinet behind the
backglass.

Lots of pinball machines have huge PCBs (& usually the PSU as well)
directly under the playing field.
Funny, since practically all "medical devices" are immersible.

Lots of them are, but not "practically all".

R

#### Rich Grise

Jan 1, 1970
0
Lots of pinball machines have huge PCBs (& usually the PSU as well)
directly under the playing field.

Well, actually, I've seen EM (electromechanical) pins that have
point-to-point circuitry right on the bottom of the case, under
the playfield, but the PCB ones usually put the PCB behind the
backglass.

The problem is a lot more prevalent with stand-up and cocktail
videos - but in either case, you'd be surprised where people can
spill their drinks!
Lots of them are, but not "practically all".

Big Dork simply has no clue - he's best left ignored.

Cheers!
Rich

M

#### MassiveProng

Jan 1, 1970
0
Well, actually, I've seen EM (electromechanical) pins that have
point-to-point circuitry right on the bottom of the case, under
the playfield, but the PCB ones usually put the PCB behind the
backglass.

The problem is a lot more prevalent with stand-up and cocktail
videos - but in either case, you'd be surprised where people can
spill their drinks!

Big Dork simply has no clue - he's best left ignored.

So are you, asswipe. Upright video games and cocktail versions of
upright video games are NOT pinballs, you retarded ****.

L

#### Lionel

Jan 1, 1970
0
Well, actually, I've seen EM (electromechanical) pins that have
point-to-point circuitry right on the bottom of the case, under
the playfield,

Yes, I've seen those too, although it's been quite a few years.
but the PCB ones usually put the PCB behind the
backglass.

Nearly all the ones I've seen have PCBs behnd the backglass, & under
the playing field.
The problem is a lot more prevalent with stand-up and cocktail
videos - but in either case, you'd be surprised where people can
spill their drinks!

I worked at an arcade for a while as a teenager, & nothing like that
would surprise me. ;^)

P

#### phaeton

Jan 1, 1970
0
Well, I got it home. The preamp and power amp are two different
boards connected by ribbon cable. Strangely, all the soda is on the
power amp board in the back. Further investigation reveals that the
amp was not 'on' at the time of the spill. It has been turned on
since the initial cleaning, and that's how they know it sounds like
crap. I haven't turned it on to try it out.

Lots of gunk everywhere, bridging traces and leads, but nothing looks
burnt and black or anything.

In lieu of a pump-up pressure sprayer, would a DIY car wash gun work?
Most of them have a 'low pressure jet' that's on by default, until you
squeeze the trigger (for high pressure). How about if I saran wrap up
the transformer and pots and hit it with the low pressure only, then
rinse well, and let it sit up in a sunny place for a couple of weeks
to dry out?

The sliders and knobs were really sticky and stiff, and I went ahead
and blasted them with the Contact Cleaner. All but one slider
improved in 'feel'. I'm going to let them sit a day or so, blast
again, and then track them with an ohmmeter to see if they follow the
curve like they should. If they don't, I won't be heartbroken.

Thanks for the help and suggestions thusfar.

-phaeton

J

#### John Popelish

Jan 1, 1970
0
phaeton said:
Well, I got it home. The preamp and power amp are two different
boards connected by ribbon cable. Strangely, all the soda is on the
power amp board in the back. Further investigation reveals that the
amp was not 'on' at the time of the spill. It has been turned on
since the initial cleaning, and that's how they know it sounds like
crap. I haven't turned it on to try it out.

Lots of gunk everywhere, bridging traces and leads, but nothing looks
burnt and black or anything.

In lieu of a pump-up pressure sprayer, would a DIY car wash gun work?
Most of them have a 'low pressure jet' that's on by default, until you
squeeze the trigger (for high pressure). How about if I saran wrap up
the transformer and pots and hit it with the low pressure only, then
rinse well, and let it sit up in a sunny place for a couple of weeks
to dry out?

The sliders and knobs were really sticky and stiff, and I went ahead
and blasted them with the Contact Cleaner. All but one slider
improved in 'feel'. I'm going to let them sit a day or so, blast
again, and then track them with an ohmmeter to see if they follow the
curve like they should. If they don't, I won't be heartbroken.

Thanks for the help and suggestions thusfar.

It is not at all important that you blast the water in with
any force. All you need is its ability to dissolve the
sugars and slats left behind, and a simple stream will do
that. So you should be able to use a low pressure stream
and avoid dumping it through the transformer (unless it has
soda run through it). The contact cleaner you have used
will make it harder for the water to wet the surfaces
flow of water mixed with dish washing detergent to get under
the oils in the contact cleaner.

When everything looks clean and just wet, a thorough drying
is all that you should need to test the unit. Then, if the
pots are noisy, a little contact cleaner might help
lubricate them.

L

#### Lord Garth

Jan 1, 1970
0
John Popelish said:
phaeton wrote:
It is not at all important that you blast the water in with
any force. All you need is its ability to dissolve the
sugars and slats left behind, and a simple stream will do
that. So you should be able to use a low pressure stream
and avoid dumping it through the transformer (unless it has
soda run through it). The contact cleaner you have used
will make it harder for the water to wet the surfaces
flow of water mixed with dish washing detergent to get under
the oils in the contact cleaner.

When everything looks clean and just wet, a thorough drying
is all that you should need to test the unit. Then, if the
pots are noisy, a little contact cleaner might help
lubricate them.

Don't use tap water or mineral laden drinking water. Use
distilled water. If there is no plastic in the way, I chase the
water with methyl alcohol then blow it dry.

J

#### [email protected]

Jan 1, 1970
0
Don't use tap water or mineral laden drinking water. Use
distilled water. If there is no plastic in the way, I chase the
water with methyl alcohol then blow it dry.

The great bulk of the wash can be done with warm tap water, even hard
water. Just the final rinse is best done with distilled water.
Before that, the contamination being washed off is dirtiuer than the
tap water. No sense rinsing gallons of distilled water down the
drain, brown with Coka Cola.

L

#### Lord Garth

Jan 1, 1970
0
Okay, that makes good sense. I had DI water available from a tap
so it was never an issue. I also used nitrogen to dry the parts, also
from a wall tap.

Replies
6
Views
646
Replies
3
Views
1K
N
Replies
1
Views
950
N_Cook
N
B
Replies
3
Views
964
Jason D.
J
S
Replies
29
Views
2K
I


text:
## cupcake918 2 years ago What is the simplified form of the expression?

1. cupcake918

2. cupcake918

3. aroub

you're going to distribute the exponent which is -4 to both the numerator and the denominator: $\frac{m ^{3(-4)} }{ 4c ^{5(-4)}}$ $\frac{ m^{-12} }{ 256c ^{-20} }$ $\frac{ 256c ^{20} }{ m ^{12} }$


text: You'll need to download the kernel, kernel-core, and kernel-modules packages for your architecture — those three have to be installed as a unit. But other than that, it's fine to leave the other ones for later, you can just sudo dnf install (the three packages I mentioned) and the new kernel will be usable even if things like kernel-headers are backrev. And I see that kmod(rtl8723be.ko) is in kernel-modules, so you don't have to worry about installing kernel-modules-extra.


text:
# Relate the inverse of $U^\top A^{-1} U$ to $A$

Let $A$ be $N\times N$ symmetric positive definite, and let $U$ be $N\times (N-1)$ with full column rank, i.e. $U^\top U$ invertible. $U^\top A^{-1} U$ is invertible according to this answer, but is there any way to relate $(U^\top A^{-1} U)^{-1}$ to $A$ ? I tried the Sherman-Morrison formula, but I did not manage there.

• Just because $U^TU$ and $A$ are invertible doesn't mean $U^TAU$ is. Are you assuming that it is the case? – Arnaud D. Jan 6 '17 at 18:16
• yes we have to assume this. I'll update the post, tx! – yannick Jan 6 '17 at 18:26
• One of the few rules I know to open up inverses with tall dimensions inside is $(X Y)^+ = (X^+ X Y)^+ (X Y Y^+)^+$, where $(\cdot)^+$ denotes the pseudo-inverse. I'm not very optimistic it will help you much but you could try (apply it twice). – Florian Jan 6 '17 at 20:00


text:
Sciencemadness Discussion Board » Special topics » Technochemistry » X-Ray Fluorescence Spectroscopy Using Affordable CCD/CMOS Detectors? Select A Forum Fundamentals   » Chemistry in General   » Organic Chemistry   » Reagents and Apparatus Acquisition   » Beginnings   » Responsible Practices   » Miscellaneous   » The Wiki Special topics   » Technochemistry   » Energetic Materials   » Biochemistry   » Radiochemistry   » Computational Models and Techniques   » Prepublication Non-chemistry   » Forum Matters   » Legal and Societal Issues

Author: Subject: X-Ray Fluorescence Spectroscopy Using Affordable CCD/CMOS Detectors?
CRUSTY
Hazard to Others

Posts: 118
Registered: 5-6-2016
Location: Nearby
Member Is Offline

Mood: High-Order

X-Ray Fluorescence Spectroscopy Using Affordable CCD/CMOS Detectors?

I recently acquired a dental x-ray tube and built a power supply for it. The amplifier electronics required for photomultiplier tube and photodiode x-ray spectrometers are above my level of electronics experience so I sought another option to measure x-ray energy. I came across a paper that claims to do this using a very cheap CMOS image sensor. The paper is: Haro, M. S.; Bessia, F. A.; Pérez, M.; Blostein, J. J.; Balmaceda, D. F.; Berisso, M. G.; Lipovetzky, J. Soft X-Rays Spectroscopy with a Commercial CMOS Image Sensor at Room Temperature. Radiation Physics and Chemistry 2020, 167, 108354. DOI: 10.1016/j.radphyschem.2019.108354

I tried to reproduce their results using a CCD sensor from a webcam and got
some potentially interesting results. Disclaimer: DO NOT ATTEMPT WORK WITH X-RAYS OR HIGH VOLTAGE UNLESS YOU KNOW WHAT YOU'RE DOING! I have proper lead shielding, a Geiger counter, and a dosimeter badge, as well as lots of experience with X-ray equipment in a professional setting.

When x-rays strike a CCD sensor they produce bright spots. The charge imparted by each collision will typically spread out over a few pixels. Each cluster of energized pixels may have a different sum of values depending on the energy of the incident x-ray. We assume that the sum of these pixel values is proportional to the energy of the x-ray. By making a histogram of the sums of all x-ray spots over time, you can effectively make an x-ray energy spectrum given the right sensor.

A typical single frame during x-ray exposure

Histogram of spot energies after one minute of x-ray exposure

This spectrum closely resembles the energy spectrum of an x-ray tube with a tungsten target (like mine). I repeated this several times under different conditions and always got a bremsstrahlung-like curve with two peaks at lower energies. The log spectrum shows a straight slope on the right side of the curve which is also consistent with bremsstrahlung radiation. All three peaks stayed in exactly the same positions over all trials. Placing materials like copper foil between the tube and the sensor caused changes in peak shapes and intensities but no new peaks, so I suspect the weaker XRF lines (if present) are buried by the strong signal from the x-ray tube's target. This is all qualitative so I can't really be sure whether the spectral features are just a coincidence. I tried this with a cheaper CCD sensor but the low-energy end is too noisy to make out any features.

This could potentially be useful for low-cost elemental analysis if implemented properly. I don't know if anyone out there also has access to x-ray equipment but I'd really like to see if others can get similar results. If anyone is interested or looking to try this, I can post my python program I use to collect the data. I am going to try to buy the exact sensor used by Haro et. al to try to reproduce their results more directly. I'll post an update when I get the sensor or if I get any new results before then.

Other papers that use CMOS sensors for X-ray/gamma spectroscopy:
https://doi.org/10.1016/j.nimb.2011.09.007
https://doi.org/10.1109/NSSMIC.2009.5402242
https://doi.org/10.1063/1.5047934

blogfast25
Thought-provoking Teacher

Posts: 10468
Registered: 3-2-2008
Location: Neverland
Member Is Offline

Mood: No Mood

@CRUSTY:

Always good to see someone do something highly quantitative on SM!

Rainwater
National Hazard

Posts: 374
Registered: 22-12-2021
Member Is Offline

If you can get your hands on some old T12 light bulbs or an old cathoray tube tv,
you could improve detection by using
"back projection".
Should offer some protection to the camera as well.

What you want is the phosphorus compound coating the inside of the tube.
Its toxic but if your playing with xrays (jealous) you should be capable of staying safe.
I spent a few years at a recycling center that cleaning light bulbs for disposal,
They washed them in diluted sulfuric acid and sold it back to the bulb factory.

"You can't do that" - challenge accepted
CRUSTY
Hazard to Others

Posts: 118
Registered: 5-6-2016
Location: Nearby
Member Is Offline

Mood: High-Order

What do you mean by "back projection"? This usually refers to the algorithm used to construct 2D slices in a CT scan. I have a few grams of CFL bulb phosphor on hand but I'm not sure I see how this would improve detection here.

wg48temp9
International Hazard

Posts: 739
Registered: 30-12-2018
Location: not so United Kingdom
Member Is Offline

I was intrigued by the idea that a CCD sensor could detect x rays.

Here is the paper on the subject:
Attachment: haro2019.pdf (1.9MB)

Apparently the sensor they used is available from Digikey for $30 (surface mount) but they have an evaluation board available but probably pushes the price to >$100.

However from the detection mechanism I think any silicon optical sensor will also work. I wonder if I can detect the x rays from an old color crt type TV using a simple silicon optical sensor.

PS: I thought of using one of the following sensors as I could cut the window off but could not find one that was cheap and readily available.

Perhaps a small solar cell from a solar powered garden light would work, spray the front black to block light and expose the rear through the thin metal connects to the x rays. It would require seriously high gain amplification.

[Edited on 2/5/2023 by wg48temp9]

I am wg48 but not on my usual pc hence the temp handle.
Thank goodness for Fleming and the fungi.
Old codger' lives matters, wear a mask and help save them.
Be aware of demagoguery, keep your frontal lobes fully engaged.
I don't know who invented mRNA vaccines but they should get a fancy medal and I hope they made a shed load of money from it.
CRUSTY
Hazard to Others

Posts: 118
Registered: 5-6-2016
Location: Nearby
Member Is Offline

Mood: High-Order

 Quote: Originally posted by wg48temp9 PS: I thought of using one of the following sensors as I could cut the window off but could not find one that was cheap and readily available. [Edited on 2/5/2023 by wg48temp9]

If those are photodiodes, then yes you can. The BPW34 photodiode has been used for gamma ray counting when coupled with a transimpedance amplifier stage. One project used four of them in parallel to perform gamma spectroscopy, although the electronics for this are well beyond my understanding.

wg48temp9
International Hazard

Posts: 739
Registered: 30-12-2018
Location: not so United Kingdom
Member Is Offline

Quote: Originally posted by CRUSTY
 Quote: Originally posted by wg48temp9 PS: I thought of using one of the following sensors as I could cut the window off but could not find one that was cheap and readily available. [Edited on 2/5/2023 by wg48temp9]

If those are photodiodes, then yes you can. The BPW34 photodiode has been used for gamma ray counting when coupled with a transimpedance amplifier stage. One project used four of them in parallel to perform gamma spectroscopy, although the electronics for this are well beyond my understanding.

The BPW34 is available from AliExpress about £6 for ten of them but I will have an almost a two month wait for them.

A circut using them as a gamma ray detecter is shown in https://www.electronics-lab.com/bpw34-gamma-ray-detector/

The circuit is:

The front end uses just two high gain transistors with typical current gains of 270.

The BPW34 is encapsulated in plastic which I assume I will have to remove to detect soft X rays. The youtuber applied science shows how to decap ICs:
With ten to try with hopefully I will get one to work after decapping.

Your test using a webcam CCD sensor: was it USB webcam and if you displayed single frames could you see the detection spots. What was the make and model?

I am wg48 but not on my usual pc hence the temp handle.
Thank goodness for Fleming and the fungi.
Old codger' lives matters, wear a mask and help save them.
Be aware of demagoguery, keep your frontal lobes fully engaged.
I don't know who invented mRNA vaccines but they should get a fancy medal and I hope they made a shed load of money from it.
wg48temp9
International Hazard

Posts: 739
Registered: 30-12-2018
Location: not so United Kingdom
Member Is Offline

I was watching a youtube video about a DIY x ray generator.

The youtubers made videos off the experiments. I noticed when the room lighting was low and when the camera faced the x ray beam there were white spots in the image which I assume is detection of x rays. The x rays were generated by about 50kV (my estimate) and apparently traveled thru the camera lens and filters before reaching the camera sensor to generate a sufficiently large signal to register as a white spot. I assume the x rays are hard and not the soft x rays that color crt would generate but it does give me an indication of how a web cam will work with the gain at max.

Below a snip from the video showing the white spots:

I am wg48 but not on my usual pc hence the temp handle.
Thank goodness for Fleming and the fungi.
Old codger' lives matters, wear a mask and help save them.
Be aware of demagoguery, keep your frontal lobes fully engaged.
I don't know who invented mRNA vaccines but they should get a fancy medal and I hope they made a shed load of money from it.

 Sciencemadness Discussion Board » Special topics » Technochemistry » X-Ray Fluorescence Spectroscopy Using Affordable CCD/CMOS Detectors? Select A Forum Fundamentals   » Chemistry in General   » Organic Chemistry   » Reagents and Apparatus Acquisition   » Beginnings   » Responsible Practices   » Miscellaneous   » The Wiki Special topics   » Technochemistry   » Energetic Materials   » Biochemistry   » Radiochemistry   » Computational Models and Techniques   » Prepublication Non-chemistry   » Forum Matters   » Legal and Societal Issues


text:
Love itself became the object of her love.count sadnessesmore quotes

# circles: exciting

Scientific graphical abstracts — design guidelines

# visualization + design

A $\pi$ day music video!: Transcendental Tree Map premieres on 2020 Pi Day from Max Cooper's Yearning for the Infinite. Animation by Nick Cobby and myself. Watch live from Barbican Centre.
Music video of the “Transcendental Tree Map” Max Cooper's Yearning for the Infinite album. This video premiered on 2020 Pi Day. Music by Max Cooper. Animation by Nick Cobby and myself.
The 2020 Pi Day art celebrates digits of $\pi$ with piku (パイク) —poetry inspired by haiku.
They serve as the form for The Outbreak Poems.
Tau Day tree map animation of 8,909 digits of $\tau = 2 \pi$ created with 40,015 lines. The video is 6:28 minutes long.

# The art of Pi ($\pi$), Phi ($\phi$) and $e$

2019 $\pi$ has hundreds of digits, hundreds of languages and a special kids' edition.
2018 $\pi$ day
2017 $\pi$ day
2016 $\pi$ approximation day
2016 $\pi$ day
2015 $\pi$ day
2014 $\pi$ approx day
2014 $\pi$ day
2013 $\pi$ day
Circular $\pi$ art

Numbers are a lot of fun. They can start conversations—the interesting number paradox is a party favourite: every number must be interesting because the first number that wasn't would be very interesting! Of course, in the wrong company they can just as easily end conversations.

The art here is my attempt at transforming famous numbers in mathematics into pretty visual forms, start some of these conversations and awaken emotions for mathematics—other than dislike and confusion

Like music with numbers? Try Angels at My Door (Una), Pt vs Ys (Yoshinori Sunahara), 2wicky (Hooverphonic), One (Aimee Mann), Straight to Number One (Touch and Go), 99 luftbaloons (Nena).

Numerology is bogus, but art based on numbers can be beautiful. Proclus got it right when he said (as quoted by M. Kline in Mathematical Thought from Ancient to Modern Times)

Wherever there is number, there is beauty.

2,258 digits of $\phi$, 3,855 digits of $e$ and 3,628 digits of $\pi$ in 6 level treemaps. Uniform line thickness. Bauhaus prime colors in Piet Mondrian style. (2015 $\pi$ day posters, BUY ARTWORK)
All art posters are available for purchase.
I take custom requests.

## the numbers π, φ and e

The consequence of the interesting number paradox is that all numbers are interesting. But some are more interesting than others—how Orwellian!

All animals are equal, but some animals are more equal than others.
—George Orwell (Animal Farm)

Numbers such as $\pi$ (or $\tau$ if you're a revolutionary), $\phi$, $e$, $i = \sqrt{-1}$, and $0$ have captivated imagination. Chances are at least one of them appears in the next physics equation you come across.

$π φ e$
$= 3.14159 26535 89793 23846 26433 83279 50288 41971 69399 ... = 1.61803 39887 49894 84820 45868 34365 63811 77203 09179 ... = 2.71828 18284 59045 23536 02874 71352 66249 77572 47093 ...$

Of these three transcendental numbers, $\pi$ (3.14159265...) is the most well known. It is the ratio of a circle's circumference to its diameter ($d = \pi r$) and appears in the formula for the area of the circle ($a = \pi r^2$).

2,258 digits of $\phi$, 3,855 digits of $e$ and 3,628 digits of $\pi$ in 6 level treemaps. Uniform line thickness. Bauhaus prime colors in Piet Mondrian style. (2016 $\pi$ day posters, BUY ARTWORK)

The Golden Ratio ($\phi$, 1.61803398...) is the attractive proportion of values $a > b$ that satisfy ${a+b}/2 = a/b$, which solves to $a/b = {1 + \sqrt{5}}/2$.

The last of the three numbers, $e$ (2.71828182...) is Euler's number and also known as the base of the natural logarithm. It, too, can be defined geometrically—it is the unique real number, $e$, for which the function $f(x) = e^x$ has a tangent of slope 1 at $x=0$. Like $\pi$, $e$ appears throughout mathematics. For example, $e$ is central in the expression for the normal distribution as well as the definition of entropy. And if you've ever heard of someone talking about log plots ... well, there's $e$ again!

Two of these numbers can be seen together in mathematics' most beautiful equation, the Euler identity: $e^{i\pi} = -1$. The tau-oists would argue that this is even prettier: $e^{i\tau} = 1$.

## accidentally similar

Did you notice how the 13th digit of all three numbers is the same (9)? This accidental similarity generates its own number—the Accidental Similarity Number (ASN).

# Graphical Abstract Design Guidelines

Fri 13-11-2020

Clear, concise, legible and compelling.

Making a scientific graphical abstract? Refer to my practical design guidelines and redesign examples to improve organization, design and clarity of your graphical abstracts.

Graphical Abstract Design Guidelines — Clear, concise, legible and compelling.

# "This data might give you a migrane"

Tue 06-10-2020

An in-depth look at my process of reacting to a bad figure — how I design a poster and tell data stories.

A poster of high BMI and obesity prevalence for 185 countries.

# He said, he said — a word analysis of the 2020 Presidential Debates

Thu 01-10-2020

Building on the method I used to analyze the 2008, 2012 and 2016 U.S. Presidential and Vice Presidential debates, I explore word usagein the 2020 Debates between Donald Trump and Joe Biden.

Analysis of word usage by parts of speech for Trump and Biden reveals insight into each candidate.

# Points of Significance celebrates 50th column

Mon 24-08-2020

We are celebrating the publication of our 50th column!

To all our coauthors — thank you and see you in the next column!

Nature Methods Points of Significance: Celebrating 50 columns of clear explanations of statistics. (read)

# Uncertainty and the management of epidemics

Mon 24-08-2020

When modelling epidemics, some uncertainties matter more than others.

Public health policy is always hampered by uncertainty. During a novel outbreak, nearly everything will be uncertain: the mode of transmission, the duration and population variability of latency, infection and protective immunity and, critically, whether the outbreak will fade out or turn into a major epidemic.

The uncertainty may be structural (which model?), parametric (what is $R_0$?), and/or operational (how well do masks work?).

This month, we continue our exploration of epidemiological models and look at how uncertainty affects forecasts of disease dynamics and optimization of intervention strategies.

Nature Methods Points of Significance column: Uncertainty and the management of epidemics. (read)

We show how the impact of the uncertainty on any choice in strategy can be expressed using the Expected Value of Perfect Information (EVPI), which is the potential improvement in outcomes that could be obtained if the uncertainty is resolved before making a decision on the intervention strategy. In other words, by how much could we potentially increase effectiveness of our choice (e.g. lowering total disease burden) if we knew which model best reflects reality?

This column has an interactive supplemental component (download code) that allows you to explore the impact of uncertainty in $R_0$ and immunity duration on timing and size of epidemic waves and the total burden of the outbreak and calculate EVPI for various outbreak models and scenarios.

Nature Methods Points of Significance column: Uncertainty and the management of epidemics. (Interactive supplemental materials)

Bjørnstad, O.N., Shea, K., Krzywinski, M. & Altman, N. (2020) Points of significance: Uncertainty and the management of epidemics. Nature Methods 17.

Bjørnstad, O.N., Shea, K., Krzywinski, M. & Altman, N. (2020) Points of significance: Modeling infectious epidemics. Nature Methods 17:455–456.

Bjørnstad, O.N., Shea, K., Krzywinski, M. & Altman, N. (2020) Points of significance: The SEIRS model for infectious disease dynamics. Nature Methods 17:557–558.

# Cover of Nature Genetics August 2020

Mon 03-08-2020

Our design on the cover of Nature Genetics's August 2020 issue is “Dichotomy of Chromatin in Color” . Thanks to Dr. Andy Mungall for suggesting this terrific title.

Dichotomy of Chromatin in Color. Nature Genetics, August 2020 issue. (read more)

The cover design accompanies our report in the issue Gagliardi, A., Porter, V.L., Zong, Z. et al. (2020) Analysis of Ugandan cervical carcinomas identifies human papillomavirus clade–specific epigenome and transcriptome landscapes. Nature Genetics 52:800–810.


text:
# Find The Supremum

Calculus Level 5

What is the supremum value of $$c$$ such that there exists a differential function $$f: [0, \infty) \to (0, \infty)$$ that satisfies

$f'(x)=cf(x+1)?$

Give your answer to 3 decimal places.

×


text:
Teoreticheskaya i Matematicheskaya Fizika
 RUS  ENG JOURNALS   PEOPLE   ORGANISATIONS   CONFERENCES   SEMINARS   VIDEO LIBRARY   PACKAGE AMSBIB
 General information Latest issue Archive Impact factor Subscription Guidelines for authors License agreement Submit a manuscript Search papers Search references RSS Latest issue Current issues Archive issues What is RSS

 TMF: Year: Volume: Issue: Page: Find

 The adiabatic $S$-matrix and quasiparticlesV. N. Likhachev, Yu. S. Tyupkin, A. S. Schwarz 3 Stationary-phase method for Feynman's continual integralV. P. Maslov 30 Essentially nonlinear interaction Lagrangians and nonlocalized quantum field theoryG. V. Efimov 36 Velocity of propagation of a signal, and the space-time metric in nonlinear electrodynamicsDao Vong Dyc, Nguyen Van Hieu 55 Towards the question of $CPT$-invariant theories of infinite-component fieldsL. M. Slad 67 Glauber type representation for the scattering amplitude of high-energy Dirac particles on smooth potentialsS. P. Kuleshov, V. A. Matveev, A. N. Sisakyan 73 Generalized wave operators and regularization of perturbation seriesL. A. Sakhnovich 80 Generalized wave operators and regularization of perturbation seriesV. A. Zhelnorovich 87 Application of the nonequilibrium statistical operator to the derivation of equations of relaxational nonlinear hydrodynamics (part I)L. A. Pokrovskii 103 Polarization effects in induced scattering of high-frequency electromagnetic waves in plasmaN. V. Sholokhov 117 Bogolyubov's statistical variational principle and the Green's function method applied to the Heisenberg–Ising modelYu. G. Rudoi 129


text:
# Print this diamond

This question has been spreading like a virus in my office. There are quite a variety of approaches:

Print the following:

        1
121
12321
1234321
123454321
12345654321
1234567654321
123456787654321
12345678987654321
123456787654321
1234567654321
12345654321
123454321
1234321
12321
121
1

Answers are scored in characters with fewer characters being better.

• What is the winning criterion ? And is this a challenge or a golf ? Oct 12, 2012 at 15:33
• I read "kolmogorov-complexity" as "code-golf". Oct 12, 2012 at 16:44
• @DavidCarraher "kolmogorov-complexity" was edited in after the question was asked. The original questioner has not specified the winning criteria yet. Oct 12, 2012 at 20:56
• @Gareth My comment was made after the "kolmogorov-complexity" tag was added but before the "code-golf" tag was added. At that time people were still be asking whether it was a code-golf question. Oct 12, 2012 at 22:00
• perlmonks.com/?node_id=891559 has perl solutions. Oct 20, 2012 at 19:51

# Clojure, 191 179 bytes

#(loop[[r & s](range 18)h 1](print(apply str(repeat(if(< r 8)(- 8 r)(- r 8))\ )))(doseq[m(concat(range 1 h)(range h 0 -1))](print m))(println)(if s(recur s((if(< r 8)inc dec)h))))

-12 bytes by changing the outer doseq to a loop, which allowed me to get rid of the atom (yay).

A double "for-loop". The outer loop (loop) goes over each row, while the inner loop (doseq) goes over each number in the row, which is in the range (concat (range 1 n) (range n 0 -1)), where n is the highest number in the row.

(defn diamond []
(let [spaces #(apply str (repeat % " "))] ; Shortcut function that produces % many spaces
(loop [[row-n & r-rows] (range 18) ; Deconstruct the row number from the range
high-n 1] ; Keep track of the highest number that should appear in the row
(let [top? (< row-n 8) ; Are we on the top of the diamond?
f (if top? inc dec) ; Decided if we should increment or decrement
n-spaces (if top? (- 8 row-n) (- row-n 8))] ; Calculate how many prefix-spaces to print
(print (spaces n-spaces)) ; Print prefix-spaces
(doseq [m (concat (range 1 high-n) (range high-n 0 -1))] ; Loop over the row of numbers
(print m)) ; Print the number
(println)

(if r-rows
(recur r-rows (f high-n)))))))

Due to a bug in the logic in my first attempt (accidentally inserting the prefix-spaces between each number instead), I managed to get this:

1
1       2       1
1      2      3      2      1
1     2     3     4     3     2     1
1    2    3    4    5    4    3    2    1
1   2   3   4   5   6   5   4   3   2   1
1  2  3  4  5  6  7  6  5  4  3  2  1
1 2 3 4 5 6 7 8 7 6 5 4 3 2 1
12345678987654321
1 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 1
1  2  3  4  5  6  7  8  9  8  7  6  5  4  3  2  1
1   2   3   4   5   6   7   8   7   6   5   4   3   2   1
1    2    3    4    5    6    7    6    5    4    3    2    1
1     2     3     4     5     6     5     4     3     2     1
1      2      3      4      5      4      3      2      1
1       2       3       4       3       2       1
1        2        3        2        1
1         2         1

Not even correct ignoring the obvious bug, but it looked cool.

• That's a super-pretty bug. Perhaps there should be a challenge to generate that... Jul 5, 2021 at 11:37

## J, 29 26 24 23 22 21 chars

,.(0&<#":)"+9-+/~|i:8

Thanks to FUZxxl for the "+ trick (I don't think I've ever used u"v before, heh).

### Explanation

                  i:8  "steps" vector: _8 _7 _6 ... _1 0 1 ... 7 8
|     magnitude
+/~      outer product using +
9-         inverts the diamond so that 9 is in the center
(      )"+           for each digit:
#                  copy
0&<                   if positive then 1 else 0
":                copies of the string representation of the digit
(in other words: filter out the strictly positive
,.                     ravel each item of the result of the above
(necessary because the result after # turns each
scalar digit into a vector string)

• Instead of "0], write "+. Apr 11, 2015 at 10:26
• For one less character, write ,.0(<#":)"+9-+/~|i:8 Apr 11, 2015 at 13:24
• Here is your solution translated to 25 characters of APL: ⍪↑{(0<⍵)/⍕⍵}¨9-∘.+⍨|9-⍳17 Apr 11, 2015 at 13:44
• This here is peak J Oct 4, 2020 at 14:37

## APL (33 31)

A⍪1↓⊖A←A,0 1↓⌽A←⌽↑⌽¨⍴∘(1↓⎕D)¨⍳9

If spaces separating the numbers are allowed (as in the Mathematica entry), it can be shortened to 28 26:

A⍪1↓⊖A←A,0 1↓⌽A←⌽↑⌽∘⍕∘⍳¨⍳9

Explanation:

• (Long program:)
• ⍳9: a list of the numbers 1 to 9
• 1↓⎕D: ⎕D is the string '0123456789', 1↓ removes the first element
• ⍴∘(1↓⎕D)¨⍳9: for each element N of ⍳9, take the first N elements from 1↓⎕D. This gives a list: ["1", "12", "123", ... "123456789"] as strings
• ⌽¨: reverse each element of this list. ["1", "21", "321"...]

• (Short program:)

• ⍳¨⍳9: the list of 1 to N, for N [1..9]. This gives a list [[1], [1,2], [1,2,3] ... [1,2,3,4,5,6,7,8,9]] as numbers.
• ⌽∘⍕∘: the reverse of string representation of each of these lists. ["1", "2 1"...]
• (The same from now on:)
• A←⌽↑: makes a matrix from the list of lists, padding on the right with spaces, and then reverse that. This gives the upper quadrant of the diamond. It is stored in A.
• A←A,0 1↑⌽A: A, with the reverse of A minus its first column attached to the right. This gives the upper half of the rectangle. This is then stored in A again.
• A⍪1↓⊖A: ⊖A is A mirrored vertically (giving the lower half), 1↓ removes the top row of the lower half and A⍪ is the upper half on top of 1↓⊖A.
• +1 Amazing. Could you translate it for us APL illiterates? Oct 12, 2012 at 19:36
• Shouldn't non-ascii code be counted in UTF-8 instead of code-points? This would push APL closer to his earthly relatives. Mar 23, 2013 at 5:39
• @JanDvorak No, since there is an APL code page, which fits the entire character set into a single byte. But I think you've probably figured this out at some point since 2013. ;) Jan 25, 2015 at 0:34

# Mathematica 83 49 43 54 51

Print@@#&/@(Sum[k~DiamondMatrix~17,{k,0,8}]/.0->" ")

With 3 bytes saved thanks to Kelly Lowder.

Analysis

The principal part of the code, Sum[DiamondMatrix[k, 17], {k, 0, 8}], can be checked on WolframAlpha.

The following shows the underlying logic of the approach, on a smaller scale.

a = 0~DiamondMatrix~5;
b = 1~DiamondMatrix~5;
c = 2~DiamondMatrix~5;
d = a + b + c;
e = d /. 0 -> "";
Grid /@ {a, b, c, d, e}

• David, you beat me this time! :-) Oct 21, 2012 at 15:29
• Another try (55 chars): f = Table[# - Abs@k, {k, -8, 8}] &; f[f[9]] /. n_ /; n < 1 -> "" // Grid Mar 22, 2013 at 17:56
• Still another (71 chars): Table[9 - ManhattanDistance[{9, 10}, {j, k}], {j, 18}, {k, 18}] /. n_ /; n < 1 -> "" // Grid Mar 22, 2013 at 17:57
• Grid@#@#@9&[Table[#-Abs@k,{k,-8,8}]&]/.n_/;n<1->"" 50 chars. Mar 23, 2013 at 4:26
• A visual display of the code: ArrayPlot[Sum[k~DiamondMatrix~17, {k, 0, 8}], AspectRatio -> 2] Nov 23, 2013 at 15:53

# Python 2, 726967 61

Not clever:

s=str(111111111**2)
for i in map(int,s):print'%8s'%s[:i-1]+s[-i:]

• doesn't work in Python 3+, which requires parens around the arguments to print :( Oct 12, 2012 at 18:27
• @Griffin: In code golf I choose Python 2 or Python 3 depending on whether I need print to be a function. Oct 12, 2012 at 19:29
• s=0x2bdc546291f4b1 Oct 14, 2012 at 1:32
• @gnibbler. Very clever suggestion. Unfortunately, the repr of that hexadecimal includes a trailing 'L'. Oct 15, 2012 at 14:51
• @gnibbler: This works in Python running on 64-bit platforms, but not on 32-bit platforms. Dec 31, 2013 at 8:06

## C, 79 chars

v;main(i){for(;i<307;putchar(i++%18?v>8?32:57-v:10))v=abs(i%18-9)+abs(i/18-8);}

• Explanation please? Apr 12, 2015 at 16:35
• @LucasHenrique 307 characters total. i%18-9 is x value on cartesian plane mirroring itself on the y-axis. i/18-8 is y value on cartesian plane mirroring itself on the x-axis. Sum them together to get 1:1 diagonal (which causes numeric shift to form on 1:1 diamond. (32:57)-v is unichar numeric value for ASCII 0-9. 10 new line. Feb 14, 2017 at 9:13

# Python 2, 60 59

for n in111111111**2:printint('1'*int(n))**2.center(17)

Abuses backticks and repunits.

• The space after in keyword can be removed, just like you did with print keyboard. Oct 23, 2012 at 17:02
• @GlitchMr: Thanks! Updated. Oct 23, 2012 at 17:06
• I get an extra L in the middle seven lines of output. Mar 28, 2013 at 14:56
• You shouldn't...what version of Python are you using? Mar 28, 2013 at 15:07

### GolfScript, 3331 30 characters

Another GolfScript solution

17,{8-abs." "*10@-,1>.-1%1>n}%

Thank you to @PeterTaylor for another char.

Previos versions:

17,{8-abs" "*9,{)+}/9<.-1%1>+}%n*

17,{8-abs" "*9,{)+}/9<.-1%1>n}%

• You don't need the trailing spaces (the text in the question doesn't have them), so you can skip adding the numbers to the spaces and save one char as 17,{8-abs." "*10@-,1>.-1%1>n}% Mar 28, 2013 at 16:21

Mathematica 55 50 45 41 38

(10^{9-Abs@Range[-8,8]}-1)^2/81//Grid

Grid[(10^Array[{9}-Abs[#-9]&,17]-1)^2/81]

• Very nice work. Mar 22, 2013 at 17:17
• @DavidCarraher Thank you :D Mar 23, 2013 at 4:05
• I echo David's remark. How did you come up with this? Mar 27, 2013 at 7:02
• May I update your answer with the shorter modification I wrote? Mar 27, 2013 at 21:49
• @Mr.Wizard Certainly. Mar 28, 2013 at 4:16

# Javascript, 114

My first entry on Codegolf!

for(l=n=1;l<18;n-=2*(++l>9)-1,console.log(s+z)){for(x=n,s="";x<9;x++)z=s+=" ";for(x=v=1;x<2*n;v-=2*(++x>n)-1)s+=v}

If this can be shortened any further, please comment :)

• damn it!! I missed the space and made half diamond. I must sleep now Nov 23, 2016 at 12:41

## PHP, 92 90 characters

<?for($a=-8;$a<9;$a++){for($b=-8;$b<9;){$c=abs($a)+abs($b++);echo$c>8?" ":9-$c;}echo"\n";}

Calculates and prints the Manhattan distance of the position from the centre. Prints a space if it's less than 1.

An anonymous user suggested the following improvement (84 characters):

<?for($a=-8;$a<9;$a++,print~õ)for($b=-8;$b<9;print$c>8?~ß:9-$c)$c=abs($a)+abs($b++);

• 2nd one doesn't work. Mar 22, 2013 at 4:30
• I know it's very late, but I always have a need to golf when I see PHP scripts. 83 bytes with <? skipped per meta. Also, you seem to have some encoding problems in the second code. May 26, 2018 at 18:56
• @Soaku The second one is not mine. It was suggested as an edit to my answer by an anonymous user. I just added it without checking - not really sure why the user didn't just post it as their own attempt really. The meta question post-dates this answer by almost 3 years. May 26, 2018 at 19:43
• I meant, that I don't include <? in the bytecount. I've made some other improvements too. May 26, 2018 at 19:58

### Common Lisp, 113 characters

(defun x(n)(if(= n 0)1(+(expt 10 n)(x(1- n)))))(dotimes(n 17)(format t"~17:@<~d~>~%"(expt(x(- 8(abs(- n 8))))2)))

First I noticed that the elements of the diamond could be expressed like so:

  1   =   1 ^ 2
121  =  11 ^ 2
12321 = 111 ^ 2

etc.

x recursively calculates the base (1, 11, 111, etc), which is squared, and then printed centered by format. To make the numbers go up to the highest term and back down again I used (- 8 (abs (- n 8))) to avoid a second loop

# JavaScript, 81

for(i=9;--i+9;console.log(s))for(j=9;j;s=j--^9?k>0?k+s+k:" "+s:k+"")k=i<0?j+i:j-i

• Running this in my browser shows the diamond, but on an additional line a -7 Jul 8, 2020 at 22:23

# Charcoal, 13 bytes

Ｆ⁹«ＧX⁻⁹ιＩ⁺ι¹↓

Try it online!

### How?

Draws nine, successively smaller, concentric number-diamonds on top of each other:

Ｆ⁹«   Loop ι from 0 to 8:
ＧX     Draw a (filled) polygon with four equilateral diagonal sides
⁻⁹ι      of length 9-ι
Ｉ⁺ι¹    using str(ι+1) as the character
↓       Move down one space before drawing the next one

• This should be now competing as per new consensus in meta. Sep 13, 2017 at 8:16

# Vim, 623938 34 keystrokes

Thanks to @DJMcMayhem for saving a ton of bytes

Thanks to @AaronMiller for saving 4 bytes by generating 12345678987654321 in a different way

9i1<ESC>|C<C-r>=<C-r>"*<C-r>"
<ESC>qqYP9|xxI <ESC>YGpHq7@q

Try it online!

### Explanation:

9i1<ESC>                            Write 9 '1's, leaving the cursor at the end of the line
|C                          Go to the first column and cut all that's to the right of the cursor (implictly into register "), entering insert mode
<C-r>=                    Enter an expression:
<C-r>"*<C-r>"        The contents of register " multiplied with itself
<CR>   Evaluate it, yielding 12345678987654321

qq                                  Start recording into register q
YP                                Yank this entire line and Paste above
9|                              Go to the 9th column
xx                            Delete character under cursor twice
I <ESC>                     Go to the beginning of the line and insert a space and enter normal mode
Y                    Yank this entire line
G                   Go to the last line
p                  Paste in the line below
H                 Go to the first line
q                End recording
7@q             Repeat this 7 times

• You can delete the ma and change ai<space> to I<space>. Dec 4, 2016 at 20:20
• Also, you could probably delete stage 3 if you change stage 1 to pasting above and below. Dec 4, 2016 at 20:21
• @DJMcMayhem Thank you for the suggestion! I initially was thinking about introducing a new register for the copied bits, but this is much shorter! Dec 5, 2016 at 8:37
• 34 bytes by generating the 12345678987654321 mathematically. Readable version Sep 7, 2021 at 20:56
• @AaronMiller Thanks, updated. Sep 9, 2021 at 8:10

## PowerShell (2 options): 9284 45 bytes

1..8+9..1|%{' '*(9-$_)+[int64]($x='1'*$_)*$x}
1..9+8..1|%{' '*(9-$_)+[int64]($x='1'*$_)*$x}

Thanks to Strigoides for the hint to use 1^2,11^2,111^2...

Shaved some characters by:

• Eliminating $w. • Nested the definition of $x in place of its first use.
• Took some clues from Rynant's solution:
• Combined the integer arrays with + instead of , which allows elimination of the parenthesis around the arrays and a layer of nesting in the loops.
• Used 9-$_ to calculate the length of spaces needed, instead of more complicated maths and object methods. This also eliminated the need for $y.

Explanation:

1..8+9..1 or 1..9+8..1 generates an array of integers ascending from 1 to 9 then descending back to 1.

|%{...} pipes the integer array into a ForEach-Object loop via the built-in alias %.

' '*(9-$_)+ subtracts the current integer from 9, then creates a string of that many spaces at the start of the output for this line. [int64]($x='1'*$_)*$x defines $x as a string of 1s as long as the current integer is large. Then it's converted to int64 (required to properly output 1111111112 without using E notation) and squared. • You can save a byte by casting to a long instead of int64 Jul 26, 2018 at 20:50 • Another way to save a byte 1..8+9..1|%{' '*(9-$_)+ +($x='1'*$_+'L')*$x} Sep 19, 2018 at 12:12 # APL (Dyalog Classic), 20 19 bytes (⍉⊢⍪1↓⊖)⍣2⌽↑,⍨\1↓⎕d  Try it online! ⎕d are the digits '0123456789' 1↓ drop the first ('0') ,⍨\ swapped catenate scan, i.e. the reversed prefixes '1' '21' '321' ... '987654321' ↑ mix into a matrix padded with spaces: 1 21 321 ... 987654321  ⌽ reverse the matrix horizontally (...)⍣2 do this twice: ⍉⊢⍪1↓⊖ the transposition (⍉) of the matrix itself (⊢) concatenated vertically (⍪) with the vertically inverted matrix (⊖) without its first row (1↓) # brainfuck, 158 154 bytes ++++++++[->+>++++>+>++++++<<<<]>>>++<<+[-[-<+>>.<]<[->+<]>>>>+>[->+<<.+>]>+[-<+<.->>]<<<.<<]>>>>-[<<<<+[-<+>>.<]<[->+<]>>>>>[->+<<+.>]>-[-<+<-.>>]<<-<.>>]  Try it online! [spaceMem, spaceCount, space, lf, "0", numCount, numMem] ++++++++[->+>++++>+>++++++<<<<]>>>++<<+ [ for spaceCount -[- for spaceCount minus 1 <+ inc spaceMem >>. print space < go to spaceCount ] <[->+<]> fetch spaceCount from spaceMem >>>+ inc number >[- for numCount >+ inc numMem <<.+ print and inc number > go to numCount ] >+[- for numMem plus 1 <+ inc numCount <.- print and decrement number >> go to numMem ] <<<. print lf << go to spaceCount ] >>>>-[ for numCount <<<<+[- for spaceCount plus 1 <+ inc spaceMem >>. print space < go to spaceCount ] <[->+<]> fetch spaceCount from spaceMem >>> inc number >[- for numCount >+ inc numMem <<+. print and inc number > go to numCount ] >-[- for numMem minus 1 <+ inc numCount <-. print and decrement number >> go to numMem ] <<- decrement number <. print lf >> go to numCount ]  # Regenerate, 109 bytes (( {#2-1}| {8})($3${#3+1}|1)(${#4+1}$4|)\n){9}(($6| )(${$7/10}|${$3/10})(${$8-1+1/$8*#7-1/$8}|7){#7-1}\n){8}

Try it here!

## Explanation

The solution is divided into two parts, which generate the upper half of the diamond (including the center line) and the lower half, respectively. The upper half consists of group 1, repeated nine times (...\n){9}; the lower half consists of group 5, repeated eight times (...\n){8}.

The first part of each group handles the spaces. (I've replaced space with underscore in the explanations for better visibility.)

Upper-half spaces:

( {#2-1}| {8})
(            )  Group 2:
_{#2-1}         Space, repeated one less time than the previous length of group 2
|        Or, if this is the first row and there is no previous value of group 2...
_{8}    Space, repeated eight times

Lower-half spaces:

( $6| ) ( ) Group 6: _$6      Space, concatenated to the previous value of group 6
|     Or, if this is the first row and there is no previous value of group 6...
_    A single space

Now for the diamond itself. It can be divided into four quadrants, and I used three different approaches to generate them:

### Top left & top right: concatenation

We generate the left half (including the center) of each row with group 3, and the right half with group 4. For both halves, observe that we can generate the next row by concatenating a digit to the previous row:

 1234 321
|   |
v   v
12345 4321

So we can use a similar approach to what we did for the bottom-half spaces. The only difference is that the character we're concatenating at each step needs to be calculated.

($3${#3+1}|1)
(           )  Group 3:
$3 Previous value of group 3${    }      concatenated to the result of...
#3+1       Previous length of group 3 plus 1
|     Or, if this is the first row and there is no previous value of group 3...
1    The digit 1

(${#4+1}$4|)
(          )  Group 4:
${ } The result of... #4+1 Previous length of group 4 plus 1$4     concatenated to the previous value of group 4
|    Or, if this is the first row and there is no previous value of group 4...
Empty string

### Bottom left: integer division

We generate the left half (including the center) of each row with group 7. Observe that each row is obtained by removing the rightmost digit from the previous row:

12345
|
v
1234

If we treat the entire thing as an integer, we can perform this transformation easily by dividing it by ten:

(${$7/10}|${$3/10})
(                 )  Group 7:
${ } The result of...$7/10              Previous value of group 7, divided by 10
|            Or, if there is no previous value of group 7...
${ } The result of...$3/10     Group 3 (the final upper-left quadrant row) divided by 10

### Bottom right: digit-by-digit

There isn't an easy way to remove a digit from the left side of a previous match, so for the right half of each bottom row, we resort to generating one digit at a time with group 8. Here are the first three rows that we need to generate:

7654321
654321
54321

Each digit is one less than the previous digit, except that we have to "reset" when we hit 1. The reset value is always one less than the length of the left half of the row, which we have access to as group 7.

How can we tell when we've hit 1? I used an integer-division trick I first developed for programming in Acc!!: if N is a positive integer, then 1/N will be one iff N = 1 and zero if N > 1. Multiplying this quantity by (length of group 7) - 1 gives us the reset we need.

(${$8-1+1/$8*#7-1/$8}|7){#7-1}
(                      )        Group 8 (generates one digit at a time):
${ } The result of...$8-1                          Previous value of group 8, minus 1
+     #7                  Plus the length of group 7
1/$8* if the previous value of group 8 equals 1 -1/$8             Minus 1 if the previous value of group 8 equals 1
|           Or, if there is no previous value of group 8...
7          The digit 7
{    }  Generate this many digits on each row:
#7-1   One less than the length of group 7

• This language looks really cool! Funnily enough I was thinking about making a similar one a few weeks back, but figured it'd be too much work :p. Awarding the bounty now. Jun 29, 2021 at 15:45

### Ruby, 766960 54 characters

(-8..8).map{i=_1.abs;puts' '*i+"#{eval(?1*(9-i))**2}"}

(Thanks, Patrick, G B, and Slim Liser!)

Improvements welcome. :)

• 69 chars: f=->x{[*1..x]+[*1...x].reverse};puts f[9].map{|i|(f[i]*'').center 17} Nov 5, 2012 at 21:11
• Great comment, I didn't know the '...' and didn't understand how this could work.
– G B
Nov 25, 2016 at 7:10
• 60 chars: [*-8..8].map{|i|puts' '*i.abs+"#{eval [?1*(9-i.abs)]*2*?*}"}
– G B
Nov 25, 2016 at 8:05
• 54 chars: (-8..8).map{i=_1.abs;puts' '*i+"#{eval(?1*(9-i))**2}"}. It's the same solution optimized. Oct 2, 2020 at 12:22

## R, 71 characters

For the records:

s=c(1:9,8:1);for(i in s)cat(rep(" ",9-i),s[0:i],s[(i-1):0],"\n",sep="")

• +1 - can save a few with message(rep(" ",9-i),s[c(1:i,i:1-1)]) Apr 11, 2015 at 17:14
• @flodel you'd have to note that that prints to stderr, and you could also do for(i in s<-c(1:9,8:1))... to save a byte Dec 14, 2017 at 17:10
• 64 bytes Apr 6, 2018 at 21:05

# k (64 50 chars)

-1'(::;1_|:)@\:((|!9)#'" "),'$i*i:"J"$(1+!9)#'"1";

Old method:

-1',/(::;1_|:)@\:((|!9)#\:" "),',/'+(::;1_'|:')@\:i#\:,/$i:1+!9;  • (1+!9)#'"1" is ,\9#"1" – ngn Dec 5, 2016 at 22:42 # CJam, 31 27 bytes CJam is a lot newer than this challenge, so this answer is not eligible for being accepted. This was a neat little Saturday evening challenge, though. ;) 8S*9,:)+9*9/2%{_W%1>+z}2*N*  Test it here. The idea is to form the upper left quadrant first. Here is how that works: First, form the string " 123456789", using 8S*9,:)+. This string is 17 characters long. Now we repeat the string 9 times, and then split it into substrings of length 9 with 9/. The mismatch between 9 and 17 will offset every other row one character to the left. Printing each substring on its own line we get:  1 23456789 12 3456789 123 456789 1234 56789 12345 6789 123456 789 1234567 89 12345678 9 123456789  So if we just drop every other row (which conveniently works by doing 2%), we obtain one quadrant as desired:  1 12 123 1234 12345 123456 1234567 12345678 123456789  Finally, we mirror this twice, transposing the grid in between to ensure that the two mirroring operations go along different axes. The mirroring itself is just _ "Duplicate all rows."; W% "Reverse their order."; 1> "Discard the first row (the centre row)."; + "Add the other rows.";  Lastly, we just join all lines with newlines, with N*. # Python 3, 54 bytes saved another 3 bytes by letting the int function crash instead of a loop condition. Thanks to dingledooper. i=8 while[print(f'{int("1"*(9-abs(i)))**2:^17}')]:i-=1  Try it online! Python 3, 57 bytes saved 1 byte by using f-Strings thanks to dingledooper. i=8 while i+9:print(f'{int("1"*(9-abs(i)))**2:^17}');i-=1  Try it online! Python 3, 58 bytes Even shorter solution by a different approach (prints one extra space at the beginning of each line). i=8 while i+9:j=abs(i);i-=1;print(' '*j,int('1'*(9-j))**2)  Try it online! Python 3, 61 bytes (without extra spaces) i=8 while i+9:j=9-abs(i);i-=1;print(f'%{8+j}d'%int('1'*j)**2)  Try it online! These are my previous solutions: Python 3, 66 bytes f=lambda c:f'%{8+c}d'%int('1'*c)**2 for c in f(9):print(f(int(c)))  Try it online! Python 3, 71 bytes: f=lambda c:str(int('1'*int(c))**2) for c in f(9):print(f(c).center(17))  Try it online! • Here's 57 bytes using f-strings. In addition, there's this magical 54 byte solution which works because int() throws an error on an empty string. Feb 26, 2021 at 0:00 # jq -nr, 55 bytes range(17)-8|fabs|" "*.+"123456789"[:9-.]+"87654321"[.:]  fabs is not supported on TIO but you can try it on https://jqplay.org/. Alternatively try it on TIO with .*.|sqrt instead of fabs, for 59 bytes. # jq-rn, 766560 59 bytes -6 bytes thanks to ovs and another -6 (plus -5 more indirectly) thanks to Michael Chatiskatzi def r:range(9),7-range(8);r|[8-.-r|"\(" "*.//1-.)"[:1]]|add  Try it online! ### Explanation The -n flag specifies that there is no input; the -r flag outputs the result strings, each on its own line, without quotes. def r: Define a helper function r range(9), which generates the numbers 0 through 8, followed by 7 - range(8); the numbers 7 through 0 Main program: r | Start with the results of r [ For each of those numbers, put the following in a list: 8 - . - r | 8, minus the current number, minus the results of calling r again "\( For each of those numbers, interpolate the following into a string: " " * . Try to repeat a space that many times // and if the result is null (i.e. the number was less than 1), 1 - . subtract the number from 1 instead )" [:1] Take the first character of each resulting string ] | Take each resulting list of strings and add concatenate it together  To help visualize what's going on, here's what just the r|[8-.-r] part does: [8,7,6,5,4,3,2,1,0,1,2,3,4,5,6,7,8] [7,6,5,4,3,2,1,0,-1,0,1,2,3,4,5,6,7] [6,5,4,3,2,1,0,-1,-2,-1,0,1,2,3,4,5,6] [5,4,3,2,1,0,-1,-2,-3,-2,-1,0,1,2,3,4,5] [4,3,2,1,0,-1,-2,-3,-4,-3,-2,-1,0,1,2,3,4] [3,2,1,0,-1,-2,-3,-4,-5,-4,-3,-2,-1,0,1,2,3] [2,1,0,-1,-2,-3,-4,-5,-6,-5,-4,-3,-2,-1,0,1,2] [1,0,-1,-2,-3,-4,-5,-6,-7,-6,-5,-4,-3,-2,-1,0,1] [0,-1,-2,-3,-4,-5,-6,-7,-8,-7,-6,-5,-4,-3,-2,-1,0] [1,0,-1,-2,-3,-4,-5,-6,-7,-6,-5,-4,-3,-2,-1,0,1] [2,1,0,-1,-2,-3,-4,-5,-6,-5,-4,-3,-2,-1,0,1,2] [3,2,1,0,-1,-2,-3,-4,-5,-4,-3,-2,-1,0,1,2,3] [4,3,2,1,0,-1,-2,-3,-4,-3,-2,-1,0,1,2,3,4] [5,4,3,2,1,0,-1,-2,-3,-2,-1,0,1,2,3,4,5] [6,5,4,3,2,1,0,-1,-2,-1,0,1,2,3,4,5,6] [7,6,5,4,3,2,1,0,-1,0,1,2,3,4,5,6,7] [8,7,6,5,4,3,2,1,0,1,2,3,4,5,6,7,8]  Any number that's greater than 0 gets turned into that many spaces (and then trimmed back to a single space). The other numbers gets subtracted from 1 (turning 0 .. -8 into 1 .. 9) and stringified. • tostring can be shortened to @sh here. In general @text and "\(.)" are equivalent with tostring. – ovs Sep 4, 2021 at 21:08 • And join("") can be shortened to add. Sep 4, 2021 at 21:29 • @ovs Very nice! I seem to have skipped over the @ functions when I was looking through the docs. Sep 7, 2021 at 15:06 • Applying this tip by ovs you can go down to 60 bytes. Sep 7, 2021 at 16:22 • @MichaelChatiskatzi Wow, that's a weird idiom. After some playing around, I found a different 60-byte solution that only uses //, which I like better, but thanks for inspiring me to look! Sep 7, 2021 at 19:41 # Raku, 424138 35 chars say " "x 9-$_,(1 x$_)²for 1…9…1  Try it online! • @FrownyFrog Something did change in Perl 6 since this was written (this is a very old answer), fixed. Jul 27, 2018 at 12:42 ## GolfScript, 36 chars Assuming that this is meant as a challenge, here's a basic GolfScript solution: 9,.);\-1%+:a{a{1$+7-.0>\" "if}%\;n}%

## Perl, 43+1

adding +1 for -E which is required for say

say$"x(9-$_).(1x\$_)**2for 1..9,reverse 1..8

edit: shortened a bit

• Is +1 for -E standard? I mean perl -E is the same number of characters as perl -e. :) Aug 23, 2020 at 13:58

## Python, 65

for i in map(int,str(int('1'*9)**2)):print' '*(9-i),int('1'*i)**2

• Try prepending I=int; to your code and replacing all subsequent instances of int with I Nov 27, 2016 at 2:51
• @Cyoce I had thought of that. It would save 2 chars each time int` is used, and it's used 3 times, so it saves 6 chars at a cost of 6 chars. Nov 27, 2016 at 4:05


text:
# orthogonal projection operator

Let $V$ a vector space with $\dim V < \infty$, and $U\subset V$. let $T_U:V\rightarrow V$ with $T_U(v)=2s-v$ where $s$ is the orthogonal projection of $v$ onto $U$. I want to prove that $\forall v_1,v_2\in V \ :\ \langle T_U(v_1) \ | \ T_U(v_2)\rangle = \langle v_1 \ | \ v_2\rangle$.

I tried to do the following:

Let $v_1, v_2 \in V$, and let $s_1$ to be the orthogonal projection of $v_1$ onto $U$ and $s_2$ the orthogonal projection of $s_2$ onto $U$. then:

$\langle T_U(v_1) \ | \ T_U(v_2)\rangle = \langle 2s_1-v_1 \ | \ 2s_2 - v_2\rangle = \langle 2s_1 \ | \ 2s_2\rangle - \langle 2s_1 \ | \ v_2\rangle - \langle v_1 \ | \ 2s_2\rangle + \langle v_1 \ | \ v_2\rangle$

but from there I don't know how to continue..

## 1 Answer

The first three terms are rewritten $$2\langle s_1|s_2-v_2\rangle+2\langle s_1-v_1|s_2\rangle$$ Can you do the rest of the job? Show that each term is equal to zero!